This will still write to /dev/foo if there is a journal:

mount -oro /dev/foo /mnt/disk

How can I treat /dev/foo as read-only?

  • The question may make sense to you, but you should explain the issue for others (including google). Such as "The ext4 journal is automatically replayed on mount, how can I prevent this, and all other writes to the underlying device". The title is also misleading, as the filesystem is read only. – Patrick Jan 15 '17 at 23:30
mount -oro,noload /dev/foo /mnt/disk
  • 4
    You should explain the answer, and what the option does. – Patrick Jan 15 '17 at 23:30

If you make the device readonly first:

blockdev --setro /dev/foo

then the filesystem will be unable to write to it, so you don't need to know any special type-dependent filesystem options.

  • blockdev is only able to block rw access from userspace. There still can be rw access to a device even if set ro using blockdev. See also lkml.org/lkml/2007/2/6/1 and other references online. – Gen.Stack Apr 15 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.