Восстановление GPT table




$ sudo fdisk -l
Disk /dev/loop0: 1.99 GiB, 2109763584 bytes, 4120632 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop1: 55.48 MiB, 58159104 bytes, 113592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop2: 218.102 MiB, 229629952 bytes, 448496 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop3: 64.79 MiB, 67915776 bytes, 132648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop4: 51.4 MiB, 53522432 bytes, 104536 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/loop5: 31.9 MiB, 32595968 bytes, 63664 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 465.78 GiB, 500107862016 bytes, 976773168 sectors
Disk model: ST9500325AS     
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb4c0c308

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 976773119 976771072 465.8G 83 Linux




The primary GPT table is corrupt, but the backup appears OK, so that will be used.
Disk /dev/sdb: 111.81 GiB, 120034123776 bytes, 234441648 sectors
Disk model: KINGSTON SUV400S
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: FFF7340C-E82C-4993-B6FC-93951390DBF4

Device       Start       End   Sectors   Size Type
/dev/sdb1     2048   1050623   1048576   512M EFI System
/dev/sdb2  1050624 234440703 233390080 111.3G Linux filesystem


Disk /dev/sdc: 7.32 GiB, 7851737088 bytes, 15335424 sectors
Disk model: Transcend 8GB   
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x77bdca59

Device     Boot Start      End  Sectors  Size Id Type
/dev/sdc1  *     2048 15335423 15333376  7.3G  c W95 FAT32 (LBA)


Disk /dev/mapper/luks-07986967-d5d7-42ea-ae95-349367c8242b: 465.78 GiB, 500104691712 bytes, 976766976 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

$ sudo sfdisk -d /dev/sdb > PT_sdb.txt
The primary GPT table is corrupt, but the backup appears OK, so that will be used.

$ sudo gdisk /dev/sdb
GPT fdisk (gdisk) version 1.0.5

Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!

Warning: Invalid CRC on main header data; loaded backup partition table.
Warning! One or more CRCs don't match. You should repair the disk!
Main header: ERROR
Backup header: OK
Main partition table: OK
Backup partition table: OK

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: damaged

****************************************************************************
Caution: Found protective or hybrid MBR and corrupt GPT. Using GPT, but disk
verification and recovery are STRONGLY recommended.
****************************************************************************

Command (? for help): p
Disk /dev/sdb: 234441648 sectors, 111.8 GiB
Model: KINGSTON SUV400S
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): FFF7340C-E82C-4993-B6FC-93951390DBF4
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 234441614
Partitions will be aligned on 2048-sector boundaries
Total free space is 2925 sectors (1.4 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00  EFI System Partition
   2         1050624       234440703   111.3 GiB   8300  

Command (? for help): b
Enter backup filename to save: back-up-gpt-data-to-a-file
The operation has completed successfully.

Command (? for help): i
Partition number (1-2): 1
Partition GUID code: C12A7328-F81F-11D2-BA4B-00A0C93EC93B (EFI system partition)
Partition unique GUID: B896E463-C105-4953-A875-7CFE63F72D3D
First sector: 2048 (at 1024.0 KiB)
Last sector: 1050623 (at 513.0 MiB)
Partition size: 1048576 sectors (512.0 MiB)
Attribute flags: 0000000000000000
Partition name: 'EFI System Partition'

Command (? for help): i
Partition number (1-2): 2
Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)
Partition unique GUID: 0A0D4866-A85A-4394-982F-C2DC4E80AD7A
First sector: 1050624 (at 513.0 MiB)
Last sector: 234440703 (at 111.8 GiB)
Partition size: 233390080 sectors (111.3 GiB)
Attribute flags: 0000000000000000
Partition name: ''

Command (? for help): l
Type search string, or Enter to show all codes: 
0700 Microsoft basic data                0c01 Microsoft reserved                
2700 Windows RE                          3000 ONIE boot                         
3001 ONIE config                         3900 Plan 9                            
4100 PowerPC PReP boot                   4200 Windows LDM data                  
4201 Windows LDM metadata                4202 Windows Storage Spaces            
7501 IBM GPFS                            7f00 ChromeOS kernel                   
7f01 ChromeOS root                       7f02 ChromeOS reserved                 
8200 Linux swap                          8300 Linux filesystem                  
8301 Linux reserved                      8302 Linux /home                       
8303 Linux x86 root (/)                  8304 Linux x86-64 root (/)             
8305 Linux ARM64 root (/)                8306 Linux /srv                        
8307 Linux ARM32 root (/)                8308 Linux dm-crypt                    
8309 Linux LUKS                          830a Linux IA-64 root (/)              
830b Linux x86 root verity               830c Linux x86-64 root verity          
830d Linux ARM32 root verity             830e Linux ARM64 root verity           
830f Linux IA-64 root verity             8310 Linux /var                        
8311 Linux /var/tmp                      8400 Intel Rapid Start                 
8500 Container Linux /usr                8501 Container Linux resizable rootfs  
8502 Container Linux /OEM customization  8503 Container Linux root on RAID      
8e00 Linux LVM                           a000 Android bootloader                
a001 Android bootloader 2                a002 Android boot 1                    
Press the Enter key to see more codes, q to quit: p
a003 Android recovery 1                  a004 Android misc                      
a005 Android metadata                    a006 Android system 1                  
a007 Android cache                       a008 Android data                      
a009 Android persistent                  a00a Android factory                   
a00b Android fastboot/tertiary           a00c Android OEM                       
a00d Android vendor                      a00e Android config                    
a00f Android factory (alt)               a010 Android meta                      
a011 Android EXT                         a012 Android SBL1                      
a013 Android SBL2                        a014 Android SBL3                      
a015 Android APPSBL                      a016 Android QSEE/tz                   
a017 Android QHEE/hyp                    a018 Android RPM                       
a019 Android WDOG debug/sdi              a01a Android DDR                       
a01b Android CDT                         a01c Android RAM dump                  
a01d Android SEC                         a01e Android PMIC                      
a01f Android misc 1                      a020 Android misc 2                    
a021 Android device info                 a022 Android APDP                      
a023 Android MSADP                       a024 Android DPO                       
a025 Android recovery 2                  a026 Android persist                   
a027 Android modem ST1                   a028 Android modem ST2                 
a029 Android FSC                         a02a Android FSG 1                     
a02b Android FSG 2                       a02c Android SSD                       
Press the Enter key to see more codes, q to quit: q


Command (? for help): p
Disk /dev/sdb: 234441648 sectors, 111.8 GiB
Model: KINGSTON SUV400S
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): FFF7340C-E82C-4993-B6FC-93951390DBF4
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 234441614
Partitions will be aligned on 2048-sector boundaries
Total free space is 2925 sectors (1.4 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00  EFI System Partition
   2         1050624       234440703   111.3 GiB   8300  

Command (? for help): v

No problems found. 2925 free sectors (1.4 MiB) available in 2
segments, the largest of which is 2014 (1007.0 KiB) in size.

Command (? for help): p
Disk /dev/sdb: 234441648 sectors, 111.8 GiB
Model: KINGSTON SUV400S
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): FFF7340C-E82C-4993-B6FC-93951390DBF4
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 234441614
Partitions will be aligned on 2048-sector boundaries
Total free space is 2925 sectors (1.4 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1050623   512.0 MiB   EF00  EFI System Partition
   2         1050624       234440703   111.3 GiB   8300  

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.