Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
    
Could you define what you mean by align, align to/for what? – mdpc Aug 16 '13 at 16:07
    
From here: "...Linux' fdisk, however, still uses a virtual C-H-S system where you can define any number of heads and sectors yourself (the cylinders are calculated automatically from the drive's capacity), with partitions always starting and ending at intervals of heads x cylinders. Thus, you need to choose a number of heads and sectors of which the SSD's erase block size is a multiple." This specifically refers to SSDs. I am asking about HDDs. – Jonathan Landrum Aug 16 '13 at 16:20
up vote 3 down vote accepted

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.

share|improve this answer

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.

share|improve this answer
    
Please do not post an answer that's essentially a link. Include the relevant information in your post (e.g. the smart and hdparm command lines and what they do). Leave the link for reference, but it must not be necessary to follow it to get an answer to the question. For more answer writing tips, see How to Answer. – Gilles Aug 17 '13 at 20:26

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:

  1. 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).
  2. 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.
  3. 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):

  1. Boot from ISO of SystemRescueCD
  2. Fill with zeros all the pendrive (with dd if=/dev/zero ...)
  3. Create a GPT table with fdisk
  4. Define 4 partitions (Data [Rest_size], Grub2[1GiB], EFI[512MiB], BIOS_grub[8MiB]), i had tried with gdisk, parted, etc
  5. Install Grub for i386-pc (yes for x86, so pendrive will also boot on 32bit only systems) to dedicated partition and MBR
  6. 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.

share|improve this answer
1  
Is this a question or an answer ? – don_crissti May 23 at 10:25

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.

share|improve this answer
1  
Modern drives have no alignment on cylinders (cylinders as reported to software are pure fiction), but they do have alignment on sectors. – Gilles Aug 17 '13 at 20:25
    
I believe I qualified the comment adequately regarding that in the first two sentences. Further, the utilities that I referenced which include the one originally asked about, default to CHS addressing. "Cylinder align" was used in quotes, and the explanation of why it's okay to use it was still valid. I don't feel a down-vote was warranted in this case. – James Brandon Aug 26 '13 at 17:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.