Friday, April 25, 2014

Fixing bad superblocks on filesystems

Fixing bad superblocks on filesystems

Occasionally, when a filesystem is mounted during the system boot, the mount will fail because the "superblock" cannot be read. There is aa easy fix, but you have to take a extreme care.

A. Procedure -- short form

1. determine the filesystems and devices
# df -h

2. Note the list of devices and corresponding filesystems and unmount the one that has a problem.
# umount {/badfilesystem}

3. Determine the superblock information.
#  NOTE: YOU MUST USE THE "-n" OPTION TO AVOID
#        REFORMATTING THE FILESYSTEM!

# mke2fs -F -n {/baddevicename}

Note: Expect about one screen of output

4.  Pick a superblock backup and use that number as input
# e2fsck -b {superblockbackupnumber} {/baddevicename}

Note: Expect some output about Passes 1 - 5; be prepared to answer some questions about blocks or inodes that have some problems with.

5 remount the file system
# mount {/badfilesystem}

B. Procedure -- long form with example

1. Determine the filesystems and devices
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3              26G   20G  4.8G  81% /
udev                  4.0G  168K  4.0G   1% /dev
/dev/sda1             388M   38M  331M  11% /boot
/dev/mapper/system-ORA
                      8.4G  131M  7.8G   2% /ora
/dev/mapper/system-ORADATA
                       26G  129M   24G   1% /oradata

2. unmount the FS that has issue with.
# umount /oradata

3. Determine the superblock information
# dumpe2fs /dev/mapper/system-ORADATA | grep superblock
dumpe2fs 1.38 (30-Jun-2005)
  Primary superblock at 0, Group descriptors at 1-2
  Backup superblock at 32768, Group descriptors at 32769-32770
  Backup superblock at 98304, Group descriptors at 98305-98306
  Backup superblock at 163840, Group descriptors at 163841-163842
  Backup superblock at 229376, Group descriptors at 229377-229378
  Backup superblock at 294912, Group descriptors at 294913-294914
  Backup superblock at 819200, Group descriptors at 819201-819202
  Backup superblock at 884736, Group descriptors at 884737-884738
  Backup superblock at 1605632, Group descriptors at 1605633-1605634
  Backup superblock at 2654208, Group descriptors at 2654209-2654210
  Backup superblock at 4096000, Group descriptors at 4096001-4096002

4. Pick a superblock backup and use that number as input
# e2fsck -b 294912 /dev/mapper/system-ORADATA
e2fsck 1.38 (30-Jun-2005)
/dev/mapper/system-ORADATA: recovering journal
/dev/mapper/system-ORADATA was not cleanly unmounted, check forced.
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

/dev/mapper/system-ORADATA: ***** FILE SYSTEM WAS MODIFIED *****
/dev/mapper/system-ORADATA: 11/3335808 files (0.0% non-contiguous), 137492/6659072 blocks

5. Remount the file system
# mount /oradata
#

No comments:

Post a Comment