Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to recover from a degraded RAID array. I stupidly used mdadm --create somewhere along the way, and now a couple of my devices have incorrect superblocks. Luckily I kept a copy of the old superblocks:

/dev/sdd1:
          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : 7318877d:a7538da2:dbdff5e9:613cc676
           Name : vern:2
  Creation Time : Thu Oct 20 21:58:58 2011
     Raid Level : raid5
   Raid Devices : 3

 Avail Dev Size : 1953517954 (931.51 GiB 1000.20 GB)
     Array Size : 1953517568 (1863.02 GiB 2000.40 GB)
  Used Dev Size : 1953517568 (931.51 GiB 1000.20 GB)
    Data Offset : 2048 sectors
   Super Offset : 8 sectors
          State : clean
    Device UUID : 3dc62a0d:71ad83cf:f0dea827:6919f67c

    Update Time : Mon Mar  4 19:53:30 2013
       Checksum : a1b473f6 - correct
         Events : 152880

         Layout : left-symmetric
     Chunk Size : 512K

Comparing this to the new superblock:

          Magic : a92b4efc
        Version : 1.2
    Feature Map : 0x0
     Array UUID : 53e45e96:bc283e07:77748762:24fade80
           Name : Velma:2  (local to host Velma)
  Creation Time : Fri May  3 17:35:48 2013
     Raid Level : raid5
   Raid Devices : 3

 Avail Dev Size : 1953257858 (931.39 GiB 1000.07 GB)
     Array Size : 1953257472 (1862.77 GiB 2000.14 GB)
  Used Dev Size : 1953257472 (931.39 GiB 1000.07 GB)
    Data Offset : 262144 sectors
   Super Offset : 8 sectors
          State : clean
    Device UUID : bae87034:ba42a7ed:c4fa2854:5888d619

    Update Time : Fri May  3 17:35:48 2013
       Checksum : b3c99dd4 - correct
         Events : 0

         Layout : left-symmetric
     Chunk Size : 512K

The major difference here is in the data offset. If I can manually set the data offset back to 2048 sectors, then I stand a fighting chance of recovering the data in the RAID volume.

So... how can I set this offset?

share|improve this question
    
How did you create RAIDs with different offsets at all? I don't see any possibility in man mdadm how to influence that. –  Hauke Laging May 3 '13 at 18:49
    
This is an old RAID array that has been through many versions of Ubuntu... as I've been replacing disks with different versions of mdadm, they have been added to the array with different data offsets. –  Kkkev May 3 '13 at 19:00
    
Oh, that makes it even more fun. I guess in this case you have to write the respective field of the superblock (and maybe a checksum) directly (without a tool). Is it an option for you to get access to the data by a work-around, make a backup and completely recreate the array afterwards? –  Hauke Laging May 3 '13 at 19:07

1 Answer 1

up vote 1 down vote accepted

I found the answer deep within the bowels of http://comments.gmane.org/gmane.linux.raid/38674: it turns out that there is a branch of mdadm that allows custom data offsets. To get it:

git clone -b data_offset git://neil.brown.name/mdadm
cd mdadm
make

This adds the ability to set the data offset on a per-device basis, by appending the device id with a : and the offset. For example:

./mdadm --create /dev/md2 --level=5 -raid-devices=3 --assume-clean \ 
    /dev/sdb3:89088 /dev/sdd1:1024 /dev/sdc3:131072

I had to divide the offset by 2, as it is in K rather than sectors. I think that I could have used

./mdadm --create /dev/md2 --level=5 -raid-devices=3 --assume-clean \ 
    /dev/sdb3:178176s /dev/sdd1:2048s /dev/sdc3:262144s

instead, but I haven't verified this.

Anyway, this built the array with the correct size and I have managed to recover some of the data from it. Result!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.