Resize disks
Note: Article about Proxmox VE 2.0 |
Resizing guest disk
You can resize your disks online or offline with command line:
qm resize <vmid> <disk> <size>
exemple: to add 5G to your virtio0 disk on vmid100:
qm resize 100 virtio0 +5G
Enlarge the partition(s) in the virtual disk
Depending on the installed guest there is several diffent ways to resize the partions
Windows Guests
- Guest is Windows 7, Windows Vista or Windows Server 2008
- Boot the system, logon as administrator and extend the disk and filesystem (Using Disk manager)
- For more info www.petri.co.il/extend-disk-partition-vista-windows-server-2008.htm
Other guests
Use gparted or similar tool (recommended)
In gparted and possibly most other tools, LVM and Windows dynamic disc is not supported
Boot the virtual machine with gparted or similar tool, enlarge the partion and optionally the file system. With som linux clients you often need to enlarge the extended partion, move the swappartion, shrink the extended partion and enlarge the root partion. (or simple delete the swap and partion andre create it again - but remember to activwate the swap agin (last step).
Gparted have some warnings about some specific operations not well supported with windows guest - outside the scope of this document but read the warnings in gparted.
Linux guests - online resizing
Enlarge the partions with gnu-cfdisk on the virtual master server, then online resize the filesystem in the virtual machine. A bit more complicated but possible faster.
AFAIK only reasonable option with guests using LVM
Install gnu-cfdisk on the virtual master
apt-get install gnu-cfdisk
Mount the disk and open CFDISK:
In case of a QCOW2 image
apt-get install nbd-client qemu-nbd --connnect /dev/nbd0 diskimage cfdisk /dev/nbd0
In case of a “RAW” image
cfdisk diskimage
In case of a LVM image
cfdisk /dev/xxxxx/diskimage
Enlarge the partion in CFDISK
Unfortunaly gnu-cfdisk can not resize most filesystems, only partitons - in general
- Use “fixed start” to avoid long moving time
- Use “change size” to only enlarge partion, not file system.
If the virtual guest is a linux machine with a swap disk as the last partion you can simply delete the swap, enlarge the first disk and create a new swap - but remember to “activate” the swap again (see last step)
In case of LVM guest, simple enlarge the LVM partion and mayby the extended partion
In case of QCOW2 - disconnect the NBD mount:
qemu-nbd -d /dev/nbd0
Enlarge the filesystem(s) in the partions on the virtual disk
If you did not resize the filesystem in step 2, you need to boot the system and online resize it.
Linux client with LVM
Enlarge the physical volume (in this case on vda5)
pvresize /dev/vda5
Enlarge the logical volume (in this case root)
lvresize -L+1G /dev/xxxx/root
Enlarge the filesystem
resize2fs /dev/xxxx/root
Linux client
Enlarge the filesystem (in this case root is on vda1)
resize2fs /dev/vda1
Optionally with linux Guests - activate the swap again
If you have deleted the swap partion with gparted or cfdisk, you need to activate it again
mkswap /dev/vdxy
where vdxy is the swap partition
Notice the UUID and maybe change it in /etc/fstab (depending on distribution)
swapon -a
check with “free” that the swap is activated