Linux – Aligned partitioning of 2TB disk with Linux fdisk

alignmentfdisklinuxpartitioning

Is there a way to create a single 2TB partition, which is 4096-byte-sector aligned, on a disk using the standard Linux fdisk (I have tried version 2.17.2)?

I've tried the following things and ran into the described error:

  • If I simply use the -u flag, it sets the cluster size to one sector of 512 byte. Then, the partition would have to be 3,906,250,000 clusters long and fdisk truncates this number to 2,147,483,647 (2^31-1).
  • If I use -b 4096, it allows me to create the partition just fine (with length 488,281,506 sectors), but if I check the size of the resulting partition using blockdev --getsize64, it shows that the partition is only 250GB big, i.e. it is still using a sector size of 512.
  • If I try to set the sector and head count using -S 64 -H 32, for example, then it always sets the sector count back to 63, which doesn't divide evenly into 4096 (I know, 32 dividing evenly by 8 is technically enough, but – call me perfectionist – I'd really like to have the partition start at sector 2048 (1MB aligned), as I read is the recommended setting these days.

Is there some combination of parameters that I can pass to fdisk, that will allow me to create a partition that starts at 1MB (sector 2048 [256] for 512-[4096-]byte sectors) and is exaclt 2TB long (3,906,250,000 [488,281,506] sectors for 512-[4096-]byte sectors)?

(I read that I can just use gparted and have it change the drive to GPT partitioning, but I'd really like to know if there is a way to do it with standard fdisk and an MBR partition. I don't see a reason why MBR partitions shouldn't allow for this…)

Best Answer

Recent versions of fdisk start the first partition at sector 2048 by default. If you're seeing some other behavior, then either you're using a rather elderly version of fdisk or there's a bug in the version of fdisk that you're using.

You could also use parted or GParted for this task. They both work with MBR disks as well as with GPT disks, so using one of these tools does not necessitate switching to GPT. That said, GPT does have certain advantages, even on smaller disks. They're minor, but you might want to consider using GPT to get these advantages. (These include having CRCs of important data structures to spot problems, having a backup of important data structures to help recovery from some types of problems, having partition labels, eliminating the awkward primary/extended/logical quagmire, and of course supporting over-2TiB disks.)

Related Question