Readonly root problem

1,536 views
Skip to first unread message

Christian Gurk

unread,
Aug 1, 2015, 10:28:20 AM8/1/15
to BeagleBoard
Hi together,
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.897327]
[    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] [<c0019998>] (unwind_backtrace) from [<c0014b38>] (show_stack+0x20/0x24)
[    6.926806] [<c0014b38>] (show_stack) from [<c096f0dc>] (dump_stack+0x8c/0xcc)
[    6.934075] [<c096f0dc>] (dump_stack) from [<c096c900>] (panic+0xac/0x230)
[    6.941005] [<c096c900>] (panic) from [<c0047718>] (complete_and_exit+0x0/0x2c)
[    6.948360] [<c0047718>] (complete_and_exit) from [<c0047764>] (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
[    6.963348]
[    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
boot
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!
Christian


Robert Nelson

unread,
Aug 1, 2015, 10:35:30 AM8/1/15
to Beagle Board
So 'ro' is eiaser to do when you cut /var/ out of the main partiion...
grab a 4gb microsd (or larger) and do:

wget http://rcn-ee.com/rootfs/bb.org/testing/2015-07-26/console/debian-8.1-console-armhf-2015-07-26.tar.xz

tar xf debian-8.1-console-armhf-2015-07-26.tar.xz
cd debian-8.1-console-armhf-2015-07-26/
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:

/etc/fstab

you'll notice a couple comments about "ro" switch from the "rw" line
to "ro" and reboot..

Regards,

--
Robert Nelson
https://rcn-ee.com/

Christian Gurk

unread,
Aug 2, 2015, 4:18:49 AM8/2/15
to BeagleBoard
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!
Thanks again

William Hermans

unread,
Aug 2, 2015, 1:38:09 PM8/2/15
to beagl...@googlegroups.com
google "linux how to remount read / write" . . . such as:

http://askubuntu.com/questions/175739/how-do-i-remount-a-filesystem-as-read-write




--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Hermans

unread,
Aug 2, 2015, 2:10:52 PM8/2/15
to beagl...@googlegroups.com
debian@beaglebone:~$ sudo nano /etc/fstab

Add: ,ro after noatime

# /etc/fstab: static file system information.
#
# Auto generated by RootStock-NG: setup_sdcard.sh
#
/dev/mmcblk0p1  /  ext4  noatime,ro,errors=remount-ro  0  1
debugfs  /sys/kernel/debug  debugfs  defaults  0  0

Save and exit nano.

restart board:
debian@beaglebone:~$ sudo shutdown now -r

After board comes back up:
debian@beaglebone:~$ mount | grep /dev/mmcblk0p1
/dev/mmcblk0p1 on / type ext4 (ro,noatime,errors=remount-ro,data=ordered)

Attempt to make a zero byte file:
debian@beaglebone:~$ touch ~/test
touch: cannot touch `/home/debian/test': Read-only file system

remount read / write:
debian@beaglebone:~$ sudo mount -o remount,rw /dev/mmcblk0p1 /

retest:
debian@beaglebone:~$ touch ~/test
debian@beaglebone:~$ ls .
bin  test

After a reboot the file system should then be read only again. Do note: That if you attempt to remount ro on a rw file system. You will most probably get a "dev busy" message. Using umount on / would be very unwise . . .

Marking a rootfs as read only has to be done via /etc/fstab + a reboot.


Christian Gurk

unread,
Aug 3, 2015, 10:15:57 AM8/3/15
to BeagleBoard
Hi Robert,
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.
Greetings

Robert Nelson

unread,
Aug 3, 2015, 10:31:48 AM8/3/15
to Beagle Board
On Mon, Aug 3, 2015 at 9:15 AM, Christian Gurk
<christ...@googlemail.com> wrote:
> Hi Robert,
> 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.

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..

Robert Nelson

unread,
Aug 3, 2015, 10:34:16 AM8/3/15
to Beagle Board
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
basis.

Only thing i've had to replace on it.. the power cord, as that rusted
out... (outside of the sealed box)

William Hermans

unread,
Aug 3, 2015, 12:06:07 PM8/3/15
to beagl...@googlegroups.com
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.

Robert Nelson

unread,
Aug 3, 2015, 12:11:07 PM8/3/15
to Beagle Board
On Mon, Aug 3, 2015 at 11:05 AM, William Hermans <yyr...@gmail.com> wrote:
>> Only thing i've had to replace on it.. the power cord, as that rusted
>> out... (outside of the sealed box)

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..

Robert Nelson

unread,
Aug 3, 2015, 12:16:03 PM8/3/15
to Beagle Board
On Mon, Aug 3, 2015 at 11:10 AM, Robert Nelson <robert...@gmail.com> wrote:
> On Mon, Aug 3, 2015 at 11:05 AM, William Hermans <yyr...@gmail.com> wrote:
>>> Only thing i've had to replace on it.. the power cord, as that rusted
>>> out... (outside of the sealed box)
>
> 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..

http://connectivity.digikey.com/WeatherPic/outside.jpg

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..

William Hermans

unread,
Aug 3, 2015, 12:25:10 PM8/3/15
to beagl...@googlegroups.com
hehehe

Reply all
Reply to author
Forward
0 new messages