After upgrading my new server from Lenny to Squeeze, I noticed that the iWeb default install on this machine had the swap partition on a mirror. Not that I expect this machine to be doing much swapping, but I figured I should fix it anyways. To destroy the array and make those partitions “plain” swap partitions, follow these steps:
### find out which array is the swap partition and see who the members are
### fstab told us md1 is the swap partition and xvda5 and xvdb5 are the member partitions in that array
### turn off swap
### stop the array and delete the superblocks. without zeroing the superblocks the array will still be auto-assembled at boot and we'll get no swap
mdadm --stop /dev/md1
mdadm --zero-superblock /dev/xvda5
mdadm --zero-superblock /dev/xvdb5
### use fdisk to change the partition types for xvda5 and xvdb5 to "82 Linux swap / Solaris"
fdisk /dev/xvda #(t, 5, 82, w)
fdisk /dev/xvdb #(t, 5, 82, w)
### take the reference to /dev/md1 out of mdadm.conf (1 less error message at boot)
### modify fstab - change the reference to /dev/md1 to /dev/xvda5, then add another line for /dev/xvdb5
### reboot if you want to make sure it's all happy at boot time
I mainly wanted to do this so that if the swap space is ever actually being used, the system won’t have to mirror every write to the other drive. I’ve also read that linux is smart enough to distribute writes to swap space between partitions if more than one are available, which makes sense to me but I’d have to confirm that rumor. This change will potentially cut down on a bunch of CPU usage and IO at some point in the future, and a side benefit to doing this is that we have increased the amount of swap space from 2GB on this system to 4GB.
Still don’t want to ever use it though… 😉