[BPI-R2] Use a squashfs file as root filesystem?

How do I use a Debian root filesystem packaged in a squashfs file as the root filesystem?

This may help:

https://manpages.debian.org/testing/live-boot-doc/live-boot.7.en.html

Currently my kernel/debian does not use an initrd/initramfs and imho there is no automatic way to create one like it can be done on x86

This is a similar way: Need overlay script to run before /sbin/init

You could also just mount the squashfs directly like we do on OpenWrt (ie. no need for initrd/initramfs when booting to squashfs+overlayfs, just root= parameter on kernel cmdline pointing to squashfs partition)

You’d need a pre-init script which would have to take care of mounting the overlay (with upperdir being either tmpfs or a real r/w filesystem backed by another partition on the eMMC) before launching systemd (unless systemd includes such functionalily, not unlikely, but I’m not aware of that). Anyway, all that should be possible by adding such a script to the squashfs image and using the init= parameter.

Ah, so that’s how that’s done… So in uEnv_r2.txt from frank-w’s u-boot repo, I see this line:

root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

The partition location is correct, but the rootfstype is wrong. Can I set this in my uEnv.txt and it should load correctly? Or do I need the entire line with the change in it?

rootfstype=squashfs

Or do I need to change the bootargs line?

Your mmcblk0p2 is the squashfs? Then it should work if the rootfstype param supports squashfs.

Never mind about the stupid question. I looked closer at the uEnv_r2.txt file and it appears that the bootopt variable is (re)built within a function, so I could set root to the modified line with squashfs in it and the bootopt variable should be built correctly… Whether it loads is another question…

EDIT: Frank, you beat me to it… :sweat_smile:

bootargs will be overridden by concatenation of root,console,bootopts and graphic variable in my uboot by buildargs function