View backup superblock locations on Linux filesystem and restore filesystem

Here we will check how to identify the backup superblock locations on the Linux filesystem.

The superblock keeps the filesystem metadata, and multiple copies are saved by filesystem to restore in case primary copy gets corrupted.

To view the available backup superblocks, we can use dumpe2fs command like below.

[root@nglinux ~]# dumpe2fs  /dev/sda1 | grep -i super
dumpe2fs 1.41.12 (17-May-2010)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
  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
[root@nglinux ~]#

In the above output, we can see:
primary superblock at 0.
And the backup superblock at every other cylinderical pallete.

Sometimes in case the primary superblock gets corrupted, we can try to restore the superblock information by scanning the filesystem using backup superblock using e2fsck command in the follwoing way:

[root@nglinux ~]# e2fsck -b 98304 /dev/sda1
e2fsck 1.41.12 (17-May-2010)
/dev/sda1 is mounted.
e2fsck: Cannot continue, aborting.
[root@nglinux ~]# 

Obviously you need to umount the device and then run above command.

I hope you liked the article. Please let us know in case your suggestions/comment.

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
2 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
Saket Jainved Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
ved
Guest
ved

if this /dev/sda1 is representing root partition then how you can umount it.

Admin

Yes right, we can’t umout it then…

Moreover if root partition is corrupted, then you will not able to boot your system until and unless you correct its superblock information.

For it to work, you need to correct it via.
a. Boot via cd.
b. or let it mount on RAM via initramfs and no partition is mounted.

And then restoring the superblock information.