Bug 971326
Summary: | ntfsresize-opts execute failed when omitted the 'size' option | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 6 | Reporter: | bfan |
Component: | libguestfs | Assignee: | Richard W.M. Jones <rjones> |
Status: | CLOSED ERRATA | QA Contact: | Virtualization Bugs <virt-bugs> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 6.5 | CC: | leiwang, wshi |
Target Milestone: | rc | Keywords: | Regression |
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | libguestfs-1.20.8-4.el6 | Doc Type: | Bug Fix |
Doc Text: |
Cause: Resizing a Windows NTFS filesystem without specifying the target (final) size.
Consequence: The operation would fail.
Fix: The code for resizing NTFS filesystems has been fixed.
Result: You can now resize an NTFS filesystem without specifying the size, and the size is taken automatically from the target disk.
|
Story Points: | --- |
Clone Of: | Environment: | ||
Last Closed: | 2013-11-21 04:44:29 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: |
Description
bfan
2013-06-06 09:33:17 UTC
(In reply to bfan from comment #0) > libguestfs: error: ntfsresize: /dev/sda1: > Another bug is that the error message is empty. Upstream: $ ./run ./fish/guestfish -N fs:ntfs ntfsresize-opts /dev/sda1 size:104693760 force:true : ntfsresize-opts /dev/sda1 force:true [no errors] $ ./run ./fish/guestfish -N fs:ntfs ntfsresize-opts /dev/sda1 force:true [no errors] RHEL 6.5: $ guestfish -N fs:ntfs ntfsresize-opts /dev/sda1 size:104693760 force:true : ntfsresize-opts /dev/sda1 force:true libguestfs: error: ntfsresize: /dev/sda1: $ guestfish -N fs:ntfs ntfsresize-opts /dev/sda1 force:true [no errors] The commands being run (in the failing case) are: mkfs -t ntfs -Q /dev/sda1 ntfsresize -P --size 104693760 --force /dev/sda1 ntfsresize -P --force /dev/sda1 You can't see the error in guestfish, so using virt-rescue instead: ><rescue> mkfs -t ntfs -Q /dev/sda1 Cluster size has been automatically set to 4096 bytes. Creating NTFS volume structures. mkntfs completed successfully. Have a nice day. ><rescue> ntfsresize -P --size 104693760 --force /dev/sda1 ntfsresize v2.0.0 (libntfs 10:0:0) Device name : /dev/sda1 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 10737398272 bytes (10738 MB) Current device size: 10737401856 bytes (10738 MB) New volume size : 104690176 bytes (105 MB) Checking filesystem consistency ... Accounting clusters ... Space in use : 55 MB (0.5%) Collecting resizing constraints ... Needed relocations : 13209 (55 MB) Schedule chkdsk for NTFS consistency check at Windows boot time ... Resetting $LogFile ... (this might take a while) Relocating needed data ... Updating $BadClust file ... Updating $Bitmap file ... Updating Boot record ... Syncing device ... Successfully resized NTFS on device '/dev/sda1'. You can go on to shrink the device for example with Linux fdisk. IMPORTANT: When recreating the partition, make sure that you 1) create it at the same disk sector (use sector as the unit!) 2) create it with the same partition type (usually 7, HPFS/NTFS) 3) do not make it smaller than the new NTFS filesystem size 4) set the bootable flag for the partition if it existed before Otherwise you won't be able to access NTFS or can't boot from the disk! If you make a mistake and don't have a partition table backup then you can recover the partition table by TestDisk or Parted's rescue mode. ><rescue> ntfsresize -P --force /dev/sda1 ntfsresize v2.0.0 (libntfs 10:0:0) Device name : /dev/sda1 NTFS volume version: 3.1 Cluster size : 4096 bytes Current volume size: 104690176 bytes (105 MB) Current device size: 10737401856 bytes (10738 MB) New volume size : 10737398272 bytes (10738 MB) Checking filesystem consistency ... Accounting clusters ... Space in use : 55 MB (51.7%) Collecting resizing constraints ... WARNING: Every sanity check passed and only the dangerous operations left. Make sure that important data has been backed up! Power outage or computer crash may result major data loss! Are you sure you want to proceed (y/[n])? <<<<----- ntfsresize waits for input at the marked place, which obviously libguestfs/guestfish cannot provide. This is a bug in old ntfs-3g. Fixing it would require a rebase to the newer upstream version. Trying a slightly different test in virt-rescue. By redirecting
/dev/null into the last command I can (probably) simulate what
libguestfs does when there is no keyboard input:
><rescue> mkfs -t ntfs -Q /dev/sda1
><rescue> ntfsresize -P --size 104693760 --force /dev/sda1
><rescue> ntfsresize -P --force /dev/sda1 </dev/null
Now (both upstream and on RHEL 6.5), the last command
performs the resize anyway:
[...]
Are you sure you want to proceed (y/[n])? Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/sda1'.
This may indicate that upstream libguestfs effectively
sets stdin to /dev/null whereas RHEL 6.5 libguestfs does not.
I don't understand what's happening, but there are various issues. I checked and libguestfs on RHEL 6.5 does set stdin of the ntfsresize process to /dev/null. This is a bug in ntfsresize (RHEL 6.5) which has been fixed upstream: The question dialog does: printf("Are you sure you want to proceed (y/[n])? "); buf[0] = 0; fgets(buf, sizeof(buf), stdin); if (!strchr(short_yes, buf[0])) { printf("OK quitting. NO CHANGES have been made to your " "NTFS volume.\n"); exit(1); } If the input is /dev/null, then buf[0] will contain \0 and so the code does strchr("Yy", '\0'). If you read the man page for strchr closely you'll see this is a strange corner-case which returns non-NULL. This explains why using the explicit redirect </dev/null works to shortcircuit this dialog. It doesn't explain why libguestfs isn't behaving the same way when it reopens stdin as /dev/null for the subprocess. I added a workaround for this to the libguestfs 1.20.8-4.el6 package. Can't add this to the bug because it's not acked. Verified with libguestfs-1.20.8-5.el6.x86_64
# guestfish -N fs:ntfs
Welcome to guestfish, the libguestfs filesystem interactive shell for
editing virtual machine filesystems.
Type: 'help' for help on commands
'man' to read the manual
'quit' to quit the shell
><fs> ntfsresize-opts /dev/sda1 size:104693760 force:true
><fs> ntfsresize-opts /dev/sda1 force:true
><fs>
So, change the status to verified
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 |