There's plenty of advice for Windows, but none for Linux. So here goes:
Step 1) Set up your partition manager to use 56 sectors/track. For instance:
Code:
fdisk -S 56 /dev/sda
or
cfdisk -s 56 /dev/sda
or
sfdisk -S 56 *other options here - if you're using sfdisk you presumably know wtf you're doing*
or
parted .... well, don't use parted.
Step 2) Set up your partitions like you normally would.
Step 3) There is no step three, you're done.
I know linux works with this, but I'd appreciate it if someone partition a drive in such a fashion with systemrescuecd and install Windows on those partitions and let the rest of us know if it works. It would also allow Windows users to have multiple partitions without having to painstakingly align each one.
If you're interested, read the following. Otherwise skip the rest of my post, it's just info you don't need to know but might want to know anyway.
First thing to keep in mind: Cylinders, Heads, and Sectors do not really exist. Seriously, they don't. Take a screw driver and take apart your SSD. If you find a hard drive platter in there, let me know. However, your BIOS still speaks in terms of Cylinder+Head+Sector, so your hard drive has to support it. (even for normal platter hard drives, CHS is legacy - your hard drive will re-interpret CHS in terms that it understands.)
What we're doing is this: Each sector is 512 bytes. Each track, by convention, consists of 63 sectors. So each track is 512*63=32256 which is not a multiple of 4096. Partitions must begin (and end) at track boundaries. Since we're defining each track as being 56 sectors, each track is 512*56=28672=4096*7 bytes, which means all partitions will begin and end at a 4096 byte alignment whether we like it or not. Not only will our sda1 partition begin and end at a 4096 byte alignment, but so will our sda2 swap partition and our sda3 / partition, and no amount of hanky-panky with making our partitions weird sizes will impact any of that.
Proof of concept:
First the old fashioned way.
Code:
root@sysresccd /root % fdisk /dev/sda
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +100M
Command (m for help): a
Partition number (1-4): 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (15-2610, default 15):
Using default value 15
Last cylinder, +cylinders or +size{K,M,G} (15-2610, default 2610): +1G
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (147-2610, default 147):
Using default value 147
Last cylinder, +cylinders or +size{K,M,G} (147-2610, default 2610):
Using default value 2610
Command (m for help): p
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000da626
Device Boot Start End Blocks Id System
/dev/sda1 * 1 14 112423+ 83 Linux
/dev/sda2 15 146 1060290 82 Linux swap / Solaris
/dev/sda3 147 2610 19792080 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@sysresccd /root % fdisk -l -u /dev/sda
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x000da626
Device Boot Start End Blocks Id System
/dev/sda1 * 63 224909 112423+ 83 Linux
/dev/sda2 224910 2345489 1060290 82 Linux swap / Solaris
/dev/sda3 2345490 41929649 19792080 83 Linux
root@sysresccd /root %
The first partition begins at 63*512=32256=4096*7.875, which is not an even multiple of 4096.
The second partition begins at 224910*512=115153920=4096*28113.75, which is not an even multiple of 4096.
The third partition begins at 2345490*512=1200890880*293186.25, which is not an even multiple of 4096.
All three partitions will have poor performance. It is possible that you will get a partition that begins on a 4096 aligned boundary, but it's a 1/8 chance.
Second, with 56 sectors/track:
Code:
root@sysresccd /root % fdisk -S 56 /dev/sda
The number of cylinders for this disk is set to 2937.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2937, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2937, default 2937): +100M
Command (m for help): a
Partition number (1-4): 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (16-2937, default 16):
Using default value 16
Last cylinder, +cylinders or +size{K,M,G} (16-2937, default 2937): +1G
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (164-2937, default 164):
Using default value 164
Last cylinder, +cylinders or +size{K,M,G} (164-2937, default 2937):
Using default value 2937
Command (m for help): p
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 56 sectors/track, 2937 cylinders
Units = cylinders of 14280 * 512 = 7311360 bytes
Disk identifier: 0x000da626
Device Boot Start End Blocks Id System
/dev/sda1 * 1 15 107072 83 Linux
/dev/sda2 16 163 1056720 82 Linux swap / Solaris
/dev/sda3 164 2937 19806360 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@sysresccd /root % fdisk -l -u /dev/sda
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 56 sectors/track, 2937 cylinders, total 41943040 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x000da626
Device Boot Start End Blocks Id System
/dev/sda1 * 56 214199 107072 83 Linux
/dev/sda2 214200 2327639 1056720 82 Linux swap / Solaris
/dev/sda3 2327640 41940359 19806360 83 Linux
root@sysresccd /root %
You'll note that the commands I typed in are exactly the same, and the partition layout is similar, although the sizes are slightly tweaked. (within a few megabytes of each other, but the total disk size is the same)
The important part is the starting points of each partition:
The first partition begins at 56*512=28672=4096*7, which is an even multiple of 4096.
The second partition begins at 214200*512=109670400=4096*26775, which is an even multiple of 4096.
The third partition begins at 2327640*512=1191751680=4096*290955, which is an even multiple of 4096.
If you don't want to take it from me, take it from Theodore Ts'o:

Originally Posted by
[url]http://article.gmane.org/gmane.linux.utilities.util-linux-ng/1947[/url]
For SSD's and HDD's that use a 4k internal sector size, being 4k aligned makes a big difference because it avoids read-modify-write cycles. We can achieve this easily if we simply use a CHS geometry of 56 sectors/track instead of 63 sectors. So, I would propose that we change the default geometry used by the partitioning tools in util-linux-ng, gparted, etc. so the default sectors is 56; furthermore, to catch those partitioning tools that use the HDIO_GETGEO ioctl, that we change the fantasy geometry generated in drivers/scsi/scsicam.c:scsicam_bios_param() and drivers/ata/libata-scsi.c to also use a 255/56 head/sector geometry.
I'll have benchmarks, ummm, some other time. YMMV. I am not responsible for any damages etc etc.
edit: there's a new thread at http://www.ocztechnologyforum.com/fo...ad.php?t=54379 with lots of information.
Bookmarks