Why does the partition start on sector 2048 instead of 63?

56

28

I had two drives partitioned the same and running two RAID partitions on each.

One died and I replaced it under warranty for the same model.

While trying to partition it, the first partition can only start on sector 2048, instead of 63 that was before. Drive have different geometry as previous and remaining ones. (Fewer heads/more cylinders)

Old drive:

$ sudo fdisk -c -u -l /dev/sdb 

Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders, total 3907029168 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: 0x000aa189

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63   174080339    87040138+  83  Linux
/dev/sdb2       174080340   182482334     4200997+  82  Linux swap / Solaris
/dev/sdb3       182482335  3907024064  1862270865   fd  Linux raid autodetect

Remanufactured drive received from warranty:

$ sudo fdisk -c -u -l /dev/sda

Disk /dev/sda: 2000.4 GB, 2000398934016 bytes
81 heads, 63 sectors/track, 765633 cylinders, total 3907029168 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: 0x000d0b5d

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048  ...

Why is that?

gcb

Posted 2011-10-31T22:28:05.450

Reputation: 3 392

Releated questions and answers: https://superuser.com/q/565577/19956, https://unix.stackexchange.com/q/81556/3054.

– pts – 2018-01-05T14:48:09.190

Using newer disk drives, GPT is recommended which uses 2048 as start sector by default. The older disk was probably formatted with an older utility and using non-GPT partition table format.

For partitioning newer "Advanced Format 4K" disks, use GPT fdisk Utilities.

For RAID, be sure to use type fd00 Linux RAID and label your partitions appropriately.

– TrinitronX – 2019-08-14T23:27:57.057

1The output does not indicate that this is an Advanced Format 4K drive: Sector size (logical/physical): 512 bytes / 512 bytes. – bwDraco – 2011-10-31T23:07:50.407

1Why was this downvoted? – bwDraco – 2011-10-31T23:35:56.487

1I disagree with the downvote, I was also not aware of the track-alignment misconception and JdeBP's info is useful and relevant to a valid question. – Garrett – 2011-10-31T23:39:28.377

Answers

45

Because your old disc was partitioned with a old utility, such as the Linux fdisk, that uselessly implemented track-alignment using the entirely fake disc geometry that you see reported, and your new disc has been or is being partitioned by a newer utility that (by default) aligns to 1MiB boundaries instead.

Further reading

JdeBP

Posted 2011-10-31T22:28:05.450

Reputation: 23 855

5fdisk is not an "old utility", it's actively maintained. Just do NOT use "fake disk geometry" via -c=dos (it's off by default!). The manpage explicitly warns against doing that as CHS is dead as disco. The link to JdBP's page is dead, but the history of the 1MiB (2048 sector) alignment can be found the Wikipedia entry Logical Disk Manager. It's a Windows Vista wart: "Using a 1-MiB alignment boundary allows safer editing of the partition table with Vista Disk Mgt." – David Tonhofer – 2016-08-14T14:09:50.640

1FYI the 1 MiB (2048 sector) alignment was introduced to Linux fdisk in util-linux-ng-2.17.1/fdisk/fdisk.c, function update_sector_offset(void), released on 2010-02-22. Windows Vista was released in 2006-11. – pts – 2018-01-05T14:39:01.563

@DavidTonhofer This requirement is still present in fdisk 2.20.1. As you report, the man-page mentioned -c=nondos being the default configuration, but the first usable sector remains to be 2048. – sherrellbc – 2018-02-19T14:09:24.170

7

In other words, the LBA sector number 63 corresponds to cylinder 0, head 1, sector 1 in the CHS format, which is the first sector you can use in the MBR format. However, the number 63 is not divisible by 8, which causes a problem with 4K drives, so some modern tools starts the first partition at 2048 which also provides future GPT compatibility.

– billc.cn – 2011-10-31T23:48:59.333

8There are times when one yearns for a way to mark down comments, especially comments where others try to put outright errors into one's mouth. Those "other words" are incorrect, which is why they are not what I wrote. The first sector that one can use (as several people have) for a primary partition with an MBR partition table is LB# 2, or even LB# 1 if one doesn't need compatibility with things like IBM's LVM. And the 1MiB alignment is nothing to do with EFI partition table compatibility. – JdeBP – 2011-10-31T23:59:22.047

Right I guess I made a mistake about the first part, but for the second bit I meant that if you start at 2048, you will have no problem converting the drive to GPT in the future, hence the word "also" and "future". – billc.cn – 2011-11-01T03:59:53.087

