Monday, February 14, 2011

Destroying an mdadm Array

Or how to banish the ghost of raid5's past.
I recently made the jump from raid6 to greyhole. I'll cover why in another post, but the primary point here is that I took my array offline using the following command:
  • mdadm -S /dev/md0 (where md0 can be whatever your raid device's name is)
And then I formatted each of the raid drives to be an independently formatted disk with an ext4 partition. I then added them as part of my greyhole pool and life was grand. That is, until I rebooted, and low and behold, I found my lurid past haunting me. md0 had risen from the dead and was claiming most of the drives back as spares! Not only that but it attempted to make them raid members again and hid the previously created partitions! (By this I mean I only saw /dev/sdb without the accompanying partition /dev/sdb1.) My data is 100% backed up, so I was not afraid of data loss, but it was rather annoying to see, potentially, 75% of my newly transferred data swallowed by a jilted raid array. Fear not! By opening the disk in fdisk and writing the partition table, I was able to retrieve my data partitions intact.

Literally all I did above to recover my raid-altered drives was
  • fdisk /dev/sdX
  • w
I then checked to see if the raid superblocks were still present on my previous raid volumes even though they'd been formatted, and to my surprise they were! You can view the superblock information of any volume by running the following command:
  • mdadm -E /dev/sdX
If there is no super block you'll just get a line spit out that says "mdadm: No md superblock detected on /dev/sdX" otherwise you'll get a multiline printout of a drive's superblock information.

You can vanquish these peskily pervasive blocks by issuing the command:
  • mdadm --zero-superblock /dev/sdX

One other thing to check is that /etc/mdadm.conf is empty, as information about your raid device can reside here as well. After taking care of the superblocks and your mdadm.conf file you can be relatively sure that your array has been laid to rest for good.

No comments:

Post a Comment

Followers