How to repair corrupted filesystem from old disk

by teze   Last Updated February 26, 2018 02:00 AM

An old Debian 6 dedicated server we still use stopped working. Going to rescue mode using a live Ubuntu image, we quickly realized the filesystem is corrupt and disk is now read-only, with even partitions unaccessible.

According to the hosting provider, this is due to the disk's old age. It's just close to being dead.

Unfortunately, there are some files on it we'd like to recover if possible.

So in rescue mode, with everything unmounted, we tried to fix the partitions but without success :

$ sudo fdisk -l

Disk /dev/loop0: 314.3 MiB, 329584640 bytes, 643720 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Trying

$ sudo fsck /dev/md0

gives

fsck from util-linux 2.27.1
e2fsck 1.42.13 (17-May-2015)
fsck.ext2: Invalid argument while trying to open /dev/md0
The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/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 <device>
 or
    e2fsck -b 32768 <device>

Trying to get the block size doesn't help either:

$ sudo mke2fs -n /dev/md0

results in

mke2fs 1.42.13 (17-May-2015)
mke2fs: Device size reported to be zero.  Invalid partition specified, or
        partition table wasn't reread after running fdisk, due to
        a modified partition being busy and in use.  You may need to reboot
        to re-read your partition table.

Mounting back the partitions results now in an error, and tools like parted doesn't seem to work either.

I realize this is very likely, as mentioned, due to a hardware issue, but having no direct access to the hardware (provider keeps the machines private) any insight and clue on how to restore this is welcome.

Thanks!



Related Questions



fsck on shutdown instead of startup

Updated November 30, 2015 22:00 PM

how to fix filesystem of a LXC container

Updated February 09, 2018 15:00 PM


FSCK while booting Centos

Updated November 24, 2018 16:00 PM