sfdisk gets cylinder calculation wrong when using sectors
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
util-linux (Ubuntu) |
Fix Released
|
High
|
Unassigned | ||
Trusty |
Triaged
|
High
|
Unassigned |
Bug Description
If you try and specify the starting offset for the partition in sectors and ask sfdisk to use the rest of the disk (with "+"), sfdisk will incorrectly calculate the end cylinders and not create the partition. For example
---
# dd if=/dev/zero of=/tmp/disk.img bs=1M count=10
# losetup -f /tmp/disk.img
# sfdisk -uS /dev/loop1 <<EOF
2048 + L *
0 0;
0 0;
0 0;
EOF
Checking that no-one is using this disk right now ...
BLKRRPART: Invalid argument
OK
Disk /dev/loop1: cannot get geometry
Disk /dev/loop1: 1 cylinders, 255 heads, 63 sectors/track
sfdisk: ERROR: sector 0 does not have an msdos signature
/dev/loop1: unrecognized partition table type
Old situation:
No partitions found
New situation:
Warning: The partition table looks like it was made
for C/H/S=*/71/5 (instead of 1/255/63).
For this listing I'll assume that geometry.
Units = sectors of 512 bytes, counting from 0
Device Boot Start End #sectors Id System
/dev/loop1p1 * 2048 20479 18432 83 Linux
start: (c,h,s) expected (5,54,4) found (0,32,33)
end: (c,h,s) expected (57,48,5) found (1,70,5)
/dev/loop1p2 0 - 0 0 Empty
/dev/loop1p3 0 - 0 0 Empty
/dev/loop1p4 0 - 0 0 Empty
Warning: partition 1 does not end at a cylinder boundary
end of partition 1 has impossible value for cylinders: 1 (should be in 0-0)
sfdisk: I don't like these partitions - nothing changed.
(If you really want this, use the --force option.)
---
Using the --force flag writes out the correct partitions. I also note this is fixed in 2.26, which has a large rewrite of sfdisk and uses sectors by default
I've hit this as well. 2.26 is available in Wily, so any fixes here would be to trusty. It seems like a major rewrite wouldn't be backported in the SRU process though. So this might have to remain unfixed in the LTS unless somebody wants to ferret out the problem and make a smaller patch just for 2.20.