Jetson nano overlay read only directories

After searching everywhere for a solution to prevent sd card corruption on an event of power loss. I even searched a lot here and the solutions I found did not work or did not work for the latest jetpack version (/boot/inird and GitHub - lehni/root-ro: Read-only root filesystem for Raspbian Stretch and Jetson Nano (using OverlayFS))

I finally found what I am using right now for my /var folder. So I’m sharing here in case someone is facing the same struggle in hopes it might be helpful. Since it is also stated that jetson-nano developer is not for production.

The code bellow must run once your board is ready for ‘production’ (prohibited word). Mine is a Network Video Recorder (NVR) system using motion project.

This code can be used to ‘protect’ any directory on your system. Directory you know has lots of I/O.

# create folders needed by overlay filesystem on /dev/shm (RAM)
mkdir -p /dev/shm/var_upper /dev/shm/var_workdir /dev/shm/var_overlay
mkdir -p /var_
# since /var will be 'hidden' by overlay mouting 'over' it
# we need it 'visible' somewhere to be usable as lowerdir 
# mount --bind does that to /var_
mount --bind /var /var_
sudo mount -t overlay overlay -o lowerdir=/var_,upperdir=/dev/shm/var_upper,workdir=/dev/shm/var_workdir /var

Some explanation

Overlay mounts a union filesystem (or directory tree) where upper directory is protected.
This is an example for /var folder making it read only. Rw is done only on RAM (/dev/shm) hence logs etc. are lost on reboot.
This code is safe for reboot since unbind will be done automatically and everything will got back to its default.
Can be replicated to any other folder that needs read-only ‘protection’.

1 Like

Great! Thanks for your sharing to the community!

Just a final update I am using a systemd unit service to keep read only up after reboots like bellow

With as follows:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.