steps to reproduce:
./run guestfish -N disk:1536M <<EOF
part-init /dev/sda mbr
part-add /dev/sda p 1 1048577
part-add /dev/sda p 1048578 2097154
part-add /dev/sda p 2097155 -1
mkfs ext2 /dev/sda1
mkfs ext2 /dev/sda2
mkfs ext2 /dev/sda3
EOF
qemu-img create -f raw test2.img 1520M
./run virt-resize --format raw --output-format raw --resize /dev/sda1=-2M --resize
/dev/sda2=-8M --shrink /dev/sda3 --no-extra-partition test1.img test2.img
The output:
---8<---
Formatting 'test2.img', fmt=raw size=1593835520
[ 0.0] Examining test1.img
100%
⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧
--:--
**********
Summary of changes:
/dev/sda1: This partition will be resized from 512.0M to 510.0M. The
filesystem ext2 on /dev/sda1 will be expanded using the 'resize2fs' method.
/dev/sda2: This partition will be resized from 512.0M to 504.0M. The
filesystem ext2 on /dev/sda2 will be expanded using the 'resize2fs' method.
/dev/sda3: This partition will be resized from 512.0M to 503.7M. The
filesystem ext2 on /dev/sda3 will be expanded using the 'resize2fs' method.
**********
[ 10.0] Setting up initial partition table on test2.img
[ 10.0] Copying /dev/sda1
[ 11.0] Copying /dev/sda2
[ 12.0] Copying /dev/sda3
[ 17.0] Expanding /dev/sda1 using the 'resize2fs' method
virt-resize: error: libguestfs error: resize2fs: e2fsck 1.42.11
(09-Jul-2014)
The filesystem size (according to the superblock) is 131072 blocks
The physical size of the device is 130575 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort? yes
If reporting bugs, run virt-resize with debugging enabled and include the
complete output:
virt-resize -v -x [...]
--->8---
This is a quick fix, but I am not sure it's correct or not:
diff --git a/resize/resize.ml b/resize/resize.ml
index ca5f87d..970ec03 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -666,10 +666,9 @@ read the man page virt-resize(1).
error (f_"%s: This partition contains an LVM physical volume which will be
damaged by shrinking it below %Ld bytes (user asked to shrink it to %Ld bytes). If you
want to shrink this partition, you need to use the '--resize-force' option, but
that could destroy any data on this partition. (This error came from '%s' option
on the command line.)")
name size newsize option
| ContentPV _ -> ()
- | ContentFS (fstype, size) when size > newsize ->
+ | ContentFS (fstype, _) ->
error (f_"%s: This partition contains a %s filesystem which will be
damaged by shrinking it below %Ld bytes (user asked to shrink it to %Ld bytes). If you
want to shrink this partition, you need to use the '--resize-force' option, but
that could destroy any data on this partition. (This error came from '%s' option
on the command line.)")
- name fstype size newsize option
- | ContentFS _ -> ()
+ name fstype oldsize newsize option
| ContentExtendedPartition ->
error (f_"%s: This extended partition contains logical partitions which
might be damaged by shrinking it. If you want to shrink this partition, you need to use
the '--resize-force' option, but that could destroy logical partitions within this
partition. (This error came from '%s' option on the command line.)")
name option
Regards,
Hu