I have wrote a little guide for Proxmox 1.9 regarding enlarging disks. Please comment. If possible i think it would be nice to have this info in the Wiki too.
When i wrote this guide i testet resizing, gpart, CFDISK and online resizing for all disk images (VMDK, QCOW, RAW, LVM). VMDK acted a little weird so i decided to remove it and recommend to convert VMDK to RAW images.
When i have time i will test the procedure in 2.0.
Resizing disks in Proxmox
In general there is four steps to enlarge a disk in proxmox
Step 1
If you have a local disk in VMDK format i suggest convert it to RAW or QCOW2
Some of these steps works with (some) VMDK images (untested), but there is not any reason (afaik) to use VMDK images other than for importing old virtual machine images from vmware without converting.
General
Step 1a
Step 1b
Step 2
Depending on the installed guest there is several diffent ways to resize the partions
Option 1
Option 2
Option 3
Step 3
If you did not resize the filesystem in step 2, you need to boot the system and online resize it.
Step 4
If you have deleted the swap partion with gparted or cfdisk, you need to activate it again
Best Regards
When i wrote this guide i testet resizing, gpart, CFDISK and online resizing for all disk images (VMDK, QCOW, RAW, LVM). VMDK acted a little weird so i decided to remove it and recommend to convert VMDK to RAW images.
When i have time i will test the procedure in 2.0.
Resizing disks in Proxmox
In general there is four steps to enlarge a disk in proxmox
- Enlarge the virtual disk in Proxmox
- Enlarge the partition(s) in the virtual disk
- Enlarge the filesystem(s) in the partions on the virtual disk
- Optionally with linux Guests - activate the swap again
Step 1
If you have a local disk in VMDK format i suggest convert it to RAW or QCOW2
- Shutdown the virtual machine
- Remove the disk from the Web interface, but do not delete the image from the disk.
- Log into the proxmox machine which have the virtual machine hosted
- Find the virtual HD and convert it with qemu-img
- cd /var/lib/vz/images/xxx
- qemu-img convert diskimage.vmdk diskimage.raw
- Where xxx is the machine ID and diskimage is the image name
- Using the web interface, add the new disk to the machine
Some of these steps works with (some) VMDK images (untested), but there is not any reason (afaik) to use VMDK images other than for importing old virtual machine images from vmware without converting.
General
- Shutdown the virtual machine
- Log into with SSH to the proxmox machine which have the virtual machine hosted
Step 1a
- In case of a local disk in image form (RAW or QCOW2) do the following.
- Find the virtual HD and enlarge it with qemu-img, fx
- cd /var/lib/vz/images/xxx
- qemu-img resize diskimage.zzz +1G
- Where xxx is the machine ID and diskimage is the image name
Step 1b
- In case of a remote disk on LVM storage
- Extend the image with
- lvresize -L+1G /dev/xxxxxx/diskimage
- To be sure that all machines in the cluster have the same info - (Important!)
- Log into all the machines in the cluster and execute
- lvchange --refresh -aly /dev/xxxxx/diskimage
- Log into all the machines in the cluster and execute
Step 2
Depending on the installed guest there is several diffent ways to resize the partions
Option 1
- Guest is Windows 7, Windows Vista or Windows Server 2008 - (recommended way)
- Boot the system, logon as administrator and extend the disk and filesystem (Disk manager)
- Windows Resize
Option 2
- 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 step 4 then.
- 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.
Option 3
- 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
- General guide lines
- 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
- In case of a QCOW2 image
- Enlarge the partion in CFDISK
- Unfortunaly gnu-cfdisk can not resize most filesystems, only partions
- 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
- qemu-nbd -d /dev/nbd0
- Mount the disk and open CFDISK:
Step 3
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
- Enlarge the physical volume (in this case on vda5)
- Linux client
- Enlarge the filesystem (in this case root is on vda1)
- resize2fs /dev/vda1
- Enlarge the filesystem (in this case root is on vda1)
Step 4
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
Best Regards