So one day you’re halfway through your morning coffee, and someone has already left you a message:
ext4-fs error: unable to read superblock
The system won’t boot. Files are completely inaccessible. There’s no obvious way to move forward. Looks like you’ve got a full-blown mess on your hands, and you’ve got no clue where it even started.
Alright, first things first—breathe. This can be fixed. Grab that coffee — and let’s clean up this mess fast!
First, get a root console (e.g. via grub) and pull up a list of partitions:
sudo fdisk -l
And from there you take the one you need (e.g.: /dev/sda3). Choose carefuly!
Let’s make sure what is going on by doing a disk check using:
sudo fsck.ext4 -v /dev/xxx
And then, you got it:
fsck.ext4: Group descriptors look bad… trying backup blocks… fsck.ext4: Bad magic number in super-block while trying to open /dev/sda5
The superblock could not be read or does not describe a correct ext4 filesystem. If the device is valid and it really contains an ext4 filesystem (and not swap or ufs or something else), then the superblock is corrupt, and you might try running e2fsck with an alternate superblock: e2fsck -b 8193
Run the following command to list the blocks where your superblock backups are stored. Remember to replace /dev/xxx with your affected filesystem partition.
sudo mke2fs -n /dev/xxx
At the bottom of the output, you’ll see a list like this:
Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Now, use any backup with the following command to restore the corrupted superblock from one of the backup blocks. Replace block_number with one of the numbers from the backup list and /dev/xxx with your partition.
sudo e2fsck -b block_number /dev/xxx
Once done, reboot your system. If the issue persists, just repeat the steps using a different backup block.
Enjoy!