Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 584057

Summary: [RHEL-5] parted mkpartfs command does not handle partition >2TB
Product: Red Hat Enterprise Linux 5 Reporter: Martin Poole <mpoole>
Component: partedAssignee: Brian Lane <bcl>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: high Docs Contact:
Priority: high    
Version: 5.5CC: atodorov, bmr, hdegoede, meyering, moshiro
Target Milestone: rc   
Target Release: ---   
Hardware: i686   
OS: Linux   
Whiteboard:
Fixed In Version: parted-1.8.1-29 Doc Type: Bug Fix
Doc Text:
The mkpartfs command did not correctly handle partitions greater than 2 terabytes (TB) due to truncation of calculated block addresses. As a consequence, mkpartfs terminated with an error message. With this update, mkpartfs can now handle partitions greater than 2TB correctly.
Story Points: ---
Clone Of:
: 585159 (view as bug list) Environment:
Last Closed: 2012-02-21 05:43:24 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:
Bug Depends On:    
Bug Blocks: 585159, 590060, 726828    
Attachments:
Description Flags
patch for block overflow none

Description Martin Poole 2010-04-20 16:22:23 UTC
Description of problem:

Due to truncation of calculated block addresses the ext2 mkpartfs code does not correctly handle partitions greater than 2TB.

Version-Release number of selected component (if applicable):

  parted-1.8.1-27.el5


How reproducible:

Always.

Steps to Reproduce:
1. Use parted to create ext2 filesystem on partition >2TB
2. fsck the partition.
3.
 
Alternate with details.
 1.Just create a filesystem whose size is 2TB or more by the mkpartfs
  subcommand as follows.

 # parted /dev/sdb
...
(parted)mklabel gpt
(parted)mkpartfs primary ext2 0 -0
(parted)q

2.Get the dumpe2fs data of the above created filesystem.
 # dumpe2fs /dev/sdb1

3.Confirm Group 16384 in the dumpe2fs data.


Actual results:

errors.

Expected results:

success.

Additional info:

Comment 1 Martin Poole 2010-04-20 16:24:21 UTC
Created attachment 407866 [details]
patch for block overflow

Comment 3 Jim Meyering 2010-04-21 07:25:16 UTC
Hi Martin,

