TX1, using overlayroot for read-only filesystem

Thank you for you replay.

Here is a simple use of f creating a non-rootfs overlayfs

apt install overlayroot 
cd /tmp
mkdir lower upper work merge
mount -t overlay overlay -o lowerdir=lower,upperdir=upper,workdir=work merge

lower and upper dir merge install merge dir.And what you do in merge dir will show store install upper dir.
https://wiki.archlinux.org/index.php/Overlay_filesystem

I edit /etc/fstab file like this

/dev/mmcblk0p29      /media/root-rw       ext4            defaults                           0 0
/dev/mmcblk0p1       /media/root-ro       ext4            defaults                          0 0
overlay                /                overlay  noauto,x-systemd.automount,lowerdir=/media/root-ro/,upperdir=/media/root-rw/overlay/,workdir=/media/root-rw/overlay-workdir/ 0 1

But this does not work and get some error! How should I configure this file?

Did you manage to get the root fs overlay working?

I need the same functionality on TX2.

I am also trying “overlayroot” on Xavier but still can’t work.

After long searching and testing I finally found a way to make overlayroot work on my TX2 device!
It starts with the flashing of the device itself, if you add the option -S xGiB, you can actually shape the size of your root partition in favor of the user data partition (called UDA) so in my case since I’m using a spacely board this becomes:

sudo ./flash.sh -S 4GiB spacely-base mmcblk0p1

so with this your root partition will only be 4 GB any more while your last partition (nr 31) will have around 28 GB, you can check this with the command

sudo gdisk -l /dev/mmcblk0

So first of all you need to install overlayroot itself:

sudo apt install overlayroot

next you can execute the following script:

mkfs.ext4 /dev/mmcblk0p31
sleep 5
update-initramfs -c -k $(uname -r)
sleep 5
printf "TIMEOUT 30\n\
DEFAULT primary\n\
\n\
MENU TITLE p2771-0000 eMMC boot options\n\
\n\
LABEL primary\n\
      MENU LABEL primary kernel\n\
      LINUX /boot/Image\n\
      INITRD /boot/initrd.img-4.9.140\n\
      APPEND \${cbootargs} root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4\n" | tee extlinux.conf
mv extlinux.conf /boot/extlinux
printf "overlayroot_cfgdisk=\"disabled\"\n\
overlayroot=\"device:dev=/dev/mmcblk0p31,recurse=0\"\n" | tee overlayroot.local.conf
mv overlayroot.local.conf /etc
sleep 1
echo "rebooting..."
reboot

Note the line where the initrd.img-4.9.140 is, this might be different for someone else I guess you could also put there img-$(uname -r) to be a bit more generic.

enjoy!

1 Like

Which version of l4t are you using?
R28.2 no longer uses initramfs, which would seem to conflict with your script.

Sorry for not mentioning that, I’m using the latest release 32.1 with kernel 4.9.140

Also I would like to mention, I did change the kernel so that overlayfs was included not as a module but inside the kernel itself (so use ‘Y’ in stead of ‘M’ in the kernel menu config)

Hi @gert.willems I tried above script with jetpack version 4.4.1 kernel 4.9.140 on tx2, and I can confirm overlay works fine (thumbs up for that :)). But I also stumble upon other problem that after booting, the device no longer detects usb peripherals , due to which neither mouse nor keyboard is working, and I can’t pass through the login screen. Fortunately I had the wlan ip saved, So i am able to login using ssh from other device and verified that system is working fine and overlayroot also works in ro-mode. Did you see any such problem regarding usb port after executing above script and rebooting the device?

On further experimentation I found reverting back below line in extlinux.conf to original make usb peripheral works. But overlay stops working.

INITRD /boot/initrd

While changing it to

INITRD /boot/initrd.img-4.9.140-tegra

makes overlay works but usb peripheral stops working. My hunch is that in later case initrd is not properly loading the drivers on bootup. Can some one points out the difference between the two files(/boot/initrd and /boot/initrd.img-4.9.140-tegra)?

