⚕️
wiki
  • Programming
    • Bash
    • Python
    • Yocto
      • Getting Started
      • Minimal Rootfs
      • SDK
    • Tools
      • Git
      • 🖥️LSF
      • Jenkins
      • Dockers
      • ➖Linux Utilities
      • Make
    • Libraries
      • 🔐OpenSSL
  • How To
    • Access FIFO Registers as memory
    • Linux webservers
    • Add contents to Rootfs
    • Passwordless login
    • Mutt Configuration
    • ⌚Tracing + Profiling
      • 🛤️Perf
      • ☮️uftrace
  • Fundamentals
    • Projects
      • Usb Keyboard
      • Untitled
  • Extras
    • Keyboard Shortcuts
Powered by GitBook
On this page
  1. How To

Add contents to Rootfs

Instead of generating cpio and re-compiling kernel, we can generate rootfs and directly boot on to target

Pre-requisites:

  • fakeroot

  • mkimage

  • pigz

#enter fake root, it will go into root shell without root prevelages
fakeroot
cd <any location>
 
#(Extract rootfs or use published rootfs)
cp -Pr <rootfs> ./

cd rootfs/
#(Add your contents)

#Create cpio file
find . | cpio -o -H newc > ../rootfs.cpio

#Add init to cpio file
#This init file override is very important.
echo ./init | cpio -oA -H newc -F ../rootfs.cpio
cd ../

#compress the cpio 
pigz -f -9 -n -c rootfs.cpio > rootfs.cpio.gz

#Create uboot readable image
mkimage -A arm64 -O linux -T ramdisk -C none -n rootfs -d rootfs.cpio.gz rootfs.cpio.gz.u-boot
  • cpio_append and init comes from yocto build for the corresponding architecture

  • if we dont specify anything, init from host machine will be used resulting in x86 compatibility

PreviousLinux webserversNextPasswordless login

Last updated 2 years ago