Removing an md swap partition

My core2duo linux box here has been running a software RAID1 swap and root for some time now. Basically /dev/md1 is the mirrored swap using the first gig of two drives, and the root partition is /dev/md2 using partition 2 on the same drives. It all works quite well.

Recently I was doing some experiments with virtual machines and in an attempt to improve performance I thought I’d change the RAID1 swap to a RAID0 swap. I thought this should be relatively simple. I had another partition elsewhere that I added in as additional swap first, then removed the /dev/md1 swap from the system;

swapoff /dev/md1

And then tried to shut down and delete the /dev/md1 array. This did not work

mdadm --stop /dev/md1
Device or resource busy.

Hmmm, I’ve removed md devices before and I thought this should really work, since the device is no longer used as swap. So off to the google we go. Of course lots of people have similar problems … and it was interesting that a lot seemed to be related to swap. Per a lot of forum discussions, there are questions and not many answers.

However, I found this SUSE forum post and it had the answer that worked for me. Basically I had to reboot, edit the grub boot config and added ‘noresume’ onto the end of the kernel line. Once it was booted up, I could now stop /dev/md1 and remove it. Something to do with software suspend locking the swap device. Crazy. Very un-unixy.