Skip to contentSkip to conversation

read-only partitions: does the policy apply to all metadata ?

DISCUSSION [email protected] 5 participants 7 messages Mar 10, 2009 – Mar 15, 2009

lore
Share & tools
lore
#0 lore raw

Hello,

When a partition is mounted as read-only, does the kernel really prevent ANY byte to be written to it, including any metadata ?

(i am thinking here about file attributes -- last access time, as well as meta information about filesystem/blocks description etc ...).

And is the policy implemented in every filesystem type driver or at some abstraction level (as if the write() and like system calls were designed to return an error).

Unfortunately, on common (all?) hard drives, there seems to be no switch to set the device microcode in read-only mode.

By the way, this makes me also thing about memory cards with locks: is it a real protection or it is just a setting which tells the kernel that it *SHOULD* mount the device read-only ?

Please include my private address if you answer; i posted to the list because in some other forums we did not come up
with a clear answer, so this is my last chance to get a definite done. However i didn't subscribe to the list as i have realized i am not able to help unfortunately:
operating systems are the most complex thing ever design by humans !

Best regards
Phil

#1 lore raw
Quoted 3 lines · On Tue, 10 Mar 2009 17:26:44 BST, [email protected] said:

When a partition is mounted as read-only, does the kernel really prevent ANY byte to be written to it, including any metadata ?

It's very hard to come up with a workable way to do a true read-only mount of a journaled filesystem such as ext3 - what do you do if there's anything in the journal that needs to be replayed?

Your best bet is to not worry about the filesystem, and look at flagging the underlying block device as read-only.

#2 lore raw
Quoted 8 lines · On Tue, 10 Mar 2009 13:22:39 -0400 [email protected] wrote:
Quoted 3 lines · On Tue, 10 Mar 2009 17:26:44 BST, [email protected] said:

When a partition is mounted as read-only, does the kernel really prevent ANY byte to be written to it, including any metadata ?

It's very hard to come up with a workable way to do a true read-only mount of a journaled filesystem such as ext3 - what do you do if there's anything in the journal that needs to be replayed?

Replay it to a snapshot backed by the r/o fs ...

#3 lore raw
Quoted 1 line · Alan Cox

Replay it to a snapshot backed by the r/o fs ...

Assuming you've got an LVM in place, and someplace to put the snapshot, and all that. It's certainly well outside what you'd *expect* to happen if you do a 'mount -o ro' of an ext3 file system. ;)

#4 lore raw
In reply to Alan Cox
Quoted 8 lines · Alan Cox
Quoted 5 lines · On Tue, 10 Mar 2009 13:22:39 -0400 [email protected] wrote:
Quoted 3 lines · On Tue, 10 Mar 2009 17:26:44 BST, [email protected] said:

When a partition is mounted as read-only, does the kernel really prevent ANY byte to be written to it, including any metadata ?

Quoted 5 lines
Quoted 3 lines

It's very hard to come up with a workable way to do a true read-only mount of a journaled filesystem such as ext3 - what do you do if there's anything in the journal that needs to be replayed?

Replay it to a snapshot backed by the r/o fs ...

Or you can use 'ro, noload' to just ignore the journal. See the docs.

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw
In reply to [email protected]
Quoted 9 lines · [email protected] wrote:

Hello,

When a partition is mounted as read-only, does the kernel really prevent ANY byte to be written to it, including any metadata ?

(i am thinking here about file attributes -- last access time, as well as meta information about filesystem/blocks description etc ...).

As far as I know any of the visible attributes (last access, etc.) cannot be modified. However, mounting read-only may still write to the filesystem if the block device is writable, for example with ext3/ext4 if the file system was not unmounted cleanly last time and the journal needs to be replayed.

Quoted 5 lines

And is the policy implemented in every filesystem type driver or at some abstraction level (as if the write() and like system calls were designed to return an error).

Quoted 8 lines

Unfortunately, on common (all?) hard drives, there seems to be no switch to set the device microcode in read-only mode.

By the way, this makes me also thing about memory cards with locks: is it a real protection or it is just a setting which tells the kernel that it *SHOULD* mount the device read-only ?

Normally the card reader indicates to the OS that the device is read-only, and then the kernel will mount it only read-only. However, note that some crappy SD card readers don't implement the write protect switch detection and will allow writing to a card marked read-only.

Quoted 10 lines

Please include my private address if you answer; i posted to the list because in some other forums we did not come up
with a clear answer, so this is my last chance to get a definite done. However i didn't subscribe to the list as i have realized i am not able to help unfortunately:
operating systems are the most complex thing ever design by humans !

Best regards
Phil