LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   fsck commad (https://www.linuxquestions.org/questions/linux-newbie-8/fsck-commad-942735/)

anandg111 05-01-2012 10:13 AM

fsck commad
 
can somebody tell me what exactly fsck command does ?
please dont post the man page for it I had aleady read it.

grim76 05-01-2012 10:30 AM

The man page is pretty straight forward as to what fsck does. Is there another question that you have regarding fsck other than what it does?

MensaWater 05-01-2012 10:31 AM

The intent of fsck to check a filesystem. What exactly it does is dependent on the filesystem type and on the extent if any of damage.

For example for non-journaled filesystems it typically has to read all the blocks and verify everything including superblocks are where they are. For a journaled filesystem on the other hand it typically just tries to verify that what was last logged in the journal has been committed to the data and if not does the commit. However a "full" fsck on a journaled filesystem does pretty much what it did on non-journaled. On Linux by default this full fsck is done on ext3 which is a journaled version of ext2 (which wasn't journaled) after a certain number of mounts or number of days.
VxFS which is Veritas' journaled filesystem is something that I only did a full fsck on when I suspected or saw filesystem issues. Others have suggested that although you could disable the automatic full of ext3 on Linux it isn't a good idea unless you're scheduling a time to do it yourself.

The main thing fsck does is to fix issues found in order to make the filesystem perform better and/or to repair damage so that an unmountable filesystem again becomes mountable.

To get into more detail you'd really need to investigate the filesystem type you're interested in and then find what fsck does for that specific filesystem.

anandg111 05-01-2012 10:32 AM

due to improper shutdown file system of my machine became read only i ran fsck and it worked. So my question is what fsck does and how it converted fs of my system to write mode as well ?

MensaWater 05-01-2012 11:01 AM

fsck didn't convert your filesystem to write mode. It fixed the issue that made your system decided to mount in read only.

That is to say at boot the system tries to mount filesystems but if it finds issues it will mount as read only to prevent further corruption then tell you to run an fsck to fix whatever it issues existed. It doesn't automatically do the fsck because there is a potential the fsck would render the filesystem completely unusable. By mounting read only it gives you a chance to try to save important information before you attempt the fsck.

Again unless you want to study the underlying filesystem structures in detail the best answer is "it tries to fix the filesystem". In most cases it DOES. Some user prefer to interact with fsck answering questions as it goes along but many people just run "fsck -y" as they don't understand the underlying structures and don't want to answer the potentially hundreds of questions it asks.


All times are GMT -5. The time now is 03:33 AM.