Notes on adding new HDD space to XenServer VM using ext3

Ubuntu, for example, will use ext3 by default.  And on XenServer, you can’t boot into gparted (I think it should be possible, but I can’t get it to work).
If your VM is using LVM (eg CentOS), do not do this, there is an easier way.

The following instructions will not delete any data if you have one /root partition with all the data on that you’re increasing, and so long as you start the new partition at the same place on the disk.

Rough instructions:

shut down the VM
backup the VM
using xenserver, add the extra space
boot into recovery mode (have the distro iso in the drive, and go to toolbar > VM > start/shutdown > start in recovery mode
in recovery mode, bring up a shell running from the recovery media (nothing mounted)
fdisk /dev/sda
p # print out the current partition table, take a note of the start of the root partition, the type codes of all partitions, and optionally the size of additional partitions
d # delete all partitions
set up the partitions again (for swap, first add two other partitions – in ubuntu this is sda1 primary and sda2 extended, then label 5 for swap will be available)
t # change type of partitions if necessary
wq # write the partitions

need to restart here?  go back to rescue mode if so

e2fsck -f /dev/sda1
resize2fs /dev/sda1
resize2fs /dev/sda5 (might need to do e2fsck first – try resize2fs and it may tell you to do e2fsck)
(don’t think you need to for /dev/sda2??)

restart the computer, not rescue mode

check fdisk -l shows the partitions

umount /dev/sda5
mkswap /dev/sda5
swapon /dev/sda5

blkid # get partition ids (should also have given you swap id when did mkswap command)
vi /etc/fstab # make sure swap partition is correct, like this:
  UUID=3ddbc973-d84c-4dad-ba09-473f46f72c32 none  swap    swap    sw      0     0
restart, not rescue mode

check swap mounted
free -m #should show swap with some space



Leave a Reply

Your email address will not be published. Required fields are marked *