We are running software raid1 using MDADM on ubuntu 11.04. What's the best way to get rid of it Keeping the current system ?

I want to use hardware raid instead.

What I tried to do: -Copied the 1disk of software raid using HDClone. Configured degraded raid array without the second disk. Then copied everything from /dev/md0 onto a spare disk /dev/sdb using dd utility. However the copy wasn't accurate so I was not able to boot. I even tried to reinstall grub but it all didnt work. What's the best way to do this procedure? Thanks


I would move the installation to another drive. With the same DD utility, and do a grub install on it so that it boots normally. After that setup your hardware raid, and do DD from the drive you setup back to the new hardware raid drive and do a grub install on that drive, and you should be set.

  • for some reason dd from MD0 to dev sda fails...maybe should I use some parameters like a block size? – RomanG May 4 '12 at 3:34

On creating your software RAID you have chosen to combine multiple drives into one logical unit. In your case a RAID1 is just mirroring data. On using mdadm you did that by partitioning and configuring your drives accordingly. Exactly this is why disk-clone utilities obviously fail to move your data to another drive.

Of course you can still copy (e.g. by using cp -a or any other copy utility) your data from the RAID to any other spare disk.

In case we need to resolve our software RAID we can do so by e.g.:

sudo umount /dev/md0
sudo mdadm --stop /dev/md0
sudo mdadm --zero-superblock /dev/sda1 /dev/sdb1

Adapt the setting shown here for RAID /md0 and drives /sda and /sdb to your settings.

After that we need to change the partition type back from RAID to normal, install Grub, and update our fstab.

See also this question

  • should I run this using LiveCD? or boot the system first using the raid? – RomanG May 8 '12 at 2:17
  • IIRC you can't stop an array used by the system you booted from. If it's not a mere data drive you need to do this from a live session. – Takkat May 8 '12 at 6:03
  • I was able to remove the second disk by running this mdadm -G /dev/md0 -n 1 --force However, the system still relies on /dev/md0...how to get rid of this completely? Thanks – RomanG May 9 '12 at 3:07

This might come a little late..

dd is the best tool to clone raw disks ( or partitions ), and that's exactly what it does.

it copies raw data regardless ( and unaware ) of what filesystem / structure is on the source ( data + metadata )> so ponder on this for a while, as this actually means it will reconstruct the target exactly the same as the source. Or shorter > dd'ing a raid member will create a raid member .... which in your case will create a second degraded array.... And that's definitely not what you intended to do...

also while it's true that a raid1 mirrors data, it doesn't mean the raw data of the raid members is identical ( some metadata will differ )

proper procedure for reusing a former raid member is to blank it by using

dd if=/dev/zero of=/dev/sdb bs=4k ( don't copy pasta this > change output device to your needs. )

this will properly zero any data / metadata > this is also a good idea on new disks...

if the raid was used as a system disk > run a live cd ( don't copy from a running system )

repartition / format / mount the cleaned disk mount the degraded raid array and copy the raids contents with

sudo rsync -HAXavx /media/raid1/ /media/newdisk/

following is only when raid was a system disk :

alter the UUID's in fstab on the target volume ( find out what the new disk UUID is by running blkid )

copy the boot sector by running dd if=/dev/sda of=/dev/sdb bs=446 count=1 ( and NOT bs=512 like most folks think > using 512 will overwrite your partition table !! )

I'm now assuming the target disk is mounted as /media/newdisk

sudo mount --bind /dev /media/newdisk/dev

sudo mount --bind /sys /media/newdisk/sys

sudo mount --bind /proc /media/newdisk/proc

sudo chroot /media/newdisk/ ( and after you altered the UUID's in fstab )

grub-install /dev/sdb ( to make sure you've rewritten a fresh bootloader )


exit ( this returns to your non chrooted environment )

sudo reboot


Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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