Sometimes the file system superblock is getting corrupted. In worst case scenario we are also not able to run the file system check. By default file system check will be performed the on the superblock located at 0.
But nothing to worry as we know the superblock is having multiple copies saved at different locations in a file system. We can use those copies to to run the e2fsck on file system or to mount the file system.
Now the question arises
- How would we come to know about the location of copies of superblock?
- How can we run the file system check using another copy of superblock?
- How can we mount the file system using another copy of superblock?
In this article I am going to address all these questions.
I have one file system of 19G on which I am going to perform all the actions.
Question 1 : How would we come to know about the location of copies of superblock?
Answer 1 : dumpe2fs and mke2fs commands can be used to know about superblock.
dumpe2fs : This command can be used on mounted file system as well means the file systems which are working absolutely fine.
After running this command you will get to know each and every term associated with file system from that platheora of information you can capture only superblock information.
[root@node1 ~]# dumpe2fs /dev/mapper/VolGroup01-VolLV01 | grep -i superblock
dumpe2fs 1.41.12 (17-May-2010)
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
mke2fs : This command should be run on unmounted file system. NOTE : Don’t run this command without -n option.
[root@node1 ~]# mke2fs -n /dev/mapper/VolGroup01-VolLV01
mke2fs 1.41.12 (17-May-2010)
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1245184 inodes, 4980736 blocks
249036 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
152 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
So first most important question is answered.
Question 2 : How can we run the file system check using another copy of superblock?
Answer 2 : As we were not able to run the file system check on superblock at 0 location. Hence we proceed with file system check on superblock at 32768(Value taken from Step1 output).
Able to run the file system check on copy of superblock.
[root@node1 ~]# e2fsck -b 32768 /dev/mapper/VolGroup01-VolLV01
e2fsck 1.41.12 (17-May-2010)
One or more block group descriptor checksums are invalid. Fix<y>? yes
Group descriptor 0 checksum is invalid. FIXED.
Group descriptor 1 checksum is invalid. FIXED.
Group descriptor 2 checksum is invalid. FIXED.
Group descriptor 3 checksum is invalid. FIXED.
Group descriptor 4 checksum is invalid. FIXED.
Question 3 : How can we mount the file system using another copy of superblock?
Answer 3 : As we are not able to mount the file system using default superblock which starts at 0. We will try to mount the file system copy of superblock.
[root@node1 ~]# mount -o sb=98304 /dev/mapper/VolGroup01-VolLV01 /var/crash1
Tip : One useful command to determine when the file system is created and last mount time”
[root@node1 ~]# dumpe2fs -h /dev/mapper/vg_node1-lv_root | grep -E “Filesystem created|Last mount time”
dumpe2fs 1.41.12 (17-May-2010)
Filesystem created: Fri May 9 15:05:30 2014
Last mount time: Thu Jun 26 22:37:06 2014