A year ago, my HDD was available from Windows but not mountable from Ubuntu. I used some table repair tools on Ubuntu but it just corrupted the GUID table. I fixed the table with Partition Wizard on Windows and went with it, nothing changed except that the end position of the logical partition was greater than the number of disk's sectors (info from gparted and sfdisk output).
So, having this output of sfdisk and following this (mixed up GPT and MBR) instruction
Disk /dev/sdb: 1.8 TiB, 2000397852160 bytes, 3907027055 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: gpt Disk identifier: 9F126AEE-463C-394E-A817-2AD9C33C6946 Device Start End Sectors Size Type /dev/sdb1 264192 3907028992 3906764800 1.8T Microsoft basic data
I altered the value of sdb1 size so that the number of the last sector is [maximum possible value given by sfdisk] = 3907027021 and rewrote it to /dev/sdb with sfdisk. After that ntfs partition is visible from Ubuntu and Windows but cannot be mounted.
Now I have the file from sfdisk with backup:
label: gpt label-id: 9F126AEE-463C-394E-A817-2AD9C33C6946 device: /dev/sdb unit: sectors first-lba: 34 last-lba: 3907027021 /dev/sdb1 : start= 264192, size= 3906764800, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=B5CAA620-E5FD-3343-B7A6-135065D0AD95
But it can't be written to /dev/sdb by the same procedure [sfdisk /dev/sdb < backup.txt] because it doesn't permit to set the value of the end sector greater than the number of disk sectors:
/dev/sdb1: The last usable GPT sector is 3907027021, but 3907028991 is requested. Failed to add #1 partition: Invalid argument
The version of sfdisk is 2.31.1. Info given by gpart:
GPT fdisk (gdisk) version 1.0.3 Type device filename, or press to exit: /dev/sdb Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Command (? for help): p Disk /dev/sdb: 3907027055 sectors, 1.8 TiB Model: ST2000DM001-9YN1 Sector size (logical/physical): 512/4096 bytes Disk identifier (GUID): 9F126AEE-463C-394E-A817-2AD9C33C6946 Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 3907027021 Partitions will be aligned on 2048-sector boundaries Total free space is 264158 sectors (129.0 MiB) Number Start (sector) End (sector) Size Code Name 1 264192 3907027021 1.8 TiB 0700 Command (? for help): v No problems found. 264158 free sectors (129.0 MiB) available in 1 segments, the largest of which is 264158 (129.0 MiB) in size.
Is it possible to repair the GUID table using remained information?