Linux: Find Alternative Superblocks

by on December 6, 2010 · 5 comments· LAST UPDATED December 6, 2010

in

I think 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

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 5 comments… read them below or add one }

1 Gratzz June 3, 2011 at 6:50 pm

I am no expert but what I have been told is you have to issue a mkfs in read only mode with the exact same paramiters as your current file system.

Reply

2 Gratzz June 3, 2011 at 9:42 pm

To clarify my last comment. If the output you get from this guys command is a fault

for example Journal backup: inode blocks
Journal superblock magic number invalid!

Your not totally hosed you can use mkfs with the correct paramiters to duplicate the filesystem and note the SB locations.

If your in a raid youll want to pay attention to strip and stride.

Reply

3 gratzz August 16, 2013 at 6:24 am

I also had some luck recently using a hex editor to search for the magic number (ext4 = 0xEF53) that indicates the start of a superblock then using that sector offset as an alternate when mounting. This was in a strange location because something or one had changed the partition layout.

Another side note: I would mount the filesystem read only and pull critical files before running a filesystem check. Just had a couple go really wrong in that situation.
mount -o ro /dev/sdX1 /mountpoint

Reply

4 Manorama May 12, 2014 at 9:31 am

Hi ,

We have mounted one partition after few days that server was rebooted unexpectedly,
The file system entry was not there in /etc/fstab. So that file system is not mounted.
I Just wanted to know what is the last mount point of that file system.
Please advise.

Thanks,
Manorama..

Reply

5 pavloos August 19, 2014 at 5:08 pm

Hi Manorama,

You can find this using tune2fs, example:

# tune2fs -l /dev/vdb1 | grep “Last mounted on”
Last mounted on: /mnt

pawel

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: