TL;DR: This doesn't work in bookworm, so if you have this problem ditch it and go back to bullseye where overlayfs 'just works'.
Only read on if you want your eyes to bleed.
Original question: I want answers from people who deeply understand what changes get made under the hood, because so far the raspi-config
method has not worked, nor has painstakingly stepping through that script applying the changes that it should make.
I hadn't messed around with a Pi for a while, but I had enabled overlay in the past and it just worked. This time around, I've bashed my head off it for hours. I'm using the latest Raspberry Pi OS (bookworm) with the very latest package updates. I optimistically ran raspi-config
> "Performance Options" > "P2 Overlay File System Enable/disable read-only file system" and it did not work. It asked "Would you like the overlay file system to be enabled", I say "yes" and it confirms that "The overlay file system is enabled". I reboot. Overlay is not enabled because changes that I make survive a reboot.
So I ran sudo su
and stepped through the raspi-config
script. I pasted all the functions, and ran enable_overlayfs
. It installs the package overlayroot
and writes to the beginning of /boot/firmware/cmdline.txt
:
$ cat /boot/firmware/cmdline.txt
overlayroot=tmpfs console=serial0,115200 console=tty1 root=PARTUUID=974db369-02 rootfstype=ext4 fsck.repair=yes rootwait cfg80211.ieee80211_regdom=GB
That seems to be all raspi-config
function "enable_overlayfs" does. After doing this I manually ran the function "get_overlay_conf", and it returned '0' (successful).
I have to assume that the package overlayroot
works some magic, because there were no overlayfs changes made to /etc/fstab
, and I didn't see any config updates that tell the OS to load the new initrd image.
I reboot. I make a test change and reboot again. The change persists. In other words, FAIL. /boot/firmware/config.txt
still has the overlayroot=tmpfs, but when I poke through the raspi-config
I notice that the function which checks if overlayfs is enabled does grep -q "boot=overlay" /proc/cmdline
. I didn't see anything add that option anywhere but I assume that the /proc/cmdline contains that if the correct initrd is used.
- Should
/etc/fstab
get modified? How? - What points to the new initrd with overlayfs capabilities?
I checked the scripts in the overlayroot
package and they all relate to mounting overlays (mentioning upperdir/lowerdir options) but I can't understand what's supposed to trigger this.
Edit: I uninstalled the "overlayroot" package, disabled overlay, disabled read-only boot, rebooted and tried the entire thing again. This time I noticed that the /boot/config.txt
got updated:
DO NOT EDIT THIS FILE
The file you are looking for has moved to /boot/firmware/config.txt
initramfs initrd.img-6.6.47+rpt-rpi-v8-overlay
^ clearly this file isn't supposed to be updated. Since that didn't work anyway, I added that line to /boot/firmware/config.txt
instead, and rebooted. Still doesn't work. Whatever magic is supposed to happen in the overlayroot package isn't working.
I grabbed the package from /var/cache/apt
and extracted its contents (using dpkg-deb -X
/ dpkg-deb -R
) and I'm looking through the files. It adds overlayfs support to an initrd image, but I don't know if that image is being used, or how to configure it, and neither raspi-config
nor the package appear to handle that properly.
Frankly I've wasted too much time on this and it feels like the typical false economy of Raspberry Pi. Cheap device, waste all your time making it do something simple :(