+1: That was a great read JdeBP. I'm pretty sure I've read this else where, just not sure where. . . – surfasb – 2011-11-01T14:24:19.470

5That's still incorrect . One will have no problem anyway. Do the arithmetic. Even the original alignment to a (fake) track boundary provides more than enough room. Those 60 512-byte sectors can hold 240 EFI partition table entries. Again: The 1MiB alignment is nothing to do with EFI partition table compatibility. – JdeBP – 2011-11-01T18:48:23.467

managed to partition the same way on fdisk by disabling DOS compatibility mode... – gcb – 2011-11-05T04:11:43.193

36

fdisk -c=dos

You used the old DOS partition table when creating your partition. Newer versions of fdisk do not use dos compatibility mode by default.

Mike

Posted 2011-10-31T22:28:05.450

Reputation: 361

5This is critical if you are trying to resize a partition, which with fdisk means deleting and recreating it; you need the partition to start at the same place. – mcr – 2015-08-27T01:05:42.273

no longer works with fdisk from util-linux 2.28 :/ – akostadinov – 2016-09-28T17:26:08.320

1

found it fdisk -c=dos -u=cylinders /dev/sdb in gist - https://gist.github.com/jkullick/febf46756435f1fa99dc56f00782de03

– akostadinov – 2016-09-28T17:34:49.930

3The accepted answer has some valuable information but this answer has the gem that I needed to fix my problem. – jcbwlkr – 2013-08-13T13:05:52.993

fdisk wouldn't let me recreate a partition starting at sector 2048 without this argument - I got First sector (3072-314572799, default 3072): – tomfanning – 2014-04-25T14:40:49.467

7

Maybe it will be useful to add a comment here. For LUKS partition, it is said to delete and re-create the partition at the same place, but larger before calling cryptsetup resize. But when you created your partition long time ago, it start at the sector 63. Using fdisk, the partition will be recreated at the wrong offset, resulting in a lost partition.

I've managed to recover it using fdisk -c=dos to be able to create partition from sector 63, without troubles.

Adrien Clerc

Posted 2011-10-31T22:28:05.450

Reputation: 171

2

The 1 MiB (2048 * 512-byte emulated block size) choice is a great catch-all for various hardware storage configurations. Since file system data structures are generally aligned with the partition start point, this can be important to maximize storage read/write speed.

For example:

RAID may use data stripes ranging from 16 to 256 KiB in size. 1 MiB is an integer multiple of this, so starting the partition at 1 MiB is compatible with the underlying RAID model.

SSDs typically have an erase block size of 128 to 256 NAND pages, which depending on the drive might be 256 KiB or 512 KiB. So here again, starting the partition at 1 MiB is compatible with the underlying SSD storage characteristics.

Advance Format 512e spinning HDDs have a 4 KiB physical block size, and again, 1 MiB is an integer multiple (albeit a rather large one) of this.

So while if you have an AF drive and are partitioning as GPT, you might be perfectly happy with your first partition starting at LBA block 40 (an integer multiple of the 8 logical blocks in each physical block of your HDD), hardly any real-world storage is lost by just starting at LBA block 2048 (1 MiB), which is just a more flexible value for partitioning software to default to since it is suitable for pretty much any hardware configuration.

Ryan Feeley

Posted 2011-10-31T22:28:05.450

Reputation: 31

1

Not sure why it started on 63 in the first place, but according to fdisk, your sector sizes are 512.

So if you want your partitions, and thus clusters to be aligned, your starting offset should be divisible by 512. 2048 is pretty common these days.

If you prefer misaligned sectors, then you can always get GPart to move your partition back to 63.

Edit:

Ooops. Didn't see that you have a RAID. You should probably post your RAID and stripe size.

surfasb

Posted 2011-10-31T22:28:05.450

Reputation: 21 453

163 is 111111 in binary. The BIOS of PCs, sector number is/was encoded in six bits, resulting in a maximal number of 111111 (63) sectors per track. This maximum is still used for virtual CHS geometry. – Chris Reid – 2018-10-12T21:29:00.253

1

While I realize that the actual question was answered, a quick fix for the 63 vs 2048 first cylinder issue is something like:

sfdisk -d /dev/sdb | sfdisk --force /dev/sda

(if you're sure you've got drives that are the same size)

You can then proceed with adding the various partitions back into the RAIDs where you got complaints about the partitions not being the same size due to the 63/2048 start cylinder difference throwing off the eventual partition sizes.

Jason Byrne

Posted 2011-10-31T22:28:05.450

Reputation: 21

you should explain what it does, source destination? – Pawel Cioch – 2019-04-03T23:21:28.777