Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 584057 - [RHEL-5] parted mkpartfs command does not handle partition >2TB
[RHEL-5] parted mkpartfs command does not handle partition >2TB
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: parted (Show other bugs)
5.5
i686 Linux
high Severity high
: rc
: ---
Assigned To: Brian Lane
Release Test Team
:
Depends On:
Blocks: 590060 726828 585159
  Show dependency treegraph
 
Reported: 2010-04-20 12:22 EDT by Martin Poole
Modified: 2012-02-21 00:43 EST (History)
5 users (show)

See Also:
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 00:43:24 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
patch for block overflow (1.01 KB, patch)
2010-04-20 12:24 EDT, Martin Poole
no flags Details | Diff


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2012:0192 normal SHIPPED_LIVE parted bug fix update 2012-02-20 09:54:22 EST

  None (edit)
Description Martin Poole 2010-04-20 12:22:23 EDT
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 12:24:21 EDT
Created attachment 407866 [details]
patch for block overflow
Comment 3 Jim Meyering 2010-04-21 03:25:16 EDT
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 04:06:22 EDT
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 05:34:32 EDT
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 06:15:25 EDT
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 11:55:05 EDT
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 07:30:37 EDT
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 11:11:47 EDT
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 05:05:39 EDT
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 06:08:06 EDT
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 11:33:59 EDT
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 David Cantrell 2010-07-01 21:13:52 EDT
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 17:25:01 EST
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 Product and Program Management 2011-08-05 08:34:49 EDT
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 08:39:58 EDT
    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 09:22:42 EST
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 00:43:24 EST
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

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