Saturday, January 31, 2015

Linux -- running fsck on readonly filesystem -- especially about readonly root filesystem

Running e2fsck , fsck on readonly filesystems makes sense.. It makes sense, because you can be sure that the filesystem is consisten while fsck is reading it, and also while fsck is correcting it..
Moreover; I did these kind of operations couple of times recently and did not encounter any problems..

On the other hand; it is not recommended..
Lets have a quick look at the fsck man page:
Here is says;
e2fsck(8) - Linux man page
Note that in general it is not safe to run e2fsck on mounted filesystems.

So it is not safe according to the application owner.
The question is why? 
Altough, I could not find a certain answer for this, I think that it may be related with the kernel and filesystem.. I mean the filesystem remains consistent in itself.. That 's true. On the other hand; the whole picture(kernel<->fs) will not be consistent..  What I try to say is ; when we correct a readonly filesystem using e2fsck, we actually make write operations on it.. This may lead problems when we mount it read/write again. The reason is that kernel may find some unexpected data in the fs.. Unexpected data may be a result of writing in to the fs while it was readonly..  
The concern is sspecially for root filesystem...  Such a problematic scenario in a root fs may trigger a hang or crash..
So what we need to do? What should be our action plan if we need to run e2fsck on filesystems?
I think, you can run e2fsck , while the system is online, by taking the risk, suppposing you cant reboot and also able to take the risk.... root filesystem, on the other hand; should be an exception. 
Altough, we can technically run e2fsck on root filesystem without reboot; it is not safe. 
So in case of root fs; we should reboot and make an fsck during the boot phase.
In such a situation; when you reboot ; recent versions of Oracle / Redhat Linux will direct you to make fsck while booting; anyways.

No comments :

Post a Comment