Quantcast
Viewing latest article 3
Browse Latest Browse All 5

Answer by Christian Burger for logical sector size changes depending on whether it is attached via USB or direct SATA

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'

Viewing latest article 3
Browse Latest Browse All 5

Trending Articles