Bug 975753

Summary: "virt-resize --expand" and "virt-resize --resize" outputs error message for Win2008 32bit OS
Product: Red Hat Enterprise Linux 6 Reporter: bfan
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.5CC: bfan, leiwang, wshi
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libguestfs-1.20.9-5.el6 Doc Type: Bug Fix
Doc Text:
Cause: virt-resize fails on Windows guests that are in an inconsistent state (ie. need a CHKDSK). Consequence: You cannot resize such guests. Fix: No fix, the problem is documented in the man page instead.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-11-21 04:45:15 UTC 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:
Attachments:
Description Flags
command log with debug info
none
debug output none

Description bfan 2013-06-19 09:31:02 UTC
Created attachment 762816 [details]
command log with debug info

Description of problem:
"virt-resize --expand" and "virt-resize --resize" outputs error message for Win2008 32bit OS, but can get the expected partition in new disk.


Version-Release number of selected component (if applicable):
libguestfs-1.20.8-5.el6.x86_64

How reproducible:
100%


Steps to Reproduce:
# for virt-resize --expand
[root]# virt-list-partitions -lh Win2008-32-hvm.raw
/dev/sda1 ntfs 14.6G
[root]# qemu-img create new_Win2008-32 15.6G
Formatting 'newWin2008-32', fmt=raw size=16750372454
[root]# virt-resize --expand /dev/sda1 Win2008-32-hvm.raw new_Win2008-32

# for virt-resize --resize
[root]# virt-list-partitions -lh Win2008-32-hvm.raw
/dev/sda1 ntfs 14.6G
[root]# qemu-img create newWin2008-32 15.6G
Formatting 'newWin2008-32', fmt=raw size=16750372454
[root]# virt-resize --resize /dev/sda1=+200M Win2008-32-hvm.raw newWin2008-32


Actual results:
Copying /dev/sda1 ...
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
Expanding /dev/sda1 using the 'ntfsresize' method ...
Fatal error: exception Guestfs.Error("ntfsresize: command failed: yes | ntfsresize -P /dev/sda1 (enable debug to see the full error message)")


Expected results:
Copying /dev/sda1 ...
 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ --:--
Expanding /dev/sda1 using the 'ntfsresize' method ...

Resize operation completed with no errors.  Before deleting the old
disk, carefully check that the resized disk boots and works correctly.


Additional info:
1. Can get the expected partition in new disk though command outputs error message
2. It works with Win2008 64bit OS and other OS
3. It works in rhel7 (libguestfs-1.22.2-1.el7)

Comment 1 Richard W.M. Jones 2013-06-19 09:51:48 UTC
Is libguestfs-winsupport installed?

If so, can you enable debugging so we get to see the
actual error message.
http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs

Comment 2 Richard W.M. Jones 2013-06-19 09:52:53 UTC
BTW if libguestfs-winsupport wasn't installed, this would
still be a bug -- we'd want to improve the error message.

Comment 3 bfan 2013-06-19 10:03:38 UTC
(In reply to Richard W.M. Jones from comment #1)
> Is libguestfs-winsupport installed?
> 
> If so, can you enable debugging so we get to see the
> actual error message.
> http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs

Yes, libguestfs-winsupport already installed, It works for Win2008 64bit OS

Comment 4 Richard W.M. Jones 2013-06-19 19:08:37 UTC
(In reply to bfan from comment #3)
> (In reply to Richard W.M. Jones from comment #1)
> > Is libguestfs-winsupport installed?
> > 
> > If so, can you enable debugging so we get to see the
> > actual error message.
> > http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
>
> Yes, libguestfs-winsupport already installed.

OK, I still however need to see the debug output.

> It works for Win2008 64bit OS.

Strange ...  However there are lots of ways that ntfsresize
can fail.  Most commonly because the disk wasn't shut down
cleanly and ntfsresize refuses the resize disks that need
a chkdsk.  Unfortunately in Win8 this is the default ...

Comment 5 bfan 2013-06-20 02:48:29 UTC
Created attachment 763195 [details]
debug output

Comment 6 bfan 2013-06-20 02:50:17 UTC
(In reply to Richard W.M. Jones from comment #4)
> (In reply to bfan from comment #3)
> > (In reply to Richard W.M. Jones from comment #1)
> > > Is libguestfs-winsupport installed?
> > > 
> > > If so, can you enable debugging so we get to see the
> > > actual error message.
> > > http://libguestfs.org/guestfs-faq.1.html#debugging-libguestfs
> >
> > Yes, libguestfs-winsupport already installed.
> 
> OK, I still however need to see the debug output.
> 
> > It works for Win2008 64bit OS.
> 
> Strange ...  However there are lots of ways that ntfsresize
> can fail.  Most commonly because the disk wasn't shut down
> cleanly and ntfsresize refuses the resize disks that need
> a chkdsk.  Unfortunately in Win8 this is the default ...

[root]# cat test.sh 
virt-list-partitions -lh Win2008-32-hvm.raw
qemu-img create new_Win2008-32 15.6G
export LIBGUESTFS_DEBUG=1
export LIBGUESTFS_TRACE=1
virt-resize --expand /dev/sda1 Win2008-32-hvm.raw new_Win2008-32
[root]# bash test.sh > output.log 2>&1

Comment 7 bfan 2013-06-20 06:36:04 UTC
According to the debug info, do "chkdsk /f" on Windows, then virt-resize again, works well.

Comment 8 Richard W.M. Jones 2013-06-20 08:06:41 UTC
I'll put a note in the manual about this.

Comment 12 bfan 2013-07-01 02:40:45 UTC
Verified with libguestfs-1.20.9-5.el6

Found this section in virt-resize man page

"
   WINDOWS CHKDSK
       Windows disks which use NTFS must be consistent before virt-resize can be used.  If the ntfsresize operation fails, try booting the original VM and
       running "chkdsk /f" on all NTFS partitions, then shut down the VM cleanly.  For further information see:
       https://bugzilla.redhat.com/show_bug.cgi?id=975753

       After resize Windows may initiate a lengthy "chkdsk" on first boot if NTFS partitions have been expanded.  This is just a safety check and (unless
       it find errors) is nothing to worry about.
"

Change the status to verified

Comment 17 errata-xmlrpc 2013-11-21 04:45:15 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/RHSA-2013-1536.html