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
Richard W.M. Jones
2014-Dec-22 09:03 UTC
Re: [Libguestfs] virt-resize corrupts ext2 filesystem
On Tue, Dec 16, 2014 at 03:16:49PM +0800, Hu Tao wrote:> 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---I can reproduce this too. I don't have time to look at this now, but to make sure it's not forgotten, I have filed a bug about it: https://bugzilla.redhat.com/show_bug.cgi?id=1176526 Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Seemingly Similar Threads
- [PATCH 2/2] resize: shrink/expand swap partitions
- [PATCH v2 2/2] resize: expand f2fs partitions
- [PATCH v3 7/7] resize: add support to resize logical partitions
- [PATCH V5 2/4] resize: add support to resize logical partitions
- [PATCH 1/2] daemon: allow to change the labels of swap partitions