Jetson Nanoのrootfsをread onlyにしてoverlayfs化する

2 min read 4


Jetson Nanoのrootfsをread onlyにしてoverlayfs化することで、shutdownせずに電源OFFしてもファイルシステムが壊れないようにする。Jetson Nanoを装置に組み込んで使うときにはぜひ実施しておきたい。

Jetson Nano用の公式SDカードイメージはUbuntuなので、apt install overlayrootして/etc/overlayroot.confを設定することで実現できると思ったのだが、Jetson Nanoの場合は追加設定が必要だったのでそのまとめ。





$ sudo -i
# apt update
# apt upgrade
# apt autoremove


# apt install overlayroot


--- a/etc/overlayroot.conf    2018-09-20 22:29:41.000000000 +0900
+++ b/etc/overlayroot.conf    2021-01-19 14:17:16.061256571 +0900
@@ -167,4 +167,4 @@
 #    The result is stored in r-------- /dev/.initramfs/overlayroot.XXXXXXX,
 #    which is a tmpfs in memory.



--- a/boot/extlinux/extlinux.conf        2020-10-20 01:10:02.974730022 +0900
+++ b/boot/extlinux/extlinux.conf        2021-01-19 14:20:38.040217352 +0900
@@ -6,8 +6,8 @@
 LABEL primary
       MENU LABEL primary kernel
       LINUX /boot/Image
-      INITRD /boot/initrd
-      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0
+      INITRD /boot/initrd.img
+      APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 ro rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0

 # When testing a custom kernel, it is recommended that you create a backup of
 # the original kernel and add a new entry to this file so that the device can


# reboot



$ mount
/dev/mmcblk0p1 on / type ext4 (rw,relatime,data=ordered)


$ mount
/dev/mmcblk0p1 on /media/root-ro type ext4 (ro,relatime,data=ordered)
overlayroot on / type overlay (rw,relatime,lowerdir=/media/root-ro,upperdir=/media/root-rw/overlay,workdir=/media/root-rw/overlay-workdir/_)



$ sudo overlayroot-chroot
# mount
/dev/mmcblk0p1 on / type ext4 (rw,relatime,data=ordered)

chroot環境からexitすると元のreadonly + overlayfsに戻る。

# exit



I'm wondering on what versions of JetPack, DeepStream, Tegra you did your work, since on the latest (4.5, 5.1, R32.5) this is not working anymore and the box goes into an endless reboot loop after the "reboot" statement. Let me know please. Your post is of Jan this year, so it can't be such an old version.

Thanks for the follow up. But I think it is all just bullshit. Remember: The aim of createing an overlayfs is to have a read only filesystem after boot. I did what you suggested and it seems to work, but in the end it doesn't boot into a read-only fs.

My steps:

ubuntu@jetson:~$ sudo sed -i "s/MODULES=most/MODULES=dep/" /etc/initramfs-tools/initramfs.conf
ubuntu@jetson:~$ sudo update-initramfs -u -k $(uname -r)
update-initramfs: Generating /boot/initrd.img-4.9.253-tegra
Warning: couldn't identify filesystem type for fsck hook, ignoring.
I: The initramfs will attempt to resume from /dev/zram3
I: (UUID=5696baa7-0354-4886-b8d1-8bbb3a2900b7)
I: Set the RESUME variable to override this.
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/aarch64-linux-gnu_EGL.conf: No such file or directory
/sbin/ldconfig.real: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf.d/aarch64-linux-gnu_GL.conf: No such file or directory

After having this I changed /boot/extlinux/extlinux.conf to have this line:

INITRD /boot/initrd.img-4.9.253-tegra

I touched a file touch test and rebooted sudo reboot, hoping to not see this file again after the reboot.

But it was there...