e2fsck exit codes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I'm trying to figure out a way to tell fsck to inform me and abort if
it suspects disk corruption, but continue otherwise. I thought I knew
how to do this, but I don't.

I did the following experiment: I created a new file system using
mkfs.ext4, mounted it, ran a simple workload on it, and hard-rebooted
the machine during the middle of the workload. After rebooting the
machine, I ran "fsck.ext4 -fy" on the partition. Fsck complains about
wrong inode counts and block counts, and exits with code 1.

Is this the expected behavior? I retried the experiment on a couple of
machines, so I know its not an actual corrupted-drive issue. The
following is an example output of fsck:

root@lappy:/home/madthanu# fsck.ext4 -f /dev/sda8
e2fsck 1.42.12 (29-Aug-2014)
/dev/sda8: recovering journal
Clearing orphaned inode 6063 (uid=0, gid=0, mode=0100664, size=2377)
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 (2710767, counted=2681703).
Fix<y>? no
Free inodes count wrong (698998, counted=684135).
Fix<y>? no
/dev/sda8: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda8: 10/699008 files (80.0% non-contiguous), 83473/2794240 blocks

root@lappy:/home/madthanu# echo $?
1

root@lappy:/home/madthanu# fsck.ext4 -fy /dev/sda8
e2fsck 1.42.12 (29-Aug-2014)
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 (2710767, counted=2681703).
Fix? yes
Free inodes count wrong (698998, counted=684135).
Fix? yes
/dev/sda8: ***** FILE SYSTEM WAS MODIFIED *****
/dev/sda8: 14873/699008 files (0.1% non-contiguous), 112537/2794240 blocks

root@lappy:/home/madthanu# echo $?
1

Is there a correct way to do that? "fsck.ext4 -p" does continue
without complaining much, but as I understand it, it might continue
even if there was disk corruption (so long as fsck has enough
confidence that it restored the correct version of corrupted metadata,
it'll continue).

Thanks,
Thanu

---
(Thanumalayan Sankaranarayana Pillai)



[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux