Monday, 5 September 2011

Linux: Find Alternative Superblocks

Linux: Find Alternative Superblocks

Ithink my file system has been damaged. Instead of block 1, I want to use block n as superblock. How do I find out an alternative superblock location under Linux?

Each file system has a superblock, which contains information about file system such as file system type, size, status, information about other metadata structures and so on.

You can use any one of the following command to find out the superblock location:

[a] mke2fs - Create an ext2/ext3/ext4 filesystem.

[b] dumpe2fs - dump ext2/ext3/ext4 filesystem information.

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command (alternatively you can boot from rescue or Live Linux CD and type the same commands):

# dumpe2fs /dev/sda5 | grep -i superblock

The above command will list all superblocks for /dev/sda5 as follows:dumpe2fs 1.41.11 (14-Mar-2010)
Primary superblock at 0, Group descriptors at 1-29
Backup superblock at 32768, Group descriptors at 32769-32797
Backup superblock at 98304, Group descriptors at 98305-98333
Backup superblock at 163840, Group descriptors at 163841-163869
Backup superblock at 229376, Group descriptors at 229377-229405
Backup superblock at 294912, Group descriptors at 294913-294941
Backup superblock at 819200, Group descriptors at 819201-819229
Backup superblock at 884736, Group descriptors at 884737-884765
Backup superblock at 1605632, Group descriptors at 1605633-1605661
Backup superblock at 2654208, Group descriptors at 2654209-2654237
Backup superblock at 4096000, Group descriptors at 4096001-4096029
Backup superblock at 7962624, Group descriptors at 7962625-7962653
Backup superblock at 11239424, Group descriptors at 11239425-11239453
Backup superblock at 20480000, Group descriptors at 20480001-20480029
Backup superblock at 23887872, Group descriptors at 23887873-23887901
Backup superblock at 71663616, Group descriptors at 71663617-71663645
Backup superblock at 78675968, Group descriptors at 78675969-78675997
Backup superblock at 102400000, Group descriptors at 102400001-102400029



Now you can use the backup superblock to check the file system using superblock # 98304 (warning do not run the following on mounted live file system):

# e2fsck -f -b 98304 /dev/sda5

OR mount the file system using superblock # 98304:

# mkdir -p /mnt/data5
# mount -o sb=98304 /dev/sda5 /mnt/data5

No comments:

Post a Comment

Twitter Bird Gadget