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:
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 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 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 overlayRoot.sh 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 overlayRoot.sh script. It is here:
Got reformatting persistent storage correctly to work with my overlay script…
I would like to achieve the same thing as you achieved with this script, however for me it is not clear where is the uBoot.env file which I have to modify, where should I put the overlayRoot.sh script you created and how can I rebuild / regenerate the uboot to activate these changes? I also use the debian image created by frank-w.
Thank you for your answer in advance.
Edit: I use BPI-R64, but I believe it works the same way.
Uboot config is on BPI-BOOT/bananapi/bpi-r2/linux (or bpi-r64)
file is named uEnv.txt
If it does not exist,create it
Have not found yet time to test it
Thanks for your fast answer. I mounted /dev/mmcblk0p1 (i use the emmc to boot) to /mnt and I found the following files:
I can modify this uEnv.txt file, however I guess I need to include the overlayRoot.sh file somehow into the uImage. How can I do that? This uboot is very new for me, I only used GRUB and initramfs previously to do things before the root gets mounted.
I cloned your repository (https://github.com/frank-w/u-boot/tree/bpi-r64) and built it, but it only created a bin file, I am not sure it has anything to with this uImage.
Thank you again.
Edit: if you can give some keywords which I can google how to create this uImage file that is also awesome. I tried and I found the mkimage command, which requires a -d switch for the data file and I have no idea which file should I use. I guess mkimage is just wrapping the image for uboot, but how do I generate the input data file?
no, do not modify uImage (kernel binary)
you pass name of init_process (=your script) as cmdline from uboot to linux (=cmdline) so that this is started instead of probing for /sbin/init and others
so basicly add this line (make sure path and name of yourscript is right) to uEnv.txt
Thank you. I spent 3 days trying to make it work and now I was able to get it up and running. Now I will try the script Douglas_Orend created for the overlay.
I guess the overlay module is not loaded, so I get the following error message, when the script does a modprobe on it:
modprobe: FATAL: Module overlay not found in directory /lib/modules/5.4.0-BPI-R64-Kernel