Bug 685009

Summary: Got error when expanding ntfs filesystem
Product: Red Hat Enterprise Linux 6 Reporter: Yufang Zhang <yuzhang>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: jzheng, leiwang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.7.17-23.el6 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 10:31:26 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yufang Zhang 2011-03-15 03:30:46 UTC
Description of problem:
Got error when expanding ntfs filesystem via ntfsresize, while shrinking does work.

Version-Release number of selected component (if applicable):
><fs> version
major: 1
minor: 7
release: 17
extra: 

How reproducible:
Always

Steps to Reproduce:

1. make ntfs filesystem and get filesystem size:

><fs> mkfs ntfs /dev/vda1
libguestfs: trace: mkfs "ntfs" "/dev/vda1"
libguestfs: trace: mkfs = 0

><fs> mount /dev/vda1 /
libguestfs: trace: mount "/dev/vda1" "/"
libguestfs: trace: mount = 0

><fs> statvfs /
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
bsize: 4096
frsize: 4096
blocks: 25584
bfree: 24959
bavail: 24959
files: 132604
ffree: 132585
favail: 132585
fsid: 0
flag: 0
namemax: 255

2. shrink filesystem size to half of the original size:

><fs> umount /
libguestfs: trace: umount "/"
libguestfs: trace: umount = 0

><fs> ntfsresize-size /dev/vda1 52396032
libguestfs: trace: ntfsresize_size "/dev/vda1" 52396032
libguestfs: trace: ntfsresize_size = 0

3. make sure filesystem size shrinks as requested:

><fs> mount /dev/vda1 /
libguestfs: trace: mount "/dev/vda1" "/"
libguestfs: trace: mount = 0

><fs> statvfs /
libguestfs: trace: statvfs "/"
libguestfs: trace: statvfs = <struct guestfs_statvfs *>
bsize: 4096
frsize: 4096
blocks: 12791
bfree: 12166
bavail: 12166
files: 81432
ffree: 81413
favail: 81413
fsid: 0
flag: 0
namemax: 255

4. try to expand filesystem size to original size via ntfsresize

><fs> umount /
libguestfs: trace: umount "/"
libguestfs: trace: umount = 0

><fs> ntfsresize /dev/vda1
libguestfs: trace: ntfsresize "/dev/vda1"
libguestfs: trace: ntfsresize = -1 (error)
libguestfs: error: ntfsresize: /dev/vda1: 

  
Actual results:
Got error when expanding ntfs filesystem size.

Expected results:

Additional info:

Comment 1 Yufang Zhang 2011-03-15 03:42:00 UTC
Another issue to take notice. When shrinking the ntfs filesystem, filesystem size specified in ntfsresize-size is 52396032 bytes, which is 12792 blocks. But statvfs reports block counts is 12791, which is one block less than requested. Is is a problem? (I didn't file another bug for this issue for it is a minor one.)

Comment 2 Richard W.M. Jones 2011-03-15 08:50:47 UTC
I'll have a closer look later, but I think this is
by design -- the ntfsresize utility cannot resize the
same filesystem twice in a row without the VM being
rebooted and checked (ie. chkdsk/scandisk).

It will probably work if you boot the VM and let it
do the check between resizes.

Comment 3 Richard W.M. Jones 2011-06-10 09:33:39 UTC
I'm going to investigate this for 6.2.  I think
comment 2 is the correct analysis, but this limitation
in ntfsresize should be documented.

Comment 4 Richard W.M. Jones 2011-07-12 13:16:48 UTC
Patch posted:
https://www.redhat.com/archives/libguestfs/2011-July/msg00023.html

Comment 6 Richard W.M. Jones 2011-08-10 12:43:47 UTC
I've included the documentation fix in
libguestfs-1.7.17-23.el6.

The other two commits can't be easily applied to RHEL 6.2
because virt-resize was rewritten from Perl -> OCaml between
1.8 and 1.12.  In RHEL 6.3 we may rebase libguestfs, so we will
get those two commits as well.

Comment 8 Jinxin Zheng 2011-08-18 09:45:58 UTC
Checked in libguestfs-1.7.17-26, the following info is documented in ntfsresize's help.

    *Note:* After the resize operation, the filesystem is marked as
    requiring a consistency check (for safety). You have to boot into
    Windows to perform this check and clear this condition. Furthermore,
    ntfsresize refuses to resize filesystems which have been marked in this
    way. So in effect it is not possible to call ntfsresize multiple times
    on a single filesystem without booting into Windows between each resize.

Comment 9 errata-xmlrpc 2011-12-06 10:31:26 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1512.html