Ubuntu – Partition table created with HDD connected via SATA-USB interface not recognized if the HDD is placed in laptop hard drive bay

partitioningsata

I created a dos/mbr partition table and some partitions using gparted, on a hard drive I connected to my laptop via a SATA-USB interface. I then placed the hard drive in my system hard drive bay and booted the system using a live USB. When I opened gparted, it did not recognize the partition table. I then created another partition table with the hard drive in the laptop's hard drive bay. When I removed the hard drive from the bay and connected it to my laptop via a SATA-USB interface, gparted was also not able to recognize the partition table. In both cases however, gparted was able to recognize the partition table on the hard drive, if I connect it to my laptop via the same interface with which I had created the partition table.

My question is how does the system differentiates between a partition table created in the hard drive bay and via a SATA-USB interface?

Best Answer

Idea: Cabling or interface (more likely, maybe) in the USB-thingie swaps around bits or bytes? (check for byte swapping by using conv=swab in reading disks partition data with dd while connected to USB and compare to non-USB readings?)


Example extraction of first 1024 bytes from /dev/sda; compare outputs from the same disk (do not change partionining!) connected on different interfaces - to verify that the disk will work on both:

$ sudo dd if=/dev/sda count=2 bs=512 | od -t x1z
2+0 records in
2+0 records out
1024 bytes (1,0 kB, 1,0 KiB) copied, 3,2652e-05 s, 31,4 MB/s
0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  >................<
*
0000660 00 00 00 00 00 00 00 00 f1 bf b3 5a 00 00 00 00  >...........Z....<
0000700 01 00 ee fe ff ff 01 00 00 00 af 6d 70 74 00 00  >...........mpt..<
0000720 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  >................<
*
0000760 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 aa  >..............U.<
0001000 45 46 49 20 50 41 52 54 00 00 01 00 5c 00 00 00  >EFI PART....\...<
0001020 cd 51 b7 99 00 00 00 00 01 00 00 00 00 00 00 00  >.Q..............<
0001040 af 6d 70 74 00 00 00 00 22 00 00 00 00 00 00 00  >.mpt....".......<
0001060 8e 6d 70 74 00 00 00 00 87 5a 9c c6 72 be b1 41  >.mpt.....Z..r..A<
0001100 b4 32 5c c5 c3 a2 93 6c 02 00 00 00 00 00 00 00  >.2\....l........<
0001120 80 00 00 00 80 00 00 00 e6 92 5a ce 00 00 00 00  >..........Z.....<
0001140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  >................<
*
0002000

$ lsblk will tell which devices you have connected. Note: the lines to read are the ones having disk on them, e.g:

$ lsblk -p
...
/dev/sda           8:0    0 931,5G  0 disk 
└─/dev/sda1        8:1    0 931,5G  0 part /DATA
/dev/nvme0n1     259:0    0 238,5G  0 disk 
├─/dev/nvme0n1p1 259:1    0   512M  0 part /boot/efi
└─/dev/nvme0n1p2 259:2    0   238G  0 part /

To compare: Same disk with conv=swab -- i.e. BAD DATA SHOWN --

$ sudo dd if=/dev/sda count=2 conv=swab bs=512 | od -t x1z
[sudo] password for hannu: 
2+0 records in
2+0 records out
1024 bytes (1,0 kB, 1,0 KiB) copied, 0,000940358 s, 1,1 MB/s
0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  >................<
*
0000660 00 00 00 00 00 00 00 00 bf f1 5a b3 00 00 00 00  >..........Z.....<
0000700 00 01 fe ee ff ff 00 01 00 00 6d af 74 70 00 00  >..........m.tp..<
0000720 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  >................<
*
0000760 00 00 00 00 00 00 00 00 00 00 00 00 00 00 aa 55  >...............U<
0001000 46 45 20 49 41 50 54 52 00 00 00 01 00 5c 00 00  >FE IAPTR.....\..<
0001020 51 cd 99 b7 00 00 00 00 00 01 00 00 00 00 00 00  >Q...............<
0001040 6d af 74 70 00 00 00 00 00 22 00 00 00 00 00 00  >m.tp....."......<
0001060 6d 8e 74 70 00 00 00 00 5a 87 c6 9c be 72 41 b1  >m.tp....Z....rA.<
0001100 32 b4 c5 5c a2 c3 6c 93 00 02 00 00 00 00 00 00  >2..\..l.........<
0001120 00 80 00 00 00 80 00 00 92 e6 ce 5a 00 00 00 00  >...........Z....<
0001140 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  >................<
*
0002000