Thanks for the report.
If at all possible, please avoid using parted's FS-manipulation code, since it is nowhere near as robust as what you'll find in FS-specific packages like e2fsprogs.
Upstream has deprecated all FS-manipulation operations (you'll get a warning), and plans to remove the code altogether RSN.  The only exceptions are FAT and HFS resizing, for which there seems to be no other source of free code.

Comment 4 Hans de Goede 2010-04-21 08:06:22 UTC
Hi Martin,

As Jim explained the mkfs functionality of parted is not the best way to create filesystems. Still we cannot just take this away in RHEL-5.x, as your patch looks pretty safe to me I'm going to devel ack this and fix this for the next RHEL-5.x release.

Regards,

Hans

Comment 5 Jim Meyering 2010-04-21 09:34:32 UTC
Thanks for dealing with that, Hans.
That sounds like the right thing for 5.x.
Martin, beware that depending on FS type, stating sector, length, and probably the phase of the moon, parted's FS creation/move/check commands may malfunction in dangerously subtle (and sometimes not-so-subtle) ways.

What do you think about making RHEL-5.x parted issue a warning for the file system operations that are now deprecated upstream?  Perhaps that's too invasive.  Is there some other way to encourage people to adapt?

Comment 9 Jim Meyering 2010-04-21 10:15:25 UTC
FYI, I'm fixing this upstream, too,
and adding the following "expensive" test:

  dd bs=1 seek=2049G of=big < /dev/null
  parted -s big -- mklabel gpt mkpartfs primary ext2 2048s -0 u s p

It looks like the result will occupy at least 32GB.

Comment 11 Jim Meyering 2010-04-21 15:55:05 UTC
Martin, I tried to reproduce the failure like this:

    dd bs=1 seek=2049G of=big < /dev/null
    parted -s big -- mklabel gpt mkpartfs primary ext2 2048s -0 u s p
    sudo losetup -f -r -o $((1024*1024)) --show big
    sudo fsck.ext2 -n /dev/loop0
    sudo losetup -d /dev/loop0

Parted's FS creation inflates "big" to occupy 33GB, and for me on i686 F13, the fsck succeeded.
Of course, if you're already using /dev/loop0, you'll get a different one...

Comment 12 Hans de Goede 2010-04-23 11:30:37 UTC
I've prepared an update for this for 5.6 in my pkg checkout now all we need is the necessary flags to commit this.

Comment 13 Jim Meyering 2010-04-23 15:11:47 UTC
Martin, did fsck fail for you?
So far (using the procedure in comment 11), for me it does not.

Comment 14 Jim Meyering 2010-04-27 09:05:39 UTC
Martin, to be clear, I built parted from upstream source, following instructions at

  http://git.debian.org/?p=parted/parted.git;a=blob;f=README-hacking

then used the just-built parted in the procedure of comment 11.
With that, I was unable to reproduce the failure on i686 Fedora 13.

Does that procedure, with any version of parted, evoke a failure for you?

Comment 15 Jim Meyering 2010-04-27 10:08:06 UTC
The procedure in comment 11 is slightly misleading, since it uses "primary" as the partition name in a GPT table.  Also, it assumes that losetup ... --show prints loop0.  Here's a better procedure:

dd bs=1 seek=2049G of=big < /dev/null
parted/parted -s big -- mklabel gpt mkpartfs p1 ext2 2048s -0 u s p
loop=$(sudo losetup -f -r -o $((1024*1024)) --show big)
sudo fsck.ext2 -n $loop
sudo losetup -d $loop
env rm big

For reference, here's most of the output I get on i686.  Note, whereas the above was with F13, this is with F12:

---------------------------------------
$ parted/parted -s big -- mklabel gpt mkpartfs p1 ext2 2048s -0 u s p
WARNING: you are attempting to use parted to operate on (mkpartfs)...
...

Model:  (file)
Disk /home/meyering/w/co/parted/parted/big: 4297064448s
Sector size (logical/physical): 512B/512B
Partition Table: gpt

Number  Start  End          Size         File system  Name     Flags
 1      2048s  4297064414s  4297062367s  ext2         primary

$ sudo losetup -f -r -o $((1024*1024)) --show big
[sudo] password for meyering:
/dev/loop0
$ sudo fsck.ext2 -n /dev/loop0
e2fsck 1.41.9 (22-Aug-2009)
/dev/loop0: clean, 11/268566528 files, 8428101/537132795 blocks
$ sudo losetup -d /dev/loop0
$ env rm big

Comment 16 Jim Meyering 2010-05-05 15:33:59 UTC
fsck's -f option was the missing piece, as martin suggested on IRC.
This reproduces the problem:

dd bs=1 seek=2049G of=big < /dev/null
parted/parted -s big -- mklabel gpt mkpartfs p1 ext2 2048s -0 u s p
loop=$(sudo losetup -f -o $((1024*1024)) --show big)
sudo fsck.ext2 -f $loop
sudo losetup -d $loop
env rm big

So I'll apply the patch shortly.  Thanks again, Martin.

Not sure if I'll add such an expensive (in disk space and time) test.

Comment 17 Dave Cantrell 2010-07-02 01:13:52 UTC
Moving to 5.7 proposed list since parted did not make the approved component list for 5.6.

Comment 22 Brian Lane 2011-02-21 22:25:01 UTC
Moving to 5.8, the patch is already in upstream and we have a clear reproducer. This should not be taken as an endorsement of the parted fs code -- just don't use it.

Comment 26 RHEL Program Management 2011-08-05 12:34:49 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 27 Eliska Slobodova 2011-09-20 12:39:58 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
The mkpartfs command did not correctly handle partitions greater than 2 terabytes (TB) due to truncation of calculated block addresses. As a consequence, mkpartfs terminated with an error message. With this update, mkpartfs can now handle partitions greater than 2TB correctly.

Comment 29 Alexander Todorov 2011-12-14 14:22:42 UTC
Reproduced on 5.7 KVM guest / parted-1.8.1-28.el5

1) dd bs=1 seek=2049G of=big.img < /dev/null
2) Attach bitg.img as second disk to the guest and start it
3)
# parted /dev/vdb
...
(parted)mklabel gpt
(parted)mkpartfs primary ext2 0 -0
(parted)q

4) 
# fsck.ext2 -f /dev/vdb1 
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
Block bitmap differences:  +(536870912--536870913) +(536871044--536871555) +(536903680--536903681) +(536903812--536904323) +(536936448--536936449) +(536936580--536937091) +(536969216--536969217) +(536969348--536969859) +(537001984--537001985) +(537002116--537002627) +(537034752--537034753) +(537034884--537035395) +(537067520--537067521) +(537067652--537068163) +(537100288--537100289) +(537100420--537100931)
Fix<y>? yes


/dev/vdb1: ***** FILE SYSTEM WAS MODIFIED *****
/dev/vdb1: 11/268566528 files (0.0% non-contiguous), 8428101/537133047 blocks


Re-tested on RHEL 5.8 KVM guest / parted-1.8.1-29.el5

4) 
# fsck.ext2 -f /dev/vdb1 
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vdb1: 11/268566528 files (0.0% non-contiguous), 8428101/537133047 blocks


No errors reported. Moving to VERIFIED.

Comment 30 errata-xmlrpc 2012-02-21 05:43:24 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-2012-0192.html