Note to self: what to do when the hard disk fails (Linux)

It’s been a bad day.

One of my Linux box hard drives decided to fail this morning. Luckily, it’s not totally failed, but the superblock is gone AWOL. Let’s recap what I did to revive it until a replacement can be mounted.

  1. The first thing I’ve noticed was that my /storage partition had been re-mounted as read-only when the kernel intercepted an error. So I simply umount’ed it and tried a fsck.ext3 /dev/hda1. Too bad it couldn’t read the superblock, thus it failed…
  2. So I ran mke2fs -n /dev/hda1: the -n switch means “don’t create a filesystem, just tell me where the superblock backups will be stored”. As long as the other parameters are the same as those used when creating the filesystem, this will correctly locate the superblock backups. The first one reported in my case was at block 32768.
  3. At this point I’ve been able to repair the filesystem using fsck.ext3 -b 32768 /dev/hda1.
  4. Finally, I tried to remount the partition with mount /storage, but obviously it would have been too easy… the first superblock is currently sitting on a Really Dead Sector (TM) 🙁
  5. Knowing that the backup at block 32768 was working, I’ve finally been able to finish the job with mount -t ext3 -o sb=131072 /dev/hda1 /storage (where 131072 is 32768 * 4, as the filesystem uses 4k blocks, while mount uses 1k units)

Phew! Everything looked good at this point. Good enough to backup a lot of data, anyway.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.