Saturday, December 8, 2012

Finding superblocks and fsck in RHEL



"If it looks like there is an issue with the filesystem's superblock. By running the command below we can check for the location of where backup superblocks will be:

mkfs.ext3 -n /dev/mapper/vg01-lvol5

The mkfs command may cause you some worry, but I'd like to stress the importance of -n option. This causes it to not actually perform any changes. Here is an excerpt from the mkfs.ext3 man page:

 -n     Causes mke2fs to not actually create a filesystem,  but  display
              what it would do if it were to create a filesystem.  This can be
              used to determine the location of the backup superblocks  for  a
              particular  filesystem,  so  long  as the mke2fs parameters that
              were passed when the filesystem was originally created are  used
              again.  (With the -n option added, of course!)

After this we can look for the lines simlar to:

Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632


Take the first value, i.e. 32768 and try using the commands I previously pasted with the -b option.

Once again confirm that the operation to be performed looks sane, keeping in mind to replace 32768 with your actual value:

fsck -b 32768 -fN /dev/mapper/vg01-lvol5

Then if it looks good try with:

fsck -b 32768 -fy /dev/mapper/vg01-lvol5

If you find the first backup superblock does not work try again with the next available one, i.e. 98304.

Again please make sure to have the filesystem unmounted."