[PATCH 0/4] Allow shrinking of ext2, PVs and NTFS
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/
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones New in Fedora 11: Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 70 libraries supprt'd http://fedoraproject.org/wiki/MinGW http://www.annexia.org/fedora_mingw
Richard W.M. Jones wrote:
Subject: [PATCH 1/4] fish: Allow suffixes on number parameters (eg. 1M)
This small change uses the gnulib xstrtoll functionality to enable suffixes on integer parameters in guestfish. For example:
truncate-size /file 1G
(previously you would have had to given the full number).
Nice. This all looks fine. My only surprise was to see no addition of xstrtoll to the list of modules in bootstrap, but that's fine, because it was already there.
This also applies to the 'alloc' and 'sparse' commands (and indirectly to the -N option). The specification for these commands has changed slightly, in that 'alloc foo 1MB' would now use SI units, allocating 1000000 bytes instead of a true megabyte. All existing uses would use 'alloc foo 1M' which still allocates true megabytes. --- fish/alloc.c | 34 ++----- fish/fish.c | 24 +---- fish/guestfish.pod | 162 ++++++++++++++++++-------------- regressions/rhbz557655-expected.stderr | 2 - regressions/rhbz557655.sh | 6 +- src/generator.ml | 5 +- 6 files changed, 113 insertions(+), 120 deletions(-)
-- 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/
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
-- 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/
participants (2)
-
Jim Meyering -
Richard W.M. Jones