When I install CentOS using the XenServer template, it doesn’t allow make any changes to the disk drive configuration. This has two side effects that typically annoy me. First, it calculates an amount of swap space which could be anywhere from 50% to 200% of the amount of RAM you have (I’m not entirely sure of the calculation method it uses, but it takes into account disk size and amount of RAM). Secondly, if I have a drive that’s larger than 32GB, it will partition a chunk of it to be mounted at /home. I like to use separate logical volumes for a lot of things, however, /home is not typically one of them.
I’m going to cover both situations in this post. First let’s change the size of the swap space, and assign that space back to the root logical volume.
Resizing the Swap Drive
1. Turn off swapping.
swapoff -v /dev/VolGroup/lv_swap
2. Reduce the size of the logical volume.
lvm lvreduce /dev/VolGroup/lv_swap -L -8192M
3. Make the new swap space.
4. Turn swapping back on.
5. Check to see if your swap partition is the size you wanted it.
cat /proc/swaps free
Deleting the lv_home Logical Drive.
1. Unmount /home.
2. Remove the /home mount from fstab
3. Remove the line from fstab that looks like:
/dev/mapper/VolGroup-lv_home /home ext4 defaults 1 1
4. Remount drives
5. Remove the logical drive.
I usually find that a reboot at this point gives me better results. I’m not sure the cause of it, but on occasion I have not rebooted until the end, and found out I had corrupted my drive by the end.
Resize the lv_root Logical Drive.
1. Extend the logical volume.
lvextend -l +100%FREE /dev/VolGroup/lv_root
2. Resize the volume to use the remaining free space.
3. Check that the drive is the size you were expecting.