Ubuntu – Resize Disk Partition on Remote VM Server


I'm running Ubuntu Server 10.04 on a remote server as a VM. I only have access to the VM.

The VM is assign a disk space of 20GB, however the drive is currently only partitioned to use about 4.7GB.

I know that you can use LiveCD to repartition a drive using gparted. How would you go about doing that on a remote VM? (Since the partition is also the startup volume)

# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00074164

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         618     4959232   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             618         653      280577    5  Extended
Partition 2 does not end on cylinder boundary.
/dev/sda5             618         653      280576   82  Linux swap / Solaris

Best Answer

That what I would try:

  1. Many VPS hosting providers have tools to manipulate partitions in their control panels. Getting access to the control panel would be the safest option.

  2. Do not resize the partition but create a second partition and move your "working" data to that partition. I'e. mount /home or wherever your data is to a separate partition

  3. If you still feel adventurous, try remounting the boot partition read-only and see if it's possible to resize it while mounted read-only

  4. Something really tricky like remove swap - create a copy of your root partition at the very end of the drive - configure grub to boot from the new partition - reboot - resize your original partition - copy the data back - modify grub again - reboot - remove the temporary root partition - create a swap partition again.

I would consider the second two options really dangerous in the sense that if anything goes wrong your system just won't boot so you'd lose any access to the system.

Related Question