LINUXMAKER, OpenSource, Tutorials

The superblock of the hard disk is damaged

Ein Lösungsweg aus dem Dilemma heraus

Who has not had that under Linux already, that super blocks are shot dead. The Superblock contains information about the management of the file system used:

  • size of the file system
  • Number of free blocks
  • Pointer to a list of free blocks
  • Pointer to the first free block in the list of free blocks
  • Size of the inode list
  • number of free inodes
  • Pointer to list of free inodes
  • Pointer to the next free inode in the list of free inodes
  • Lock fields for list of free blocks / inodes (for example, for bad blocks)
  • Display field, if Superblock was changed

But what if you see yourself confronted with such a syslog message and nothing works?

mount: wrong fs type, bad option, bad superblock on /dev/nbd0p2, missing codepage or helper program, or other error

Most of the time you can not access the file system anymore. In my case that was a proxmox image of a VM, which then could not be started.

In my case, I first made a copy of the image on a sufficiently large other partition with dd. This takes different lengths depending on the size, but is necessary because the copy always works better and freer.
The first tool is

fdisk /dev/nbd0

In this way I can show the distribution of the partitions. And with

e2fsck -f /dev/nbd0p1

I do a filecheck. With

mke2fs -n /dev/nbd0p1

I will be shown the super blocks, which I can then repair with.

e2fsck -f -y -b <Superblock> /dev/nbd0p1

Finally, the partition can be mounted on again

mount /dev/nbd0p1 /mnt

and I come back to the lost data believed. For me it was important configuration files, which I had urgently needed when reinstalling the VM, after all, it was a week's work.