Cannot delete a RAID swap partition during Ubuntu installation

During some tests of Ubuntu in a virtual machine, I ran across an issue I’ve seen before, but never been able to fix, until now.

If you have a RAID array that contains a swap partition, you will not be able to delete it in the Ubuntu installer. Here’s the situation:

A swap partition on a RAID-1 array

A swap partition on a RAID-1 array

And if you try to delete the RAID array (“delete MD device”), here’s the error message:

Failed to delete the software raid device. There was an error deleting the software RAID device. It may be in use.

Failed to delete the software raid device. There was an error deleting the software RAID device. It may be in use.

An educated guess at the problem would be that the swap is in use, and as such, not able to be deleted. You’re right, but it’s (almost) not that simple. But let’s hit CTRL-ALT-F2 to get a console open, and try to turn off swap:

swapoff -a

Yet it still won’t delete.

Okay, let’s try to force-stop the MD array. First, let’s find out for sure which MD devices there are. Doing this:

ls -l /dev/md

Shows this:

linux:0 -> ../md127

So we know the device is md127. Let’s try to force-stop it now:

mdadm --stop --force /dev/md127

Gives this message:

mdadm: Cannot get exclusive access to /dev/md127:Perhaps a running process, mounted filesystem or active volume group?

Well, what now?

The solution:

swapoff /dev/md127

Note: If you’re jumping back to the installer, don’t do an mdadm –stop /dev/md127. That’s going to confuse the installer. Just swapoff and then return to the installer and delete the software raid.

About these ads

,

  1. #1 by musikgoat on February 1, 2014 - 11:00 pm

    Very helpful!!!

  2. #2 by Hector Goncalves on February 17, 2014 - 4:26 pm

    Thanks! it works too on debian installation

  3. #3 by Will F on March 8, 2014 - 7:47 am

    Thank you so much! Very helpful!

Follow

Get every new post delivered to your Inbox.

Join 34 other followers

%d bloggers like this: