Can anyone point in the right direction on how to remove SWAP out of a RAID1 configuration on Ubuntu 10.04 server? According to the Ubuntu Advanced installation guide, here, it said to add swap to the raid but I am having some serious performance issues. I would like to remove it from the array and recreate it, with the same size, on the two separate drives. Zero data loss on the other array is a must.

It's a remote computer so I would prefer to do it via command line if possible.

Here is the output from cat /proc/mdstat

md0 : active raid1 sdb1[1] sda1[0]
19530688 blocks [2/2] [UU]

md1 : active raid1 sdb21 sda2[0]
957230016 blocks [2/2] [UU]
  • Err... is the swap partition one of the md0 or md1 arrays? What does swapon -s give you?
    – Paul
    Oct 13 '11 at 5:25
  • The swap device is md0. Oct 13 '11 at 12:56

Assuming /dev/md0 is your swap as it is the smaller of the two, you can just disable swap, stop the array, and delete it:

swapoff -a

mdadm --stop /dev/md0
mdadm --remove /dev/md0

Then you can just fdisk sdb1 and sda1 and change their type to 82 (swap). Then swapon -a to activate. Change the fstab swap settings from /dev/md0 to /dev/sdb1 and duplicate the line for /dev/sda1.

None of this will impact /dev/md1.

  • Cool. Another question, do I need to do this by live cd or can I do it with a normal boot? Oct 13 '11 at 12:57
  • You can do all of this in a normal session. The swapoff will reduce available "memory" - so if your physical ram is low this might impact running processes. But in general this is a low risk operation.
    – Paul
    Oct 13 '11 at 22:25
  • Why not create them as RAID0 and get some performance out of it? Mar 6 '14 at 22:37
  • there is no need to RAID them. swap devices are striped by the kernel if they have equal priority.
    – rogerovo
    Aug 17 '14 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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