Quantcast
Viewing all articles
Browse latest Browse all 10

fixing superblock problems

The purpose of this blog is just to sum up various solutions I found which help in fixing a partition superblock related problems. I just thought, instead of googling every time such thing happens, why not keep it all in one document?

The problem started when after resizing my 1st ext4 partition I got problems mounting the resized partition and fsck would give off this error:
Code:
sudo fsck.ext4 -v /dev/sda1
e2fsck 1.41.14 (22-Dec-2010)
The filesystem size (according to the superblock) is 19531245 blocks
The physical size of the device is 19518208 blocks
Either the superblock or the partition table is likely to be corrupt!
The first solution was found HERE and its idea is in fixing the bad superblock by restoring it from backup. It runs as follows:
Code:
$sudo mke2fs -n /dev/sda1

Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
4882432 inodes, 19518208 blocks
975910 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
596 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, 
	4096000, 7962624, 11239424
So the line which I made in BOLD is where I get the superblock backups for the given partition. So I'm supposed next to just restore the superblock from one of these backups. For example:
Code:
sudo e2fsck -b 11239424 /dev/sda1
This fixes various superblock related problems, but it didn't fix mine :(!...

Then, however, I found one thread answering this question quite some time ago. The option given there is just to resize the partition back to the size "physical size of the device" as reported by fsck.ext4 using the 'resize2fs tool:
Code:
sudo resize2fs /dev/sda1 19518208
...
resize2fs 1.41.14 (22-Dec-2010)
Resizing the filesystem on /dev/sda1 to 19518208 (4k) blocks.
The filesystem on /dev/sda1 is now 19518208 blocks long.
Obviously this operation writes the physical size of the partition back to the superblock and voila! The partition is back and mountable with all the files accessible again!

Viewing all articles
Browse latest Browse all 10

Trending Articles