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.