fsck: file system check
This is a wiki page. Be bold and improve it!
If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.
It is our intention to make this page the most informative and complete one on the topic of e2fsck and file system check. This article will grow into a full HOWTO. You can help: 1) If anything here is not clear and you need help, do not hesitate to open a new ticket. 2) If you are knowledgeable in this topic and find a mistake or an omission, either edit this wiki page or open a new ticket to alert us. Thank you.
Partitions
To be safe a regular file system check should be regularly performed on every partition of every hard disk that you own.
Before using e2fsck, the partition should be unmounted. This is easy to do with an external drive used for backup, but it requires a special procedure when you want to check the partition where root (/) /usr or /home reside. Thus, we shall consider those scenarios separately.
External device
Internal device (/, /usr, /home)
Interactive
Interactive
# e2fsck -vfFC0 /dev/sdc1 e2fsck 1.41.9 (22-Aug-2009) Pass 1: Checking inodes, blocks, and sizes Error reading block 34308186 (Attempt to read block from filesystem resulted in short read) while getting next inode from scan. Ignore error?
Answering yes will delete the inode, i.e. data will be lost. Answering no will leave the bad block in place and the problem will remain.
Non interactive
The -y
option should not be placed after the -C
option, as it would be understood as being an argument of the latter. Instead, put it in front.
I.e.
Wrong: e2fsck -vfFC0y /dev/sdc1
Right: e2fsck -yvfFC0 /dev/sdc1
Command output
Document here the various messages or errors output by the fsck commands. The goal is to eventually be able to understand the significance of each message and be informed on what the proper course of action should be.
x% non-continguous
E.g.:
/dev/sda1: 79674/642112 files (2.8% non-contiguous), 2316797/2559744 blocks
Is it ok to ignore this?
Free blocks count wrong
# fsck -f /dev/sda2
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
/dev/sda2: recovering journal
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Free blocks count wrong (191550189, counted=192989110).
Fix?
Questions for which we are seeking answers:
- What can cause the above error?
- What to answer to the question "Fix?" What are the implications of answering yes or no?
External resources
http://en.wikipedia.org/wiki/E2fsprogs
http://en.wikipedia.org/wiki/Fsck
http://adminschoice.com/repairing-unix-file-system-fsck
http://lwn.net/Articles/248180/
e2fsck -vfFC0
complete check with maximum output.
Issues related to this page:
Project | Summary | Status | Priority | Category | Last updated | Assigned to |
---|---|---|---|---|---|---|
Linux software | Best use of e2fsck | active | critical | task | 14 years 27 weeks | |
Linux software | e2fsck: non-desctructive, informative mode only? | active | normal | feature request | 12 years 22 weeks | |
Linux software | Running e2fsck twice gives the same / differen… | active | normal | support request | 14 years 23 weeks | |
Linux software | 0 bad blocks ??? | active | normal | support request | 14 years 23 weeks | |
Linux hardware | fsck: different scenarios for use | active | normal | task | 13 years 1 week | |
Linux hardware | What is a bad block? | active | normal | task | 12 years 20 weeks |