Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am not talking about tweaking fstab or about the use of the "mount" program... I was thinking of tune4fs, btrfstune and the like : I'd like to know if you've heard of any filesystem being able to declare itself as "read-only by default" to the host system.

I know the read-only attribute is defined and applied on the OS side, but for instance, BTRFS has a "read-only" attribute for snapshots. I could use that (and I might) but I'm not sure this would work and if a more stable FS could do the same, it'd be better.



I know about chmod a-w, of course. But I am not sure chmoding would help to prevent data loss upon power loss.

share|improve this question
If your filesystems are on LVM LVs, you can make the LV read-only (with lvchange -p r). If the underlying block device is read-only, the filesystem has no choice but to become read-only. – Celada Jan 9 '13 at 16:39
Not bad ! I think I'll try this. My only concern about this is that LVM adds a layer between the hardware and my data. That extra layer might not be that resilient to corruption, but still, the idea is appealing. Thanks. – user183734 Jan 10 '13 at 8:17
The LVM/device-mapper layer is really quite thin. I don't think it has even the potential to mess with the data. It's akin to using a partition (like /dev/sda1) as opposed to the whole block device (like /dev/sda): it's the same disk blocks, just shifted over by an offset equal to the offset of the start of the partition. – Celada Jan 10 '13 at 15:04
up vote 0 down vote accepted

Have you considered making the filesystem a btrfs read-only 'seed device'?

# btrfstune -S 1 /dev/device

I have not tried this myself, but the btrfs wiki has more information about how to do this and use case.

share|improve this answer
Yes, that was included in "read-only BTRFS snapshots" even if this is about the device, not a simple snapshot. But thank you for pointing that out. I'll wait a couple of days to give the opportunity to others to talk about similar capabilities in other (more stable) FS. – user183734 Jan 10 '13 at 8:23

You must log in to answer this question.