Partition table independent of sector size

advanced-formatfdiskpartitioning

The plot

I have a WD10JPVT 1Tb disk inside an IcyBox IB-290StUS-B USB/esata enclosure.

  • When I connect the disk via USB, I get a 512 logical / 512 physical sector size.
  • When I connect the disk via the computer's native esata port, I get a 512 logical / 4k physical sector size.
  • When I connect the disk via an AKE Hidden USB 3.0 + eSATA II ExpressCard 54mm's esata port, I get a 4k logical / 4k physical sector size.

The problem

The problem is that in a MBR partition table, the beginning and end of partitions is expressed as a number of (logical) sectors. This means that if I partition the disk when it is plugged via the expresscard's esata port, and then plug it in a USB port or the native esata port, the partitions will have a wrong offset and wrong size, and vice-versa.

fdisk output

The fdisk commands below are run using Ubuntu 11.04 (natty), and give the same results with XUbuntu 12.04 for the USB and esata on expresscard, but I can't test native esata since that's what I boot Ubuntu 12.04 from.

Connected via USB:

> sudo fdisk -l /dev/sdb
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c2664

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       15201   122095104    7  HPFS/NTFS

Connected via the computer's native esata port:

> sudo fdisk -l /dev/sdb
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000c2664

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       15201   122095104    7  HPFS/NTFS

Connected via the expresscard's esata port:

> sudo fdisk -l /dev/sdb
Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 15200 cylinders
Units = cylinders of 16065 * 4096 = 65802240 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000c2664

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       15201   976760832    7  HPFS/NTFS

Solutions ?

  • Is there a way to store the "real" sector size (4k) inside an MBR partition table ?
  • Using a GPT partition table might have worked, but the GPT header is stored in sector 1 of the disk… and the sector size varies, so unless there is a way to store the GPT header at a fixed position measured in bytes, it's useless.
  • Formatting the raw drive without any partition works, but under ubuntu 11.04 I have to manually mount the disk (/dev/sdb), since Hal tries to mount the non-existant partitions (/dev/sdb1, /dev/sdb2, …), despite the fact it detects the filesystem label correctly.
  • I can create manually two overlapping partitions, one which works with 4k sectors, and one which works with 512 sectors, and every time I plug the disk one partition will be invalid and the other will be used, but this feels ugly and brittle.

Best Answer

You have done a very deep analysis of disk formats, both MBR and GPT, and it seems that you have hit a problem that was unthought-of in these standards, that of a format that is independent of the logical sector size.

The problem is that the USB disk has internal sector size of 4K but pretends to different sector sizes (both logical and physical) according to the port to which it is connected. In practice, it also pretends to different cylinder/sector configurations, although this mapping is at least consistent.

Changing this behavior will require either :

  1. Changes in the disk firmware
  2. Changing the protocol used on the port, meaning changes in the disk driver used for the USB disk

Both these options seem to me to be impossible to do yourself. I have not found on the Western Digital site any firmware updates for your disk, and I have not searched for better disk drivers (partly because I don't know what exactly to search for, but even if I knew I wouldn't be too optimistic).

The same question was asked on the following post, dating from June 2012,
How would I force Debian to use the physical sector size on a hard disk?

This is the unencouraging accepted answer (which quotes an article from July 2011) :

According to an interview with a Western Digital representative published on http://www.techarp.com/showarticle.aspx?artno=734 there is no option to disable 512e emulation on current Advanced Format drives.

[...] will Western Digital offer firmware upgrades that would convert current Advanced Format drives running in emulation mode, to the native format?

Unfortunately, no. Current Advanced Format drives cannot be converted to run in the native format through a firmware upgrade

I hope someone else comes up with a better answer, but my own answer tends to be negative. I wouldn't advice trying to fabricate a non-standard GPT/MBR format, not if you wish to keep your data safe.

Related Question