71

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?

palacsint
  • 627
  • 2
  • 8
  • 24
gcb
  • 5,442
  • 13
  • 62
  • 86

6 Answers6

53

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

Picotin
  • 66
JdeBP
  • 27,556
  • 1
  • 77
  • 106
48
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
  • 481
10

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.

5

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.

2

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.

Gareth
  • 19,080
0

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
  • 22,896