overlayfs for Jetson

Hello,

I tried to make root filesystem to read-only uinsg overlayfsroot,
but I could not make it works.

[Procedure]

  1. sudo apt install overlayroot
  2. echo ‘overlayroot=“tmpfs”’ | sudo tee -a /etc/overlayroot.local.conf
  3. sudo update-initramfs -c -k $(uname -r)
  4. reboot

As I check overlayfs for Jetson the following link, but no one can solve.
https://devtalk.nvidia.com/default/topic/1002630/jetson-tx1/tx1-using-overlayroot-for-read-only-filesystem/

Is threre any one who is able to use overlayfs successfully?

Our product is IoT product and
End-user may suddenly pick up power cable from Jetson Nano.
In that case, file system is broken and never boot up in worst case.
So we want to use read-only filesystem for Jetson Nano.

Best regards,

hello bdaddr,

your procedure looks you should create a custom initramfs,
suggest you check Topic 1032951, and also Using the initial RAM disk (initrd) for reference.

BTW,
just for your reference, there’s another discussion thread, linuxquestions.org talking about how to setup a readonly rootfs without an initramfs.
thanks

1 Like

bdaddr, if you succeed with this, could you share the steps required to make OverlayFS work on Jetson Nano?

I have spent a few hours now trying two approaches based on the linked posts and some other topics that I found in the forum, but to no avail so far:


I am tapping in the dark at this point…

I should add some context: First I tired to modify the l4t_initrd.img file inside Linux_for_Tegra/bootloader on the Host OS, and flash it back to the Nano. I wasn’t quite sure which partition I need to flash for this to be updated, after inspecting flash.xml I though EBT is the one:

sudo ./flash.sh -r -k EBT jetson-nano-qspi-sd mmcblk0p1

This worked, and I have successfully flashed other things to the Nano in the past, e.g. an updated BMP logo for startup. But it doesn’t look like my modified l4t-initrd.img is actually loaded.

I then also tried the normal Ubuntu approach, where I modify the initrd directly on the Nano, using update-initramfs -u. But this too didn’t seem to actually do anything.

Just after I wrote the above, I’ve figured it out myself, thanks to some hints in this repo https://github.com/JetsonHacksNano/rootOnUSB! So here it goes:

I found that the scripts from this project here, developed for the Raspberry Pi, works perfectly for the Nano: https://github.com/JasperE84/root-ro

The only thing that’s different is the installation procedure, so don’t run the install.sh script on the Nano:

sudo -i # root shell

# Change a few things in /etc/initramfs-tools so that overlayfs is used on startup to mount a ready-only root
echo overlay >> /etc/initramfs-tools/modules
wget https://raw.githubusercontent.com/JasperE84/root-ro/master/etc/initramfs-tools/hooks/root-ro -O /etc/initramfs-tools/hooks/root-ro
wget https://raw.githubusercontent.com/JasperE84/root-ro/master/etc/initramfs-tools/scripts/init-bottom/root-ro -O /etc/initramfs-tools/scripts/init-bottom/root-ro
chmod +x /etc/initramfs-tools/hooks/root-ro
chmod +x /etc/initramfs-tools/scripts/init-bottom/root-ro

# Update the initrd file
update-initramfs -u

# Now, the file /boot/initrd.img-4.9.140-tegra contains the above modifications.
# There is also the symbolic link in /boot/initrd.img pointing to it, but this doesn't
# actually get loaded on startup. By default /boot/initrd (without extension) is loaded.
# So change /boot/extlinux/extlinux.conf so that it actually gets loaded:
# Search for `INITRD /boot/initrd` and replace it with `INITRD /boot/initrd.img`:
if ! grep -q "INITRD /boot/initrd.img" /boot/extlinux/extlinux.conf; then sed -i "s/INITRD \/boot\/initrd/INITRD \/boot\/initrd.img/" /boot/extlinux/extlinux.conf; fi

# Before rebooting, also add the helper scripts from JasperE84/root-ro:
wget https://raw.githubusercontent.com/JasperE84/root-ro/master/reboot-to-readonly-mode.sh -O /root/reboot-ro
wget https://raw.githubusercontent.com/JasperE84/root-ro/master/reboot-to-writable-mode.sh -O /root/reboot-rw
chmod +x /root/reboot-ro
chmod +x /root/reboot-rw

Now you should be able to run sudo /root/reboot-ro to boot into RO mode, and sudo /root/reboot-rw to boot back into RW mode.

2 Likes

Hi,

The root-ro partition is rw by default on the Jetson, if you want to set it in read-only, you just need to add the following:

sudo sed -i ‘s/root=\/dev\/mmcblk0p1 rw/root=\/dev\/mmcblk0p1 ro/g’ /boot/extlinux/extlinux.conf