RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 971326 - ntfsresize-opts execute failed when omitted the 'size' option
Summary: ntfsresize-opts execute failed when omitted the 'size' option
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libguestfs
Version: 6.5
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: Richard W.M. Jones
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-06-06 09:33 UTC by bfan
Modified: 2013-11-21 04:44 UTC (History)
2 users (show)

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.
Clone Of:
Environment:
Last Closed: 2013-11-21 04:44:29 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2013:1536 0 normal SHIPPED_LIVE Moderate: libguestfs security, bug fix, and enhancement update 2013-11-21 00:40:55 UTC

Description bfan 2013-06-06 09:33:17 UTC
Description of problem:
Once the disk has been resized before, ntfsresize-opts will execute failed without the "size" option

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

How reproducible:
100%

Steps to Reproduce:
$ guestfish -N fs:ntfs
><fs> ntfsresize-opts /dev/sda1 size:104693760 force:true
><fs> ntfsresize-opts /dev/sda1 force:true
libguestfs: error: ntfsresize: /dev/sda1:

but if not do anything before, it can work, like
$ guestfish -N fs:ntfs
><fs> ntfsresize-opts /dev/sda1 force:true


 
Actual results:
libguestfs: error: ntfsresize: /dev/sda1:


Expected results:
command works


Additional info:
It works with libguestfs-1.22.2-1.el7.x86_64 in rhel7

Comment 3 Richard W.M. Jones 2013-06-06 11:03:47 UTC
(In reply to bfan from comment #0)
> libguestfs: error: ntfsresize: /dev/sda1:
> 

Another bug is that the error message is empty.

Comment 4 Richard W.M. Jones 2013-06-06 13:50:23 UTC
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.

Comment 5 Richard W.M. Jones 2013-06-06 14:01:15 UTC
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.

Comment 6 Richard W.M. Jones 2013-06-06 15:50:09 UTC
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.

Comment 7 Richard W.M. Jones 2013-06-07 11:26:30 UTC
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.

Comment 9 bfan 2013-06-17 07:31:21 UTC
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

Comment 11 errata-xmlrpc 2013-11-21 04:44:29 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


Note You need to log in before you can comment on or make changes to this bug.