1

Running fsck on a booted machine yields errors on the root file system. In an attempt to fix this, I booted from a LiveCD - but fsck on the LiveCD instance doesn't find any errors at all. I also tried running the same binary which a booted system would - with the same results of 0 errors.

What's going on here? How to fix the errors reported? (see below)

The machine is a headless Ubuntu 14.04, and the LiveCD is from Ubuntu 14.04 desktop edition.

When I'm running:

fsck -v -n /dev/mapper/lvm-root -f

The response is:

fsck from util-linux 2.20.1
e2fsck 1.42.9 (4-Feb-2014)
Warning!  /dev/mapper/lvm-root is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
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
Block bitmap differences:  -(24598720--24598781) +(42616517--42616542) -(47432723--47432748) +(49925184--49925211) +(49925312--49925373)
Fix? no

Free blocks count wrong for group #750 (22700, counted=22638).
Fix? no

Free blocks count wrong for group #1300 (13150, counted=13176).
Fix? no

Free blocks count wrong for group #1447 (24124, counted=24098).
Fix? no

Free blocks count wrong for group #1523 (32016, counted=32106).
Fix? no

Free blocks count wrong (30301182, counted=30319341).
Fix? no

Inode bitmap differences:  -11927698 +11927700
Fix? no

Free inodes count wrong (15762199, counted=15762204).
Fix? no


/dev/mapper/lvm-root: ********** WARNING: Filesystem still has errors **********


      130281 inodes used (0.82%, out of 15892480)
        1113 non-contiguous files (0.9%)
         112 non-contiguous directories (0.1%)
             # of inodes with ind/dind/tind blocks: 0/0/0
             Extent depth histogram: 121424/640
    33268738 blocks used (52.33%, out of 63569920)
           0 bad blocks
           3 large files

      101907 regular files
       19700 directories
           2 character device files
           0 block device files
           2 fifos
          22 links
        8624 symbolic links (8166 fast symbolic links)
          32 sockets
------------
      130289 files

As an attempt to fix this, I booted from from Ubuntu 14.04 LiveCD and ran the same command:

root@ubuntu:~# fsck -n -v /dev/mapper/lvm-root -f
fsck from util-linux 2.20.1
e2fsck 1.42.9 (4-Feb-2014)
Warning!  /dev/mapper/lvm-root is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
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

      130281 inodes used (0.82%, out of 15892480)
        1114 non-contiguous files (0.9%)
         112 non-contiguous directories (0.1%)
             # of inodes with ind/dind/tind blocks: 0/0/0
             Extent depth histogram: 121429/640
    33268738 blocks used (52.33%, out of 63569920)
           0 bad blocks
           3 large files

      101908 regular files
       19704 directories
           2 character device files
           0 block device files
           2 fifos
          22 links
        8625 symbolic links (8167 fast symbolic links)
          31 sockets
------------
      130294 files 

No errors, which I found weird. So I attempted to mount the root partition, and manually run the fsck located under /sbin/fsck:

root@ubuntu:~# /mnt/sbin/fsck -n -v /dev/mapper/lvm-root -f
fsck from util-linux 2.20.1
e2fsck 1.42.9 (4-Feb-2014)
Warning!  /dev/mapper/lvm-root is mounted.
Warning: skipping journal recovery because doing a read-only filesystem check.
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

      130281 inodes used (0.82%, out of 15892480)
        1114 non-contiguous files (0.9%)
         112 non-contiguous directories (0.1%)
             # of inodes with ind/dind/tind blocks: 0/0/0
             Extent depth histogram: 121429/640
    33268738 blocks used (52.33%, out of 63569920)
           0 bad blocks
           3 large files

      101908 regular files
       19704 directories
           2 character device files
           0 block device files
           2 fifos
          22 links
        8625 symbolic links (8167 fast symbolic links)
          31 sockets
------------
      130294 files 
0

Running fsck on a mounted filesystem will show the same errors that will occur if you poweroff the system at that moment; the state on disk is inconsistent because updates will have been buffered in memory and not yet been written out to disk. Hence DO NOT DO THIS!

Only run fsck on unmounted filesystems. Even on read-only mounted filesystems problems can occur if fsck fixes problems and the kernel doesn't know about it.

  • Whether the system is mounted or not doesn't make any difference on the LiveCD. Also not writing any changes using fsck with the -n flag – Jon Skarpeteig Sep 24 '15 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.