X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=tools%2Fvirt-resize;h=4beb45b57df315e551ecb4be8b3748e2a565eeb0;hp=8a71f96c68e163be6c1af31f6940b19588a939a5;hb=6975e87153f593fddd5c27435c2e6347825daca9;hpb=7d746ba6915e3c0d8fbe41053da64f4e9fa11cd4 diff --git a/tools/virt-resize b/tools/virt-resize index 8a71f96..4beb45b 100755 --- a/tools/virt-resize +++ b/tools/virt-resize @@ -58,10 +58,8 @@ B be used on live virtual machines - for consistent results, shut the virtual machine down before resizing it. If you are not familiar with the associated tools: -L, -L and -L, -we recommend you go and read those manual pages first. +L and L, we recommend you go and read +those manual pages first. =head1 EXAMPLES @@ -69,7 +67,7 @@ Copy C to C, extending one of the guest's partitions to fill the extra 5GB of space. truncate -r olddisk newdisk; truncate -s +5G newdisk - virt-list-partitions -lht olddisk + virt-filesystems --long -h --all -a olddisk # Note "/dev/sda2" is a partition inside the "olddisk" file. virt-resize --expand /dev/sda2 olddisk newdisk @@ -104,13 +102,14 @@ can use C like this to find the disk image name: =item 3. Look at current sizing -Use L to display the current partitions and +Use L to display the current partitions and sizes: - # virt-list-partitions -lht /dev/vg/lv_guest - /dev/sda1 ext3 101.9M - /dev/sda2 pv 7.9G - /dev/sda device 8.0G + # virt-filesystems --long --parts --blkdevs -h -a /dev/vg/lv_guest + Name Type Size Parent + /dev/sda1 partition 101M /dev/sda + /dev/sda2 partition 7.9G /dev/sda + /dev/sda device 8.0G - (This example is a virtual machine with an 8 GB disk which we would like to expand up to 10 GB). @@ -173,9 +172,7 @@ PV, then if virt-resize knows how, it will resize the contents, the equivalent of calling a command such as L, L or L. However virt-resize does not know how to resize some filesystems, so you would have to online -resize them after booting the guest. And virt-resize also does not -resize anything inside an LVM PV, it just resizes the PV itself and -leaves the user to resize any LVs inside that PV as desired. +resize them after booting the guest. Other options are covered below. @@ -362,9 +359,9 @@ Windows will check the disk. =item * -LVM PVs (physical volumes). However virt-resize does I -resize anything inside the PV. The user will have to resize -LVs as desired. +LVM PVs (physical volumes). virt-resize does not usually resize +anything inside the PV, but see the C<--LV-expand> option. The user +could also resize LVs as desired after boot. =back @@ -443,7 +440,7 @@ The contents of the LV are also resized if virt-resize knows how to do that. You can stop virt-resize from trying to expand the content by using the option C<--no-expand-content>. -Use L to list the filesystems in +Use L to list the filesystems in the guest. You can give this option multiple times, I it doesn't @@ -516,6 +513,36 @@ my $quiet; Don't print the summary. +=cut + +my $format; + +=item B<--format> raw + +Specify the format of the input disk image. If this flag is not +given then it is auto-detected from the image itself. + +If working with untrusted raw-format guest disk images, you should +ensure the format is always specified. + +Note that this option I affect the output format. +See L. + +=cut + +my $output_format; + +=item B<--output-format> raw + +Specify the format of the output disk image. If this flag is not +given then it is auto-detected from the image itself. + +If working with untrusted raw-format guest disk images, you should +ensure the format is always specified. + +Note that you still need to create the output disk with the right +format. See L. + =back =cut @@ -535,6 +562,8 @@ GetOptions ("help|?" => \$help, "d|debug" => \$debug, "n|dryrun|dry-run" => \$dryrun, "q|quiet" => \$quiet, + "format=s" => \$format, + "output-format=s" => \$output_format, ) or pod2usage (2); pod2usage (1) if $help; if ($version) { @@ -562,8 +591,13 @@ sub launch_guestfs { $g = Sys::Guestfs->new (); $g->set_trace (1) if $debug; - $g->add_drive_ro ($infile); - $g->add_drive ($outfile); + my @args = ($infile); + push @args, readonly => 1; + push @args, format => $format if defined $format; + $g->add_drive_opts (@args); + @args = ($outfile); + push @args, format => $output_format if defined $output_format; + $g->add_drive_opts (@args); $g->set_progress_callback (\&progress_callback) unless $quiet; $g->launch (); } @@ -1204,7 +1238,9 @@ sub restart_appliance $g = Sys::Guestfs->new (); $g->set_trace (1) if $debug; - $g->add_drive ($outfile); + my @args = ($outfile); + push @args, format => $output_format if defined $output_format; + $g->add_drive_opts (@args); $g->launch (); # Target partitions have changed from /dev/sdb to /dev/sda, @@ -1355,7 +1391,7 @@ sub canonicalize { local $_ = shift; - if (m{^/dev/[hv]d([a-z]\d)$}) { + if (m{^/dev/[hv]d([a-z]\d*)$}) { return "/dev/sd$1"; } $_; @@ -1446,8 +1482,7 @@ manual page L for details. =head1 SEE ALSO -L, -L, +L, L, L, L,