Just a guess, but perhaps the custom initrd needs to read some device tree settings, and your version does not set up device tree. This is especially true if your Jetson does not use the dev kit carrier board.

I am using Dev kit as carrier board only. The logs in the dmesg shows below errors while bootup. It does look like it is trying to load the usb driver but there’s some error in doing so the same.

1.486423] tegra-xusb 3530000.xhci: USB2 port 0 has OTG_CAP
[    1.488090] tegra-xusb 3530000.xhci: extcon 0: ffffffc1eb311000 id
[    1.488173] tegra-xusb 3530000.xhci: Direct firmware load for tegra18x_xusb_firmware failed with error -2
[    1.488177] tegra-xusb 3530000.xhci: Falling back to user helper
[    1.488614] usbcore: registered new interface driver uas
[    1.488657] usbcore: registered new interface driver usb-storage
[    1.488725] usbcore: registered new interface driver usbserial
[    1.495712] usbcore: registered new interface driver xpad
[    1.676808] usbcore: registered new interface driver usbhid
[    1.676809] usbhid: USB HID core driver
[    1.695795] usbcore: registered new interface driver snd-usb-audio
[    1.927954] vdd-usb0-5v: disabling
[    1.927956] vdd-usb1-5v: disabling
[    1.927975] vdd-usb2-5v: disabling
[    2.242873] tegra-xusb 3530000.xhci: cannot find firmware....retry after 1 second
[    3.269379] tegra-xusb 3530000.xhci: Direct firmware load for tegra18x_xusb_firmware failed with error -2
[    3.269382] tegra-xusb 3530000.xhci: Falling back to user helper
[    3.275323] tegra-xusb 3530000.xhci: cannot find firmware....retry after 1 second
[    4.293365] tegra-xusb 3530000.xhci: Direct firmware load for tegra18x_xusb_firmware failed with error -2
[    4.293369] tegra-xusb 3530000.xhci: Falling back to user helper
[    4.299118] tegra-xusb 3530000.xhci: cannot find firmware....retry after 1 second
[    5.317374] tegra-xusb 3530000.xhci: Direct firmware load for tegra18x_xusb_firmware failed with error -2
[    5.317377] tegra-xusb 3530000.xhci: Falling back to user helper
[    5.323099] tegra-xusb 3530000.xhci: cannot find firmware....retry after 1 second
[    6.341340] tegra-xusb 3530000.xhci: Direct firmware load for tegra18x_xusb_firmware failed with error -2
[    6.341342] tegra-xusb 3530000.xhci: Falling back to user helper
[    6.346933] tegra-xusb 3530000.xhci: cannot find firmware....retry after 1 second
[    7.365304] tegra-xusb 3530000.xhci: Leaving it upto user to load firmware!
[    7.372350] tegra-xusb 3530000.xhci: Direct firmware load for tegra18x_xusb_firmware failed with error -2
[    7.372353] tegra-xusb 3530000.xhci: Falling back to user helper
1 Like

@linuxdev, with your hint I deep downed into the two files namely initrd and initrd.img-4.9.140-tegra. Used zcat tool and extracted the content of each,

cp /boot/initrd /data/ #made a local copy 
cd /data/
zcat initrd | cpio - idmv

Same commands for other image file, I compared them directory by directory and found tegra18x_xusb_firmware and tegra19x_xusb_firmware file missing in lib/firmware/ in the case of initrd.img-4.9.140-tegra extracted output. I simply copied both files from first image extracted output to later one and re-compressed the image using following commands

find . | cpio -o -H newc | gzip -9 > ../initrd.img-4.9.140-tegra-overlay.gz
mv initrd.img-4.9.140-tegra-overlay.gz initrd.img-4.9.140-tegra-overlay

Now usb peripherals are working fine and overlayfs also working as expected.

cheers :)

2 Likes