Increase disk size of Xen VM


Looking for a fast and safe mode to increase the size of a Xen VM I find this link that match exactly my situation: a image disk with only two partitions, the root partition and a swap partition.

So this is the steps that I followed to reach my goal:

  1. create a backup of the diskimage that you want to modify
  2. shutdown domU
  3. add extra space to the image by entering: dd if=/dev/zero bs=1M count=1024 >> /path/to/diskimage (this would add another 1024M to the DomU image)
  4. boot domU
  5. disable swap partitions by entering: swapoff /dev/xvda2 (or what corresponds to your setup)
  6. fdisk /dev/xvda (or what corresponds to your setup)
  7. press p + enter so see the whole disksetup
  8. delete the second swap partition by entering d + enter and then 2 + enter
  9. delete the system partion by entering d + enter and then 1+enter
  10. recreate the system partition with the same start cylinder than the older one but an end-cylinder bigger than the old cylinder value. press n <enter> p <enter> 1 <enter> and then enter the values
  11. recreate the swap partition (with n <enter> p <enter> 2 <enter> and appropriate values
  12. chance the partition type of partition 2 to swap by pressing: t <enter> 2 <enter> 82 <enter>
  13. exit fdisk by pressing w <enter>
  14. execute: mkswap /dev/xvda2 to make the swap space ready
  15. reboot domU
  16. execute: resize2fs /dev/xvda1

Be aware that if you have a different partition schema this would not work!

Share

Tags: