Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 exactly 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...)

share|improve this question
    
What OS/distribution/kernel/version? –  ewwhite Mar 14 '13 at 0:46
    
@ewwhite Not sure it matters too much for the question, but here you go: Debian Squeeze 6.0.7, stock kernel 2.6.32-5-686, fdisk 2.17.2... –  Markus A. Mar 14 '13 at 1:05
1  
It matters because partition alignment along sectors is the default on newer Linux distributions. –  ewwhite Mar 14 '13 at 1:11
    
@ewwhite Is that something that depends on more than just the version of fdisk I'm using? –  Markus A. Mar 14 '13 at 1:14
add comment

3 Answers 3

There's a reason why GPT exists, and you appear to have discovered it. There's no value in pushing a square peg through a round hole.

share|improve this answer
    
Does the standard linux fdisk also support GPT or will I have to use a different tool? –  Markus A. Mar 14 '13 at 0:28
    
Yes, you should be using a different tool. fdisk isn't really useful on disks >= 2TB, and there are much better tools now anyway. –  Michael Hampton Mar 14 '13 at 1:36
1  
You want to use gdisk or parted. –  MikeyB Mar 14 '13 at 1:37
add comment
up vote 1 down vote accepted

UPDATE:

Newer versions of fdisk (e.g. v2.20.1) do not have the issue of truncating the cluster number as described in the question any more. Therefore, one can now simply use

fdisk -c /dev/sdX

to create a partition starting at 2048 and ending at 3906252047 to create the desired layout.

ORIGINAL ANSWER:

I found one way to do it:

fdisk -S 16 -H 1 -c /dev/sdX

Then, I can create a partition that starts at 129 and ends at 244,140,753.

Now, if I do fdisk -l -u /dev/sdX, I will get:

Disk /dev/sdX: 2000.4 GB, 2000365289472 bytes
1 heads, 16 sectors/track, 244185216 cylinders, total 3906963456 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: 0xee3e796d

   Device Boot      Start         End      Blocks   Id  System
/dev/sdX1            2048  3906252047  1953125000   fd  Linux raid autodetect

and blockdev --getsize64 /dev/sdX1 gives me exactly 2,000,000,000,000.

Now the big question: Does anyone see a problem with the -S 16 -H 1? :)

share|improve this answer
    
As long as you're not booting from it, it just might work, but as long as the drive reports that it has 512/512 byte sectors, the BIOS will never figure out this partition. –  DerfK Mar 14 '13 at 0:34
    
@DerfK, fortunately, grub does not use the CHS addressing method that has been depreciated for 15+ years now, so it won't matter unless you try to install Windows. –  psusi Mar 14 '13 at 1:17
add comment

Use parted instead of fdisk. It will take care of the alignment automatically and doesn't have this bug you seem to have discovered in fdisk. Also, there is no such thing as clusters. It is either sectors, or cylinders, which are depreciated junk left over from the early '90s.

share|improve this answer
add comment

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.