NAME
virt-resize - Resize a virtual machine disk
SYNOPSIS
virt-resize [--options] indisk outdisk
DESCRIPTION
Virt-resize is a tool which can resize a virtual machine disk, making it
larger or smaller overall, and resizing or deleting any partitions and
filesystems contained within.
Virt-resize cannot resize disk images in-place. Virt-resize should not
be used on live virtual machines - for consistent results, shut the
virtual machine down before resizing it.
This program is intended to be used in conjunction with
virt-list-filesystems(1) and virt-df(1). You should read the manpages
for those tools if you are not already familiar with them.
BASIC USAGE
1. Locate disk image
Locate the disk image that you want to resize. It could be in a
local file or device. If the guest is managed by libvirt, you can
use "virsh dumpxml" like this to find the disk image name:
# virsh dumpxml guestname | xpath /domain/devices/disk/source
Found 1 nodes:
-- NODE --
2. Look at current sizing
Use virt-list-filesystems(1) and/or virt-df(1) on the disk image to
find out what is currently inside the disk image, and how much free
space is available. For example:
# virt-df -h /dev/vg/lv_guest
Filesystem Size Used Available Use%
/dev/vg/lv_guest:/dev/sda1 98.7M 35.4M 58.3M 41.0%
/dev/vg/lv_guest:/dev/VolGroup00/LogVol00
8.6G 8.0G 0.1G 98.8%
In this example the filesystems are called "/dev/sda1" and
"/dev/VolGroup00/LogVol00".
3. Create destination disk
Virt-resize cannot do in-place disk modifications. You have to have
space to store the resized destination disk.
To store the resized disk image in a file, create a file of a
suitable size:
# truncate -s 10G outdisk
Use lvcreate(1) to create a logical volume:
# lvcreate -L 10G -n lv_name vg_name
Or use virsh(1) vol-create-as to create a libvirt storage volume:
# virsh pool-list
# virsh vol-create-as poolname newvol 10G
4. Resize
virt-resize indisk outdisk
This command just copies disk image "indisk" to disk image "outdisk"
*without* resizing or changing any existing partitions or
filesystems. If "outdisk" is larger, then an extra, empty partition
is created at the end of the disk covering the extra space. If
"outdisk" is smaller, then it will give an error.
To resize, you need to pass extra options (for the full list see the
"OPTIONS" section below).
"--expand" is the most useful option. It expands the named
filesystem within the disk to fill any extra space:
virt-resize --expand /dev/sda1 indisk outdisk
(In this case, an extra partition is *not* created at the end of the
disk, because there will be no unused space). If "/dev/sda1" in the
image contains a filesystem, then the filesystem is resized (if
possible because only some filesystem types support resizing).
Other options are covered below.
5. Test
Thoroughly test the new disk image *before* discarding the old one.
If you are using libvirt, edit the XML to point at the new disk:
# virsh edit guestname
Change