Need overlay script to run before /sbin/init

I’m running a modified version of Frank’s Debian 10 OS. I know there is a way to change the init script (as least there is on the Raspberry Pi). By default, it is /sbin/init. How can I change the script location using uBoot.env?

Imho you can add this to your bootopts (cmdline)


I’m sorry. I don’t understand. What do I put in the uBoot.env file? /proc/cmdline reads like this:

board=bpi-r2 earlyprintk console=ttyS0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait vmalloc=496M debug=7 initcall_debug=0 video=1920x1080 console=tty1 fbcon=map:0 drm.debug=0x7

if you use my image, uboot builds cmd from some environment vars (e.g. root,console,graphic and bootopts), imho best place for init-option is in bootopts

you can show bootopts in uboot with “printenv bootopts”

in uenv.txt you can do this:

bootopts="$bootopts init=/usr/bin/"

if this does not work (your /proc/cmdline shows “$bootopts” as string) you can print bootopts in uboot and use its contents instead of variable

Without the quotes did it for me! Thanks, Frank!

Ok sorry…afair quotes are needed when do setenv in uboot…

Do you want to create overlayfs (readonly rootfs + rw overlay)?

Can you post your script (and maybe depencies)?

I’ve done some modification on Mark Lister’s script. The only dependency that I’m aware of is initramfs-tools needs to be installed. It is here:

I need to write in some code to format the persistent storage upon request at reboot, though… My attempts have so far failed to produce the desired result…

Initramstools imho create an initramfs,do you load it in uboot/kernel? Maybe this is required to mount/write+umount

No, the script only uses certain functions in order to read the /etc/fstab file to properly mount the partitions as required. No initramfs is required for this… This script gets loaded by the kernel, in place of the /sbin/init file, and calls the /sbin/init at the end of the script in order to initialize the rest of the system.

ok, then the initramfs-depency could be dropped :slight_smile: if you got it working

I copied the /usr/share/initramfs-tools/scripts/functions file into my repo and altered the script to use instead of the initramfs-tools version. Still boots, so I guess the initramfs-tools dependency can be dropped…

I went a little further and copied only the functions used into the script and removed the script and package dependencies. Still works, so wheeeeee…

There is another file that can be copied as a control file for the script. It is here:

1 Like

Got reformatting persistent storage correctly to work with my overlay script…