You are not logged in.

#1 2012-09-18 04:37:41

thetrivialstuff
Member
Registered: 2006-05-10
Posts: 191

[solved] GUID partition table: 4K vs. 512-byte sectors; can I do both?

I have an apparently strange Western Digital hard drive (it's a 1 TB "red" model WD10EFRX, if anyone's seen these before). The problem is, when I directly connect it to the motherboard SATA, it reports 512-byte sectors. I initially partitioned it with a GUID partition table in this mode.

Now I'm using it externally, and when I connect it via a SATA-to-USB interface it reports 4K sectors, and I see this in the dmesg:

sd 9:0:0:0: [sdd] 244190646 4096-byte logical blocks: (1.00 TB/931 GiB)
sd 9:0:0:0: [sdd] No Caching mode page present
sd 9:0:0:0: [sdd] Assuming drive cache: write through
sdd: unknown partition table

From what I gather, it looks like the actual GPT is stored in LBA 1 -- which was at 512 bytes when I partitioned, and is at 4096 bytes now, so the partition table isn't found and I have no partitions.

Is it safe to recreate the same table now, when the drive is reporting 4K sectors, and effectively have two copies of the GPT? I'm not too concerned about the first sector, since the partitions were originally aligned to 2048 sectors (512-byte sectors, so aligned to 1 MB) -- lots of room between 4096 bytes into the disk and the start of the first partition -- but what about the last sector? I know GPT stores a backup at the very end of the disk; presumably that now be 4096 bytes from the end of the disk -- does that risk running into the end of the last partition, or would alignment have left a gap there?

~Felix.

Last edited by thetrivialstuff (2012-09-18 05:28:21)

Offline

#2 2012-09-18 05:32:37

thetrivialstuff
Member
Registered: 2006-05-10
Posts: 191

Re: [solved] GUID partition table: 4K vs. 512-byte sectors; can I do both?

OK, not quite solved, but sort of. Further reading on GPT reveals that it is NOT safe to attempt this, because the backup GPT location is also specified in relative LBA numbers -- starting at highest LBA - 32 or so, which is indeed encroaching on the tail end of a partition. GPT alignment in gdisk/cgdisk does not leave a margin that big at the end of the disk; it always goes to highest LBA - 32 for whatever sector size you're working in.

I found a workaround, though -- I used fdisk (not gdisk) to create an old-style MBR partition table on the front of the disk. Since that only alters the first 512 bytes of the disk, it didn't risk clobbering any partitions. The only tricky part was getting the partitions to align with where they were before, but I managed it and they are now accessible.

Of course, the disk is now broken if I try to access it with 512-byte sectors again, but there are no plans for that so it should be OK smile

~Felix.

Offline

Board footer

Powered by FluxBB