I first asked this question on SuperUser.com but got no responses. I have found how to align the partition of my SSD using fdisk (SSD article on Gentoo Wiki) but haven't been able to find any resources about aligning the partitions of a HDD. Is this practice necessary, or should I just let something like GPartEd align them as default? If it's something I should do to the HDD as well, where can I find a resource for the size to use for the sector and head portion of the command?
If you are using the old fdisk program these days, always use the
-uc which will display sectors instead of cylinders, and disable compatibility with MS-DOS.
My opinion, simply make all your partitions start/end on 1MB boundaries. So the starting sector should be evenly divisible be 2048. By simply aligning everything to the nearest 1MB, you are aligned drives with 512, and 4096 physical sectors, you are also properly aligned for typical RAID(5,6) chunk sizes of 32k, 64k, 512, 1mb.
For future Googlers, I've found this article on the Arch Linux wiki that answers this question: "Advanced Format". As it turns out, there are a couple tools you can use to determine the sector size on your disk (smartmontools and hdparm). See the article for more information.
I can put an example where align to cylinders is needed, but i don know why on the hell i really need that align?
What i want: Boot an UEFI system with Grub2 and SystemRescueCD.iso loop.
Boot medium: USB strick, i have two usb sticks, 2GiB (align to MiB works) and 8GiB (align to MiB fail on physical machine but works on VirtualBOX, at physical PC boot time it does not see/list it as a bootable EFI; align to cylinders makes on such physical PC to see it and can boot from it).
My observations are:
- If a do a 1MiB algin on the 2GiB one, it is seen by UEFI and let me boot Grub2 from it (on both physical PC and VirtualBOX).
- If a do a 1MiB algin on the 8GiB one, physical PC UEFI does NOT see/list it and does not let me to boot Grub2 from it.
- If a do a Cylinder algin on the 8GiB one, physical PC UEFI does see it and let me to boot Grub2 from it.
For testing all the cases i do exactly the same steps (all in console mode):
- Boot from ISO of SystemRescueCD
- Fill with zeros all the pendrive (with dd if=/dev/zero ...)
- Create a GPT table with fdisk
- Define 4 partitions (Data [Rest_size], Grub2[1GiB], EFI[512MiB], BIOS_grub[8MiB]), i had tried with gdisk, parted, etc
- Install Grub for i386-pc (yes for x86, so pendrive will also boot on 32bit only systems) to dedicated partition and MBR
- Install Grub for x86_64-efi (for uefi 64 bit systems)
What i get is:
- 2GiB one, allways seem/listed as bootable media and it boots ok, on VirtualBOX and on Physical 32bit and on Physical 64it, no matter if aligned to 1MiB or to cylinders.
- 8GiB one, is not allways seem/listed as bootable media , but when it is listed it boots ok, on VirtualBOX allways boots ok as well as on Physical 32bit but on Physical 64it it is not listed as bootable media if aligned to 1MiB but it is listed if aligned to cylinders.
Why on the hell that occurs? i have no idea.
P.D.: I had tested a lot of usb sticks (more than ten), usb hdds (more than 5), etc... align to 1MiB on most of them allways works well, but i found than on the 8GiB LG USB stick it does not allways work well, it requieres to work to be aligned to cylinders. Media has no deffects, just in case someone could think about that as the cause.
P.P.D.: I had also seen that such physical pc has something really weird (random behavior on boot when using ctrl+alt+del), if i reboot it by pressing ctrl+alt+del at screen menu where i select where to boot from, that makes such 8GiB usb stick to not be listed sometimes while others it is listed (when it was created with align to cylinders), but if is is align to MiB it neves get listed.
In modern hard drives, partition alignment is really almost mythical. We began using virtual geometry for these devices in BIOS years ago to overcome obstacles in DOS addressing schemes that were reliant on hardware conforming to standards. FDISK/CFDISK/GPartEd, etc, will all "cylinder align" your partitions by default, meaning they will start and stop partitions at the first unallocated cylinder position. I know that PARTED will allow you to specify the size of a partition in sectors, but I can't think of any practical reason with modern hardware to do this. Unless you have a specific requirement in mind, stick with cylinder alignment, it's clean and predictable.
Do you have a specific reason you wanted to do this?
In regards to aligning SSD partitions, I will have to read the article you've linked... but since SSDs don't really have heads, or cylinders, or tracks, I can't imagine a reason why you'd want to align partitions on them.