This patch series allows you to shrink various objects, as
requested in the following bugs:
https://bugzilla.redhat.com/show_bug.cgi?id=585221 # resize2fs
https://bugzilla.redhat.com/show_bug.cgi?id=585222 # pvresize
https://bugzilla.redhat.com/show_bug.cgi?id=585223 # ntfsresize
The first patch provides a consistent way to specify numbers
with suffixes to guestfish, eg:
truncate-size /foo 1G
It also unifies the number parsing code used by 'alloc' and
'sparse' commands to use the same Gnulib function.
Patches 2-4 implement the resizing.
With all four patches applied you can shrink filesystems even where
the container is larger, and you can use suffixes to specify the new
filesystem size.
Example using resize2fs-size:
$ guestfish -N fs:ext3:1G
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for a list of commands
'man' to read the manual
'quit' to quit the shell
<fs> vfs-type /dev/vda1
ext3
<fs> blockdev-getsize64 /dev/vda1
1073741312
<fs> resize2fs-size /dev/vda1 100M
<fs> blockdev-getsize64 /dev/vda1 # container size same
1073741312
<fs> mount-ro /dev/vda1 / # but filesystem is
smaller
<fs> df-h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 98M 17M 77M 18% /sysroot
Example using pvresize-size:
$ guestfish -N part:1G
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for a list of commands
'man' to read the manual
'quit' to quit the shell
<fs> pvcreate /dev/vda1
<fs> pvresize-size /dev/vda1 512M
<fs> pvs-full
[0] = {
[...]
pv_size: 536870912
dev_size: 1073741312
[...]
}
Example using ntfsresize-size:
$ guestfish -N fs:ntfs:1G
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for a list of commands
'man' to read the manual
'quit' to quit the shell
<fs> ntfsresize-size /dev/vda1 512M
<fs> mount-ro /dev/vda1 /
<fs> df-h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 512M 5.6M 507M 2% /sysroot
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/