To resize a virtual drive

From DISI
Revision as of 13:58, 23 May 2014 by Frodo (talk | contribs) (Created page with "Resizing a virtual drive (machine must be off): man virt-resize 0) Be extra safe and make a copy of the disk cp alpha-root alpha-root~preresize 1) Examine virtual drive's st...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Resizing a virtual drive (machine must be off):

man virt-resize

0) Be extra safe and make a copy of the disk

cp alpha-root alpha-root~preresize

1) Examine virtual drive's structure

virt-filesystems --long -h --all -a alpha-root~preresize

2) Create new drive (this uses the QCOW2 format. Multiple options available)

qemu-img create -f qcow2 -o preallocation=metadata alpha-root~postresize 15G

3) Use vm resize command to populate new disk with expanded partitions (and also expand LVM if applicable)

virt-resize --expand /dev/sda2 --lv-expand /dev/vg_alpha/root_lv alpha-root~preresize alpha-root~postresize

4) To expand more than 1 LVM partition, repeat the process

qemu-img create -f qcow2 -o preallocation=metadata alpha-root~postresize2 25G
virt-resize --expand /dev/sda2 --lv-expand /dev/vg_alpha/var_lv alpha-root~postresize alpha-root~postresize2

5) Swap file names around

mv alpha-root alpha-root~original
mv alpha-root~postresize2 alpha-root

6) Start virtual machine

virsh start alpha

7) Cross fingers