The size of disk in the sfdisk command is based on number of cylinders
(this is probably legacy from CHS epoch). That's wrong because
partitions are addressed in sectors (LBA), so cylinders don't provide
necessary resolution (granularity).
On Sat, Jan 02, 2010 at 01:01:16PM +0100, Giulio wrote:
> $ cat /sys/block/sda/size
>
184549376
>
> $ sfdisk -d /dev/sda > part.dump
> $ cat part.dump
> # partition table of /dev/sda
> unit: sectors
>
> /dev/sda1 : start= 2048, size=
2097152, Id=83
> /dev/sda2 : start=
2099200, size=
12582912, Id=83
> /dev/sda3 : start=
14682112, size=
84934656, Id=83
> /dev/sda4 : start=
99616768, size=
84932608, Id=83
>
>
> $ sfdisk -L /dev/sda < part.dump
> Checking that no-one is using this disk right now ...
> OK
>
> Disk /dev/sda: 11487 cylinders, 255 heads, 63 sectors/track
> Old situation:
> Units = cylinders of
8225280 bytes, blocks of 1024 bytes, counting from 0
>
> Device Boot Start End #cyls #blocks Id System
> /dev/sda1 0+ 130- 131-
1048576 83 Linux
> /dev/sda2 130+ 913- 784-
6291456 83 Linux
> /dev/sda3 913+ 6200- 5287-
42467328 83 Linux
> /dev/sda4 6200+ 11487- 5287-
42466304 83 Linux
> Warning: given size (
84932608) exceeds max allowable size (
84921887)
disk size:
based on number of cylinders: 11487 *
8225280 =
94483791360 bytes
based on number of sectors:
184549376 * 512 =
94489280512 bytes
end of 4th partition (LBA in bytes):
(
99616768 +
84932608) * 512 =
94489280512
Reported-by: Giulio <giulioo@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
static unsigned long
get_disksize(int format) {
- unsigned long cs = B.cylinders;
- if (cs && leave_last)
- cs--;
- return (cs * B.cylindersize) / unitsize(format);
+ if (B.total_size && leave_last)
+ /* don't use last cylinder (--leave-last option) */
+ return (B.total_size - B.cylindersize) / unitsize(format);
+
+ return B.total_size / unitsize(format);
}
static void