I’m trying to get a BBB running with readonly root filesystem to prevent filesystem corruption by inproper shutdown of the BBB. I’m using up to date so far unmodified Debian image (Linux beaglebone 4.1.1-ti-r2 #1 SMP PREEMPT Wed Jul 8 17:03:29 UTC 2015 armv7l GNU/Linux).
I found a script (https://help.ubuntu.com/community/aufsRootFileSystemOnUsbFlash) which should work. I tried to use the overlayfs-version at the very end of the site.
- copy the script to /etc/initramfs-tools/scripts/init-bottom/root-ro
- make it executable
- update-initramfs -u
I had to adjust some words in the script (line 103 overlayfs->overlay) to get it work.
I have my adjusted script here: http://pastebin.com/hVQ9BCdW
Now, when I boot, I got the following error on serial console:
Begin: Running /scripts/init-bottom … try to move: /root /mnt/root-ro
mount: invalid option –
Failure: root-ro ERROR: failed to move root away from /root to /mnt/root-ro done.
run-init: nuking initramfs contents: Directory not empty
[ 6.897327] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
[ 6.906536] CPU: 0 PID: 1 Comm: run-init Not tainted 4.1.1-ti-r2 #1
[ 6.912833] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 6.919005]  (unwind_backtrace) from  (show_stack+0x20/0x24)
[ 6.926806]  (show_stack) from  (dump_stack+0x8c/0xcc)
[ 6.934075]  (dump_stack) from  (panic+0xac/0x230)
[ 6.941005]  (panic) from  (complete_and_exit+0x0/0x2c)
[ 6.948360]  (complete_and_exit) from  (do_group_exit+0x0/0xd4)
[ 6.956408] drm_kms_helper: panic occurred, switching back to text console
[ 6.963348] —[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000100
[ 8.556964] random: nonblocking pool is initialized
I tried already to change the command in the script to “mount -M …” but also producing an error.
HINT: If you try this out, you could interrupt the boot process at the beginning by pressing a key and enter the u-boot console. There type:
setenv optargs disable-root-ro=true
Then you should boot with the readonly feature disabled.
Could someone help me with this problem? Or are there newer/other solutions to get the filesystem readonly? I must admit, I’m a quite unexperienced linux user. I was wondering, if there aren’t more BBB users using a readonly filesystem to protect there BBB from datacorruption? Especially for long running unattended systems?
Thanks in advance!
So 'ro' is eiaser to do when you cut /var/ out of the main partiion...
grab a 4gb microsd (or larger) and do:
tar xf debian-8.1-console-armhf-2015-07-26.tar.xz
sudo ./setup_sdcard.sh --mmc /dev/sdX --dtb beaglebone --ro
# the "--ro" sets things up for read-only...
On first bootup "/" is rw, let it generate the files on initial bootup
and setup your ethernet, then open:
you'll notice a couple comments about "ro" switch from the "rw" line
to "ro" and reboot..
Thank you Robert for the fast response.
I assume,I should use your instructions on a Linux-PC and not on the BBB? Normally I only work with Windows, but I think I will find a virtual machine to perform your suggested steps.
And after I switched to RO how do I temporarily switch back to rw to update/change the system? Or will I find instructions in the fstab file? Will try it later!
debian@beaglebone:~$ sudo nano /etc/fstab
Add: ,ro after noatime
/etc/fstab: static file system information.
I tried your suggestion and it worked quite ok. Problem is, that the /var folder is mounted on the emmc?! That means, that this part my be affected by file system errors due to inproper shutdowns. Also I need to use graphical console (lxde or lxqt), samba, webserver & vncserver. Therefore I would need a lot of symlinks to get these programs running properly. I tried that already and had little success.
That’s the reason, why I tried to use the uninonfs-approach with overlayfs.
That seems to me the easier solution with respect to the programs I need to run properly.
I will try to contact the author of the init-script I would like to use and ask him for help.
But thanks again for your quick help.
Umm, it's a partition on the same "media".. I don't know why you split
it between microSD/eMMC...
All your doing is setting '/' to ro except /var, so no symlink are required..
btw, you do actually have a linux machine.. Use the eMMC flasher on
one of your bbb's.. then after it'd done, stick in a blank microSD..
now you have a linux machine to run setup_sdcard.sh..
I should mention, this is the exact same setup i use on an beagleboard
xm. It's been outside for 5-6 years now, same microSD card, running
directly off solar power, so it get's it's power yanked on a daily
Only thing i've had to replace on it.. the power cord, as that rusted
out... (outside of the sealed box)
Only thing i’ve had to replace on it… the power cord, as that rusted
out… (outside of the sealed box)
You should probably “replace” some of that dust on the screen with Windex too . . . last time i look at an image from it- it was pretty fuzzy.
One of my co-workers changed the focus on the lens to try and capture
the northern lights last fall.
We've been too lazy to readjust it..
The image sensor might have had to many -40F days.. there are
horizontal lines too..
Since it was a uvc camera and 3.0.x based kernel, i think i had to use
fswebcam and averaged 30 frames to "make" a picture..