I ran into the same problem in each of the two Ubuntu installs that I recently completed. The initial install failed, and the RAID arrays I had setup could not be deleted. This became a seemingly insurmountable obstacle in the way of completing the install process. In the first instance I finally did a complete wipe of all hard drives that had any part of the RAID configuration. Not wanting to go through that long process again I delved into finding a more sensible solution.

If you’re building a software RAID array during the Ubuntu setup you may encounter a failed install. I’m not sure why this is. When you go through the setup a second time, the RAID arrays that you created previously are already there. You cannot create new ones using the same partitions, and it won’t allow you to delete the old ones either.

My solution for disassembling and deleting these “ghost RAIDS” was to go through the installation process, enter the partitioner, selecting manual partitioning. You’ll then need to select Configure MD device to start any MD devices that already exist. If this option is not present create partition flagged as for RAID, then the option will appear.

Press Ctrl-Alt-F1 to get to a command prompt, press return.

You’ll have root access at the prompt, so there’s no need to su or sudo. You’ll want to see what MD devices are running, and which disks they’re using. Run

cat /proc/mdstat

You’ll see a bit of information about the MD devices, you’re looking for the following line(s):

md0 : active raid1 sdb1[1] sda1[0]

This tells you that md0 is a RAID1 array, using the partitions /dev/sda1 and /dev/sdb1. If you have more than one MD device you’ll see similar lines for each device.

Next run the command:

mdadm –stop –scan

This will stop all MD devices. During the setup none of the devices should be mounted, but in the a real world application, if the MD devices is mounted, you will get the error mdadm: fail to stop array /dev/md0: Device or resource busy In that case you have to first unmount the device with umount /dev/md0.

Next you need to zero out the superblock of each partition that is used in an array.

mdadm –zero-superblock /dev/sda1

Repeat this command as many times as needed.

I found that it was also helpful to clear the MBR of each drive with

dd if=/dev/zero of=/dev/sda count=1 bs=446

If you also want to erase the partition table change 446 to 512. If you clear the partition table you’ll want to run fdisk. Fdisk will give you an error that there are no partition tables, simply type w and hit return to write an empty partition table to the drive, then q to quit.

Now, reboot the system. If everything went according to plan you should have hard drives without any trace of a ghost RAID, and possibly no set partitions.

Things to note:

  • If your drive was degraded, it’s possible bad or missing drives will reappear after reboot and you’ll need to go through this process again.
  • If you already have data on any of the drives used in a MD device, the second you create your RAID array mdadm will start to sync the drives. This may cause your install to fail. Your best bet is to erase all the data from the drives before creating the RAID, or wait for mdadm to sync the drives, then format the MD device in the partition manager.
  • This guide is not designed to help recover data from a failed array. I make no guarantee that following these directions won’t cause data loss.