Bug 1176526

Summary: virt-resize cannot shrink ext filesystem by a small amount
Product: [Community] Virtualization Tools Reporter: Richard W.M. Jones <rjones>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: NEW --- QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: ptoscano
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Richard W.M. Jones 2014-12-22 09:02:10 UTC
Description of problem:

(Note: reported by Hu Tao here:
https://www.redhat.com/archives/libguestfs/2014-December/msg00160.html )

When you shrink a filesystem by a small amount (eg. -8 MB)
using virt-resize, it cannot cope, giving the following error:

[  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

Version-Release number of selected component (if applicable):

libguestfs latest from git

How reproducible:

100%

Steps to Reproduce:

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

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

Actual results:

[   0.0] Examining test1.img
**********

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.

**********
[   3.0] Setting up initial partition table on test2.img
[   3.0] Copying /dev/sda1
[   4.0] Copying /dev/sda2
[   5.0] Copying /dev/sda3
[   9.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 [...]


Expected results:

Should succeed.