Re: Corrupted persistent superblock - repairable?

From: Enrique Perez-Terron (enrio_at_online.no)
Date: 10/19/05


Date: Wed, 19 Oct 2005 00:01:08 +0200

On Tue, 18 Oct 2005 16:37:20 +0200, Rohan Beckles <rohan.beckles@virgin.net> wrote:

> Hello --
>
> Recent failures of successive system disks (30 days apart!) convinced me to
> employ two RAID Edition HDs as system disks, in a RAID 1 configuration.
>
> The partitions on these disks are referred to in /etc/raidtab as /dev/md0
> (/boot, mirrored) and /dev/md1 (/, mirrored).
>
> Before my recent system upgrade, my two-drive RAID0 array (2 Western Digital
> Caviar 250GB HDs, for music and stuff) was configured as /dev/md0. My
> RAID0 array is now referred to in /etc/raidtab as /dev/md2. Now,
> post-upgrade, this array cannot be mounted on startup.
>
> /sbin/raidstart complains that both copies of the persistent superblock are
> corrupt. The array can only be started manually now, using /sbin/raid0run,
> after booting.
>
> I suspect that the root reason is that the superblock on this array has
> "/dev/md0" (and the drives that are associated with it) written in it, and
> of course /dev/md0 is now claimed by other devices.
>
> Is there anyway to updated the superblock of my RAID0 array to reflect its
> new device node name, i.e. "/dev/md2"? It would be even better if I could
> do this without destroying any data on the disk.

You could use mdadm:

   # mdadm --examine /dev/hda1
   /dev/hda1:
             Magic : a92b4efc
           Version : 00.90.02
              UUID : f0e9e745:51c48643:e1d520af:00422121
     Creation Time : Fri Oct 7 15:07:16 2005
        Raid Level : raid1
      Raid Devices : 2
     Total Devices : 2
   Preferred Minor : 0

       Update Time : Sun Oct 9 16:18:40 2005
             State : clean
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0
          Checksum : 5481f27b - correct
            Events : 0.108

         Number Major Minor RaidDevice State
   this 1 3 1 1 active sync /dev/hda1

      0 0 3 65 0 active sync /dev/hdb1
      1 1 3 1 1 active sync /dev/hda1

Look specifically at the line "Raid Level", to see if it is now a raid1 or raid0.
Check what other devices belong to the same volume (bottom).

Then

   mdadm --zero-superblock --force /dev/hda1
   mdadm --zero-superblock --force /dev/hdb1

   mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/hda1 /dev/hdb1

Caveats:

1. I have minimal experience with mdadm and md devices. The commands may not
    even be correct as shown.
2. Ensure that the *file system* on the devices is smaller than
    the partition size, by enough to allow for an md superblock.

      echo "($(fdisk -s /dev/hda1)/64 - 1)*64" | bc

    should tell the usable size of /dev/hda1. Use the smallest number from
    all component devices. Check that the actual file system size is less
    than or equal to that.
3. When creating an md device, the first component becomes the
    master copy, and the other component(s) are overwritten to
    make them equal.

-Enrique