It's a little late, but I had a similar problem after the USB port of my IOMEGA hard disk case broke off. I switched to another USB-2-SATA case just to discover, that I could not mount the EXT4 partition. For some reason the IOMEGA case reported the logical sector size to be 4096, but my new case said it was only 512 bytes. This screws up the MS-DOS partitioning table.
It was driving me nuts, because with the help of testdisk
I was able to access the partition, when changing the sector size, but I found no way to change the sector size system-wide. It turns out, that's not necessary, because EXT4 does not care for sector size, you just have to find the beginning of the partition you'd like to access.
Quick fix: Use a loopback device to shift to the correct position of the partition.
Permanent fix: Rewrite partition table, accordingly.
In my case the affected drive was /dev/sdb
.
My quick fix was relatively easy, since I had only one partition beginning at sector 63.
$ sudo sfdisk -d /dev/sdb
# partition table of /dev/sdb
unit: sectors
/dev/sdb1 : start= 63, size=623708785, Id=83
Now we have to calculate the partition's position, when sector size still was 4096 bytes:
63 sectors * 4096 bytes = 258048 bytes
And use that with losetup
:
$ sudo losetup /dev/loop0 /dev/sdb -o 258048
$ sudo mount /dev/loop0 /mnt
Your partition should now be mounted at /mnt
.
For the longterm fix I used sfdisk
to dump the partition layout:
$ sudo sfdisk -d /dev/sdb > sdb.partitions.sfdisk.text
Fixing the partition table by multiplying with the beginning sector with 8 where appropriate -- here I realized my partition table was kinda screwed from the beginning.
I edited the partition table dump with nano sdb.partitions.sfdisk.text
:
/dev/sdb1 : start= 63, size=623708785, Id=83
to:
/dev/sdb1 : start= 504, size=623708785, Id=83
and later on extended the partition to use all available space (which I determined by other means):
/dev/sdb1 : start= 504, size=625141944, Id=83
Last step is to write back the partition table with:
$ sudo sh -c 'cat sdb.partitions.sfdisk.text | sfdisk /dev/sdb'
Many Western Digital external USB drives over 2 TB (including at least some My Book, My Book Essential, Elements, and Easystore drives) can be configured for either 512 byte logical sectors or 4096 byte logical sectors using the WD Quick Formatter tool. When configured for 4096 byte logical sectors, the USB-to-SATA bridge in the enclosure does a translation between 512 byte logical sectors at the SATA interface to the internal drive and 4096 byte logical sectors at the USB interface to the host computer.
With 512 byte logical sectors, an MBR partition table could only use up to 2 TB of a drive. That's because MBR table entries are 32 bits with a max of 2^32 or 4,294,967,296 sectors. 2^32 sectors x 512 bytes/sector is 2 TB. With 4096 byte logical sectors, an MBR partition cable can use up to 16 TB of a drive. (2^32 sectors x 4096 bytes/sector is 16 TB) Windows XP only supports MBR partition tables, and so 4096 byte logical sectors are the only way to use all of the space on a drive over 2 TB in Windows XP. The newer GPT partition table format supported in Windows Vista and later does not have the 32-bit limitation, and can support disks larger than 2 TB regardless of the sector size.
The WD Quick Formatter tool (version 2.0.0.65 available for download as of this writing) can enable or disable the sector size translation. This version of the tool does not work correctly under Windows XP, so I recommend running the tool in Windows 7 or later. When run in Windows 7, or in later version of Windows but with Windows 7 compatibility mode, the tool will present two configuration options on the "Format your WD external drive" screen:
- XP Compatible: This option configures the drive for 4096 byte logical sectors, and creates an MBR partition table.
- Most Compatible (Vista or later required): This option configures the drive for 512 byte logical sectors, and creates a GPT partition table.
Both options also create a single partition filling the entire drive, and quick format it in NTFS.
If you run the tool in Windows 8 or later without putting it in Windows 7 compatibility mode, the tool will not present a compatibility option on the formatting screen and it will format in the "most compatible" mode (512 byte logical sectors).
WD Quick Formatter 2.0.0.65 doesn't work correctly in Windows XP: it successfully configures 4096 byte logical sectors, but fails to format correctly. Another tool can subsequently be used to partition and format the drive.
WD Quick Formatter 1.2.0.10 works correctly in Windows XP, but is not available for download from Western Digital anymore.
When the target drive is configured for the same logical sector size as the source, you can copy to it using dd and the copy will work without any need to alter the partition table.
I can confirm that these Western Digital external USB drives can be configured for XP compatibility:
Easystore 14 TB (WDBCKA0140HBK)
Easystore 12 TB (WDBCKA0120HBK)
Easystore 8 TB (WDBCKA0080HBK)
My Book Essential 1140, 3 TB (WDBACW0030HBK)
Elements 1021, 3 TB (WDBAAU0030HBK)
Best Answer
Yes, a lot of code in the world was written in the times of exclusive domination of 512-byte sectors. This code cannot handle any other sector size, so BIOS / disk hardware always emulates 512-bytes sectors regardless of actual sector size. Otherwise, 95% of operating systems just wouldn't boot from such disks at all.
There are boundaries in CHS addressing system. 1 ≤ S ≤ 63, 0 ≤ H ≤ 255 (and sometimes 0 ≤ C ≤ 1023). It is the reason why logical geometry exists and is different from the physical geometry.
Since Windows Vista,
FDISK
creates the first partition on LBA sector 2048 (1M alignment). It may have any CHS coordinates; they do not matter anymore.In Windows XP and previous versions, the first partition was created on CHS sector (C=0, H=1, S=1) which usually maps to LBA sector 63 (if logical geometry of this disk has 63 sectors per track). Some USB flash drives have logical geometry with 32 virtual sectors per track, so the first partition starts on LBA sector 32 for them. In any case, all of this has nothing to do with actual disk geometry, performance reasons, etc – it's a pure tradition, terminated in Vista/Windows 7.
Clusters are always aligned with the start of the partition. So they may be misaligned on disk, if the partition was created in pre-Vista
FDISK
and is misaligned itself.