1

I used dd to clone a 500gb Hard Drive to a 256gb SSD before doing this I edited the partitions so that the last 280gb (roughly) was unallocated using GParted.

Eventually dd ran out of room at 240gb, the plan was that it would just not copy the unallocated space and the clone would be finished.

Unfortunately the GPT table is incorrect and I don't know how to sort it out.

GParted hated it and told me it would use a backup table which was the entire drive unallocated.

GPT Fdisk tells me there are 5 errors but with "p" it does say all partions are there. (this might be a good time to memtion it's a windows drive)

The DD I used sudo dd if=/dev/sda of=/dev/sdc status=progress

The Result :dd: writing to '/dev/sdc': No space left on device 468862125+0 records in 468862124+0 records out 240057407488 bytes (240 GB, 224 GiB) copied, 21466.2 s, 11.2 MB/s

GPT fdisk: Warning! Disk size is smaller than the main header indicates! and Caution: invalid backup GPT header, but valid main header; regenerating backup header from main header. then Warning! One or more CRCs don't match. You should repair the disk! it then says MBR Protective and GPT Damaged.

Upon "v": Caution: The CRC for the backup partition table is invalid. This table may be corrupt. This program will automatically create a new backup partition table when you save your partitions.

Problem: The secondary header's self-pointer indicates that it doesn't reside at the end of the disk. If you've added a disk to a RAID array, use the 'e' option on the experts' menu to adjust the secondary header's and partition table's locations.

Problem: Disk is too small to hold all the data! (Disk size is 468862124 sectors, needs to be 976773168 sectors.) The 'e' option on the experts' menu may fix this problem.

Problem: GPT claims the disk is larger than it is! (Claimed last usable sector is 976773134, but backup header is at 976773167 and disk size is 468862124 sectors. The 'e' option on the experts' menu will probably fix this problem

Partition(s) in the protective MBR are too big for the disk! Creating a fresh protective or hybrid MBR is recommended.

Identified 5 problems!^

Help would be greatly appreciated

 sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.3

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

Found valid GPT with protective MBR; using GPT.
Disk /dev/sda: 976773168 sectors, 465.8 GiB
Model: ST500LM034-2GH17
Sector size (logical/physical): 512/4096 bytes
Disk identifier (GUID): 43B49B18-460C-4EDB-B63D-195389ABF232
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 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 589831021 sectors (281.3 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1085439   529.0 MiB   2700  Basic data partition
   2         1085440         1290239   100.0 MiB   EF00  EFI system partition
   3         1290240         1323007   16.0 MiB    0C01  Microsoft reserved ...
   4         1323008       273028223   129.6 GiB   0700  Basic data partition
   5       273029120       274431999   685.0 MiB   2700  
   6       274434048       296837119   10.7 GiB    0700  Basic data partition
   7       297041920       387151871   43.0 GiB    0700  Basic data partition
$ sudo gdisk -l /dev/sdc
GPT fdisk (gdisk) version 1.0.3

Warning! Disk size is smaller than the main header indicates! Loading
secondary header from the last sector of the disk! You should use 'v' to
verify disk integrity, and perhaps options on the experts' menu to repair
the disk.
Caution: invalid backup GPT header, but valid main header; regenerating
backup header from main header.

Warning! One or more CRCs don't match. You should repair the disk!

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.
****************************************************************************
Disk /dev/sdc: 468862124 sectors, 223.6 GiB
Model: high speed      
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 43B49B18-460C-4EDB-B63D-195389ABF232
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 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 589831021 sectors (281.3 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048         1085439   529.0 MiB   2700  Basic data partition
   2         1085440         1290239   100.0 MiB   EF00  EFI system partition
   3         1290240         1323007   16.0 MiB    0C01  Microsoft reserved ...
   4         1323008       273028223   129.6 GiB   0700  Basic data partition
   5       273029120       274431999   685.0 MiB   2700  
   6       274434048       296837119   10.7 GiB    0700  Basic data partition
   7       297041920       387151871   43.0 GiB    0700  Basic data partition
Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
Pizza
  • 175
  • 1
  • 2
  • 11
  • Please [edit] and post the output of `sudo gdisk -l /dev/sdX` where `sdX` identifies the disk. Post the output for the new (target) disk and the old (source) disk. Judging by the `dd` command they are `sdc` and `sda` respectively. – Kamil Maciorowski Feb 17 '23 at 06:11
  • 1
    done: it it's long but it's what you asked for – Pizza Feb 17 '23 at 06:25
  • GPT has a backup partition table at the end of the disk. That's what the errors are about. By the way, use `bs=1M` if you don't want dd to take forever. – gronostaj Feb 17 '23 at 07:11
  • Thanks for putting the gdisk output in code I can't get it to do that for multi line. – Pizza Feb 17 '23 at 07:20
  • gronostaj, Wish I'd known that dd speed trick earlier thanks – Pizza Feb 17 '23 at 07:54

1 Answers1

3

The problem is the backup GPT was at the very end of the source disk, it is now expected to be at the very end of the target disk. But disk sizes differ and dd wrote data as-is, so it did not copy the backup GPT to the right place (in your case dd did not get to the backup GPT of the source disk at all).

Now the important things are:

  • Logical sector sizes do match. Good. (If they didn't, the partition table would be way off; compare this case where a USB enclosure changed the logical sector size.)

  • Partitions fit the new disk. I understand you had deliberately moved data to make it fit the smaller disk. Good.

  • There is room for the backup GPT (33 last sectors not allocated to any partition). Good.

Run sudo gdisk /dev/sdc and tell it to write the partition table again. This should create the missing backup GPT.

Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
  • Thank You! Worked perfectly, haven't booted it yet put it shows up fine in GParted. :) – Pizza Feb 17 '23 at 07:53
  • Once you called `gdisk /dev/sdc` (as root or prefixed by `sudo`), hit the `?` (Help) to get the list of commands. Then press the `w` key on your keyboard. `gdisk` will detect that the secondary GPT header is too early on the disk and will propose to fix it. This is what Kamil Macriorowski explains. Just wanted to make it more obvious. – OuzoPower Apr 22 '23 at 10:53
  • Had the same issue when I did a DD to clone the partitions onto a smaller disk. Having Gdisk re-write the backup partition corrected the GParted Error. – armitus Aug 27 '23 at 23:40