Linux USB HDD fix

I partitioned and formatted a 2TB HDD connected with an USB HDD adapter to a Debian system running under VMware, copied the files and moved the HDD to an old P4 system with Debian and a non-AHCI capable BIOS. The HDD showed up as a 232.9GB one:

1
2
Device     Boot Start       End   Sectors   Size Id Type
/dev/sdc1         256 488378645 488378390 232.9G 83 Linux

After googling a while I found out that the problem is with the BIOS reporting the HDD to the OS as if it had 512 bytes long sectors, not 4096 ones.

I could mount the ext4 file system with losetup by telling that it starts at byte no. 8*256 = 2048:

1
2
losetup /dev/loop0 /dev/sdc -o 2048
mount /dev/sdc1 /home/storage4

A permanent fix is to edit the HDD’s MBR partition table to have the file system start at the correct byte no. I exported the partition table to a text file with sfdisk:

1
sfdisk -d /dev/sdc > sdc.partitions.sfdisk.text

Then opened the file and edited the start value to 2048, and size to 8*488378390=3907027120. After that I wrote back the partition table to the drive:

1
cat sdc.partitions.sfdisk.text | sfdisk /dev/sdc

After running partprobe everything was all right again.

1
2
3
4
5
6
7
8
9
Disk /dev/sdc: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x0006aac3

Device     Boot Start        End    Sectors  Size Id Type
/dev/sdc1        2048 3907029167 3907027120  1.8T 83 Linux
Name (required)
E-mail (required - never shown publicly)
Webpage URL
Comment:
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> in your comment.

Trackback responses to this post

About me

Nonoo
I'm Nonoo. This is my blog about music, sounds, filmmaking, amateur radio, computers, programming, electronics and other things I'm obsessed with. ... »

Twitter

Listening now

My favorite artists