iamwill
Posts: 6
Joined: Tue Jan 19, 2016 3:00 am

Read-Only File system...

Sun Feb 28, 2016 6:05 am

I am running Arch Linux on my Pi right now. I have 3 partitions on the SD card, 1=boot, 2=filesystem, 3=storage. I'd like to make 1 and 2 read-only... But the most important part is that; i'd like to be able to mount partition 3 and write to it while the rest of the filesystem is read only. Is this possible? Thanks for the help.

Will

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Read-Only File system...

Sun Feb 28, 2016 9:05 am

iamwill wrote:I am running Arch Linux on my Pi right now. I have 3 partitions on the SD card, 1=boot, 2=filesystem, 3=storage. I'd like to make 1 and 2 read-only... But the most important part is that; i'd like to be able to mount partition 3 and write to it while the rest of the filesystem is read only. Is this possible? Thanks for the help.

Will
you want to add a 'ro' option in the /etc/fstab

Code: Select all

/dev/mmcblk1p1  /test               ext4    defaults,noatime,ro  0       1
see https://wiki.debian.org/fstab

fsr
Posts: 88
Joined: Wed Jan 13, 2016 2:29 am

Re: Read-Only File system...

Sun Feb 28, 2016 9:11 am

FYI the only place linux writes is
/home/<user>
/tmp
/var

If you really want to make your filesystem readonly you should have a dedicated RW partition for /var that is RW.
a way to deal with this is to create /var in a ramdisk at boot and mount it over the top of /var on the root filesystem.

what are you trying to protect the filesystem from by making it read only?

iamwill
Posts: 6
Joined: Tue Jan 19, 2016 3:00 am

Re: Read-Only File system...

Sun Feb 28, 2016 5:17 pm

I am trying to protect the filesystem from unexpected power hits. The project I am using the Pi for will be a headless file transfer device and once physically mounted in it's case, I wont have access to shut it down. I have an automated script and udev rules to automatically pull files from a USB device when plugged in.. it will copy to the write-able partition and then transfer files to a server once it has verified that the files are good to go. The pi will serve no other purpose so I don't need the filesystem active.. readonly is perfect for it's purpose, but I also do want it to corrupt if it takes an unexpected power loss.

stderr
Posts: 2178
Joined: Sat Dec 01, 2012 11:29 pm

Re: Read-Only File system...

Sun Feb 28, 2016 5:27 pm

iamwill wrote: in it's case,
for it's purpose,
Please save my sanity:
in its case
for its purpose
readonly is perfect
This is completely true, many situations would be improved by having the sdcard as protected from writing as possible. Tiny Core, available for the pi, takes this to the extreme and makes it rather a pain to figure out how to change anything. I suppose once one gets that figured out, one can bask in the glory of a read only system that is running entirely in memory.

User avatar
jojopi
Posts: 3268
Joined: Tue Oct 11, 2011 8:38 pm

Re: Read-Only File system...

Sun Feb 28, 2016 9:03 pm

iamwill wrote:I am trying to protect the filesystem from unexpected power hits.
You will probably need to put your writeable filesystem on a separate device.

The problem is not that Linux corrupts data it is not writing; the problem is that the SD card internally moves data around for wear levelling and can lose track of it in the event of unexpected power loss.

The card's wear levelling almost certainly operates over the whole device, with no regard to software partitioning. If any partition is being written during power off, data anywhere on the device could potentially be corrupted.

Return to “Advanced users”