Forums » Software Development »
MitySOM-5CSX read-only Linux
Added by Mathew Jones almost 6 years ago
Hi,
We're running everything from SD card, all based on the original image for the dev kit with some kernel mods (Linux 3.16.0 kernel).
This works well for us except that we have experienced 3 failures (out of about 25) during development when our system was being power-cycled fairly frequently (but not ridiculously quick as it takes a 30-60secs to reboot each time).
As I understand it the SD card partitions are:- mmcblk0p3: Linux root filesystem
- mmcblk0p2: Spare Linux filesystem
- mmcblk0p1: Preloader, U-Boot & U-Boot environment variables
We don't know whether the failures were genuine SD card hardware failures or Linux filesystem corruption due to the power-offs.
Both the Linux partitions are ext3, which I thought had some resilience to uncontrolled power-offs due to it being a journalled filesystem.
So I've been looking at making the Linux root filesystem read-only but have so far struggled to install and use 'overlayroot' as I think it depends on overlay/overlayfs module and other libraries. I also couldn't see any options in the kernel 3.16.0 menu config to add overlay/overlayfs.
Do you know if a read-only root filesystem is possible for the 3.16.0 kernel build on the MitySOM-5CSX?
Thanks.
Replies (2)
RE: MitySOM-5CSX read-only Linux - Added by Mike Fiorenza almost 6 years ago
Hi Mathew,
What you're describing sounds like filesystem corruption. If you have a read/write filesystem that you power-cycle over and over they eventually get corrupt.
This is why using a read-only filesystem is preferred.
I'm not familiar with overlayroot, but I can provide steps to what I normally do to make the filesystem read-only.
Using the original image for the dev-kit perform the following steps:
Change u-boot to mount the filesystem read-only¶
- Boot the unit with a serial cable connected and break into u-boot by pressing any key when prompted with:
Hit any key to stop autoboot
- When prompted in u-boot, change the mmcsetbootargs parameter to mount filesystem as read-only
MitySOM-5CSx # editenv mmcsetbootargs edit: setenv bootargs console=ttyS0,115200 root=${mmcroot} rw rootwait ---- CHANGE TO ---- edit: setenv bootargs console=ttyS0,115200 root=${mmcroot} ro rootwait
- Save the changes in u-boot and reset to boot into Linux
MitySOM-5CSx # saveenv MitySOM-5CSx # reset
At this point, u-boot will mount the filesystem read-only but Linux will then remount it as read-write after booting up
Change Linux to mount the filesystem read-only¶
- Edit the fstab to mount the filesystem read-only
root@mitysom-5cse-h4-3ya:~# vi /etc/fstab
- Change the following line from
rootfs / auto defaults 1 1
torootfs / auto defaults,ro 1 1
- Change the init.d read-only flag to indicate read-only
root@mitysom-5cse-h4-3ya:~# vi /etc/default/rcS
- Change the following line at the bottom from
ROOTFS_READ_ONLY=no
toROOTFS_READ_ONLY=yes
At this point, the filesystem is now read-only. This may be all you need for the custom SD card image you're creating.
You'll notice a init.d service or two will complain that they can't create/remove a file during boot-up since the filesystem is now read-only, but I assume they don't apply to your use-case.
You can either choose to ignore it, or remove the service from init.d so it doesn't run and complain.
Lastly, now that the filesystem is read-only if you'd like to make changes to the SD card you can run the following:
root@mitysom-5cse-h4-3ya:~# mount -o remount,rw /dev/root /
Let me know if you have any further questions or my example does not meet your needs.
- Mike
RE: MitySOM-5CSX read-only Linux - Added by Mathew Jones almost 6 years ago
Thanks a lot Mike.
That does seem to setup the filesystem as read-only, and is quite a simple solution.