Hide Forgot
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:
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.)
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.
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.
Patch posted: https://www.redhat.com/archives/libguestfs/2011-July/msg00023.html
The basic (documentation only) fix is: http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=2ba2ddf2113db7bb2afe3f739dc3cbaa5416a4ba The following two commits could also be considered: http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=edd747a09060dd191277f1bcae827a94939cfb9d http://git.annexia.org/?p=libguestfs.git;a=commitdiff;h=d31de200b82ef66d7e87b32dd5345c053997cc35
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.
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.
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