1

I recently have a partition corrupted and I can't mount it. It is a jfs filesystem. I did a fsck.jfs and fsck.jfs -ftrying to fix the partition but it failed. At the end I tried to mount it with read-only and I successfully mounted it and able to copy the data out.

My question is, why does it work when we mount it with read-only ? What is so special in the mounting operation when it is only mounting read-only ? I am curious to know the detail technical part of how the kernel works that makes the read-only mounting works but no the read-write mounting. Thanks.

2
  • Did you get any error message when trying to mount rw? (Have a look in the output of dmesg.)
    – michas
    Jan 8, 2017 at 17:48
  • Most likely the filesystem wants to clean its journal, or edit some filesystem housekeeping information, or something like that when you mount it read-write and it's failing to do that. I would not be surprised if a corrupted filesystem behaved like that.
    – Celada
    Jan 8, 2017 at 21:20

1 Answer 1

1

Read-only means that the system will not write data to the partition, but you can read it, so you just lose the write permissions.

Why read-only?

The system is corrupt, so one should not trust on many disk tables. What it is marked as non-used disk space, could really contain some important file, so better not to write on "empty" space. Also directory content could contain data that you can restore with additional tools.

For these and similar reasons, it is better to have the system read-only, so that you can try to restore most of the original content, before to loose content overwriting some piece of disk.

3
  • hi appreciated the answer! but i actually not asking the reason of mounting read-only in a corrupted fs, i am actually asking reason mounting read-only success in a corrupted fs while mounting read-write failed. Why the kernel allowing read-only mount and rejecting read-write mount ? Read-write mounting needs what extra from the fs that cause it fail ? is there some sort of verifying on the fs metadata ? just curious on the detail technical part.
    – sylye
    Jan 9, 2017 at 14:57
  • 3
    @sylye: but it is in my answer. Read-Write can corrupt further the filesystem, so the kernel (and also mount on boot) will keep the system as safe as possible, not to corrupt/lose data. On very very old kernels, often, instead of read-only, the system simply went into PANIC (which also prevent corruption, but rendered system not so usable). Jan 9, 2017 at 15:09
  • But in general reading is simpler than writing, for these reasons many filesystem can be mounted as read-only safely, but read-write only with extra flag. Jan 9, 2017 at 15:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .