growpart on disk larger than 2TB fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-utils |
Fix Released
|
Medium
|
Scott Moser | ||
cloud-utils (Ubuntu) |
Fix Released
|
Medium
|
Scott Moser | ||
Precise |
Fix Released
|
Medium
|
Scott Moser | ||
Saucy |
Fix Released
|
Medium
|
Scott Moser |
Bug Description
=== Begin SRU Information ===
[Impact]
If growpart is run on a disk that is larger than 2 Terabytes and an MBR
partition table, then the partition table will not be updated correctly.
The result is that the partition can actually be shrunk, which breaks the
filesystem on the disk.
[Test Case]
To test, you need a block device > 2TB or a file > 2TB.
Because of sparse files, you can easily create one on local filesystem.
Below, an actual block device can be used just as well.
## Create a file that is 2.5TB.
$ dev="/tmp/my.img"
$ truncate --size 2500G $dev
## if 'dev' is a file, then 'update' wont work. In upstream trunk it will
## not attempt to run partx on a file. update only exists in saucy or later.
[ -b "$dev" -a "$(lsb_release -sc)" != "precise" ] &&
update_
## upstream cloud-utils, but broken
## use sfdisk to partition it with a 500GB first partition
## then show that that generally worked
$ echo "2048,$
$ sfdisk --unit S -l $dev 2>/dev/null | grep "${dev}1"
/tmp/my.img1 2048 1048578047 1048576000 83 Linux
## use growpart to grow the partition
## then verify it worked. We should see a ~2TB partition size
$ growpart ${update_f} /tmp/my.img 1
CHANGED: partition=1 start=2048 old: size=1048576000 end=1048578048 new: size=4294965248
$ sfdisk --unit S -l $dev 2>/dev/null | grep "${dev}1"
/tmp/my.img1 2048 4294967295 4294965248 83 Linux
## When this failed, it would fail like this:
## the new 'size' is > 2TB and thus invalid. And sfdisk -l would show
## the bad table.
$ growpart ${update_f} /tmp/my.img 1
CHANGED: partition=1 start=2048 old: size=1048576000 end=1048578048 new: size=5242874962
$ sfdisk --unit S -l $dev 2>/dev/null | grep "${dev}1"
/tmp/my.img1 2048 947909713 947907666 83 Linux
[Regression Potential]
Regression potential is little to none.
This was 100% broken with disks over 2TB previously.
The code now checks if the new size would be greater than 2TB. If it is, it
just limits the size to 2TB.
=== End SRU Information ===
For disks larger than 2TB (the amount addressable by MBR), growpart will mess up partition tables.
It also fails in such a way that it ends up shrinking the partition table, see below for an example.
In reality, this is probably an sfdisk bug, but I can work around it in growpart by just knowing the max size.
$ sudo growpart -v --dry-run /dev/sdb 1
geometry is -C 364801 -H 255 -S 63. total size=5860528065
max_end=5860528065 tot=5860528065 pt_end=209715200 pt_start=2048 pt_size=209713152
CHANGE: partition=1 start=2048 old: size=209713152 end=209715200 new: size=5860526017
# === old sfdisk -d ===
# partition table of /dev/sdb
unit: sectors
/dev/sdb1 : start= 2048, size=209713152, Id=83, bootable
/dev/sdb2 : start= 0, size= 0, Id= 0
/dev/sdb3 : start= 0, size= 0, Id= 0
/dev/sdb4 : start= 0, size= 0, Id= 0
# === new sfdisk -d ===
# partition table of /dev/sdb
unit: sectors
/dev/sdb1 : start= 2048, size=5860526017, Id=83, bootable
/dev/sdb2 : start= 0, size= 0, Id= 0
/dev/sdb3 : start= 0, size= 0, Id= 0
/dev/sdb4 : start= 0, size= 0, Id= 0
$ sudo growpart /dev/sdb 1
CHANGED: partition=1 start=2048 old: size=209713152 end=209715200 new: size=5860526017
$ grep "sdb" /proc/partitions
8 16 2930266584 sdb
8 17 782779360 sdb1
$ sudo sfdisk -l /dev/sdb -u -S
unrecognized format - using sectors
Disk /dev/sdb: 364801 cylinders, 255 heads, 63 sectors/track
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/sdb1 * 2048 1565560768 1565558721 83 Linux
/dev/sdb2 0 - 0 0 Empty
/dev/sdb3 0 - 0 0 Empty
/dev/sdb4 0 - 0 0 Empty
ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: cloud-utils 0.25-0ubuntu5
ProcVersionSign
Uname: Linux 3.2.0-57-generic x86_64
ApportVersion: 2.0.1-0ubuntu17.6
Architecture: amd64
Date: Tue Dec 10 21:28:44 2013
MarkForUpload: True
PackageArchitec
ProcEnviron:
TERM=screen
PATH=(custom, no user)
LANG=en_US.UTF-8
SHELL=/bin/bash
SourcePackage: cloud-utils
UpgradeStatus: No upgrade log present (probably fresh install)
description: | updated |
Changed in cloud-utils (Ubuntu Precise): | |
status: | New → In Progress |
Changed in cloud-utils (Ubuntu Saucy): | |
status: | New → In Progress |
Changed in cloud-utils (Ubuntu Precise): | |
importance: | Undecided → Medium |
Changed in cloud-utils (Ubuntu Saucy): | |
importance: | Undecided → Medium |
Changed in cloud-utils (Ubuntu): | |
importance: | Undecided → Medium |
assignee: | nobody → Scott Moser (smoser) |
Changed in cloud-utils (Ubuntu Precise): | |
assignee: | nobody → Scott Moser (smoser) |
Changed in cloud-utils (Ubuntu Saucy): | |
assignee: | nobody → Scott Moser (smoser) |
description: | updated |
fixed in trunk at revision 250.