Skip to contentSkip to conversation

sfdisk: trying to create aligned partitions: fail

DISCUSSION Giulio 2 participants 5 messages Aug 17, 2011 Util-Linux package

lore
Share & tools
lore

Giulio

author
#0 lore raw

Linux 2.6.18-238.12.1.el5
sfdisk from util-linux 2.20-rc1
fdisk (util-linux 2.20-rc1)
200GB VMware SCSI disk

It seems it's not immediately possible to create aligned partitions (ie:
starting at 1MB/2048 sectors) with sfdisk.

1) 1st try, using MBs as unit of measure:

dd if=/dev/zero of=/dev/sda bs=1 count=512
sfdisk -L -uM /dev/sda <<-EOF
1,1001,83
,,83
;
;
EOF

Results (starts at sector 1 instead of 1MB):

$ fdisk -lu /dev/sda

Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1     2056319     1028159+  83  Linux
/dev/sda2         2056320   419425019   208684350   83  Linux

2) 2nd try, using sectors as unit of measure:

dd if=/dev/zero of=/dev/sda bs=1 count=512
sfdisk -L -uS /dev/sda <<-EOF
2048,2050048,83
,,83
;
;
EOF

Results (wrong 2nd partition created):

$ fdisk -lu /dev/sda

Disk /dev/sda: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048     2052095     1025024   83  Linux
/dev/sda2               1        2047        1023+  83  Linux
/dev/sda3         2052096   419430399   208689152   83  Linux

Partition table entries are not in disk order

===

Is there some option to enable alignment?

Thanks

maintainer
#1 lore raw
Quoted 7 lines · Giulio

Linux 2.6.18-238.12.1.el5
sfdisk from util-linux 2.20-rc1
fdisk (util-linux 2.20-rc1)
200GB VMware SCSI disk

It seems it's not immediately possible to create aligned partitions (ie:
starting at 1MB/2048 sectors) with sfdisk.

This is unsupported by sfdisk and cfdisk. You have to use fdisk or parted.

I'll add a note about it to the man page...

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
author
#2 lore raw
Quoted 11 lines · Karel Zak
Quoted 7 lines · Giulio

Linux 2.6.18-238.12.1.el5
sfdisk from util-linux 2.20-rc1
fdisk (util-linux 2.20-rc1)
200GB VMware SCSI disk

It seems it's not immediately possible to create aligned partitions (ie:
starting at 1MB/2048 sectors) with sfdisk.

This is unsupported by sfdisk and cfdisk. You have to use fdisk or parted.

What is unsupported?

I know sfdisk won't automatically align partitions and didn't expect it to do it, my email was about sfdisk behaving in an unexpected way:
- not respecting 1MB as start of partition when I ask for it
- creating partitions out of order when using sectors

Maybe I chose the wrong subject, I was trying to align partition manually and sfidk won't let me do it.

Thanks.

maintainer
#3 lore raw
Quoted 4 lines · Giulio

I know sfdisk won't automatically align partitions and didn't expect it to do it, my email was about sfdisk behaving in an unexpected way:
- not respecting 1MB as start of partition when I ask for it
- creating partitions out of order when using sectors

Try --in-order command line option, the option is undocumented in old versions ;-(

sfdisk --in-order -L -uM /dev/sdb <<-EOF
1,10,83
,,83
;
;
EOF

result (output from fdisk):

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048       22527       10240   83  Linux
    /dev/sdb2           22528      204799       91136   83  Linux

sfdisk --in-order -L -uS /dev/sdb <<-EOF
2048,8000,83
,,83
;
;
EOF

result (output from fdisk):

       Device Boot      Start         End      Blocks   Id  System
    /dev/sdb1            2048       10047        4000   83  Linux
    /dev/sdb2           10048      204799       97376   83  Linux
Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#4 lore raw
Quoted 2 lines · Karel Zak
Quoted 1 line · Giulio

I know sfdisk won't automatically align partitions and didn't expect it =

to

Quoted 5 lines
Quoted 3 lines

do it, my email was about sfdisk behaving in an unexpected way:
- not respecting 1MB as start of partition when I ask for it
- creating partitions out of order when using sectors

=C2=A0Try --in-order command line option, the option is undocumented in o=

ld

Quoted 1 line

=C2=A0versions ;-(

With "--in-order" the issue with partitions out of order (the case in which I was using -uS) is solved.

However, there still is an isse when using -uM
I was trying with a 200GB VMware disk and when I used -uM and 1 as start of 1st partition sfdisk would create a partition starting at sector 1 (not MB 1).

I see you used a 100MB disk, so I tried different sizes until I found when the error appears, unfortunately I'm not able to fine grain sizes in VMware more than the following:

=3D=3D command used
DEV=3D$1
dd if=3D/dev/zero of=3D/dev/$DEV bs=3D1 count=3D512 sfdisk --in-order -L -uM /dev/$DEV <<-EOF 1,10,83
,,83
;
;
EOF
=3D=3D

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D with a 1062MB, OK:
Disk /dev/sdc: 1062 MB, 1062207488 bytes
64 heads, 32 sectors/track, 1013 cylinders, total 2074624 sectors Units =3D sectors of 1 * 512 =3D 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048       22527       10240   83  Linux

<=3D=3D=3D=3D start sector 2048
/dev/sdc2 22528 2074623 1026048 83 Linux
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D with a 1073MB, NOT-OK:
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders, total 2097152 sectors Units =3D sectors of 1 * 512 =3D 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       32129       16064+  83  Linux

<=3D=3D=3D=3D=3D start sector 1
/dev/sdb2 32130 2088449 1028160 83 Linux
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Thanks