How to resize disk(no lvm) in proxmox ve

Today I met a problem that I need to extend disk image for a ubuntu server which is a virtual machine hosted in proxmox ve.

Resizing disk images

First thing first, I need resize the disk images of the virtual machine.I can do it both in command line or via web management interface.

  • Extend disk size of virtual machine via shell command
# Extend disk size of virtual machine with vid 136 with 100G
qm resize 136 virtio0 +100G

  • Extend disk size of virtual machien via web interface

"Datacenter" | "$Node" | $VIRTUAL_MACHINE | "HARDWARE" | "HARD DISK(SCSI0)" | "RESIZE DISK" | "size Increment(GiB) | "100" | "Resize disk"

Enlarge the partition in the virtual disk

Login the virtual machine and run command as show below:

  • Show disk partition
# show disk device
ls -al /dev/sda*
  • Run parted with command parted /dev/sda
root@xxx-xxxx-server:~# parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
  • print partitions. print
(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 389GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      30720kB  30GB   30GB   ext4
  • Resize partition with command resizepart.
(parted) resizepart
  • select partition which I wanted to resize. 2
Partition number? 2
  • Enter y to continue.
Warning: Partition /dev/sda2 is being used. Are you sure you want to continue?
Yes/No? y
  • Enter size 200GB
End?  [30GB]? 200GB
(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 389GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name  Flags
 1      1049kB  2097kB  1049kB                     bios_grub
 2      2097kB  200GB   200GB   ext4
  • Quit parted with quit.
(parted) :quit

Enlarge partition with resize2f

resize2f /dev/sda2 99G
# Show size of partition
df -h 

Swell