Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

Its 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 sdb2[1] sda2[0]
957230016 blocks [2/2] [UU]

Swap is on the md0 device.

Thanks

share|improve this question
    
Which array is your current swap on? –  Andrew Oct 13 '11 at 5:50
    
Hey Andrew, swap is on the md0 device. Thx –  thiesdiggity Oct 13 '11 at 13:50
    
How much swap are you actually doing? –  MikeyB Oct 13 '11 at 15:32
    
Hey Mikey, we aren't actually doing much swap but I am thinking that might be degrading the server performance. The reason I am thinking that is because we have another server that is setup with RAID 1 but swap is not part of the RAID and its performance is excellent. The only differences between the two servers are: processors (both with 2 quad cores, just dif versions) and one is running Ubuntu 9.10 while the other is running 10.04. Do you not think swap in the RAID is the issue? –  thiesdiggity Oct 13 '11 at 16:31

2 Answers 2

up vote 2 down vote accepted

Assuming you've got swap on /dev/md1, this should work (this is in a root prompt):

# mdadm /dev/md1 --fail /dev/sdb2
# mdadm /dev/md1 --remove /dev/sdb2
# mdadm --zero-superblock /dev/sdb2
# mkswap /dev/sdb2
# echo "/dev/sdb2 none swap sw 0 0" >> /etc/fstab
# swapon /dev/sdb2
# swapoff /dev/md1
# mdadm --stop /dev/md1
# mdadm --zero-superblock /dev/sda2
# mkswap /dev/sda2
# echo "/dev/sda2 none swap sw 0 0" >> /etc/fstab
# swapon /dev/sda2

If you use sudo for these (as you probably should), you'll need to change echo $foo >> $blah to echo $foo | sudo tee -a $blah$.

share|improve this answer
    
Excellent, that doesn't seem too difficult. Can I do that within a normal boot or do I need to boot via Ubuntu Live CD? Thx. –  thiesdiggity Oct 13 '11 at 13:52
    
That's from a normal boot - with a LiveCD you wouldn't need to shuffle the active swaps around, just disassemble the array and convert both components to swap. –  Andrew Oct 15 '11 at 4:38

Meanwhile it depends on the version of kernel you use, LSR RAID-1 can give performance boost when reading from it — due to possible read balancing. Also, making swap not using RAID-1 means you have unstable OS (app hangs/crash) when one of the disks has failed. In other words, it's rather senseless idea.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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