2

I made an image with dd

sudo dd if=/dev/sda of=/path_to_external_drive/backup.img

Now I wanted to recover the system after the mount of all partitions went smoothly. When I make

sudo dd if=backup.img of=/dev/sda

I don't get any error messages until I try to boot the system.

I get the following error message from sudo fdisk -l because I wanted to see why the BIOS does not found any partition.

Partition 1 does not start on physical sector boundary

So I tried Disk Image Writer from my live stick but it says, that the image is 41 kB too large.

How can this happen and how can I fix it? Is there another way, besides buying a new SSD, to restore the system?

fdisk -l backup.img:

fdisk -l of the backup.img fdisk -l /dev/sda:

GPT PMBR size mismatch (976773247 != 976773167) will be corrected by w(rite).

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 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: dos
Disk identifier: 0x635f93a2

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1           1 976773247 976773247 465.8G ee GPT

Partition 1 does not start on physical sector boundary.

gdisk -l /dev/sda:

GPT fdisk (gdisk) version 1.0.1

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/sda: 976773168 sectors, 465.8 GiB  
Logical sector size: 512 bytes  
Disk identifier (GUID): 8DC2A4AA-C369-4ED8-B876-DCE0418A1BD0  
Partition table holds up to 128 entries  
First usable sector is 34, last usable sector is 976773214  
Partitions will be aligned on 2048-sector boundaries

Total free space is 4157 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name  
   1            2048          923647   450.0 MiB   2700  Basic data partition  
   2          923648         1128447   100.0 MiB   EF00  EFI system partition  
   3         1128448         1161215   16.0 MiB    0C01  Microsoft reserved ...  
   4         1161216       669571071   318.7 GiB   0700  Basic data partition  
   5       669571072       960290815   138.6 GiB   8300  
   6       960290816       976771071   7.9 GiB     8200  
  • 1
    Did you get that error for dd? Or is there some other step(s) involved you're not telling us about? – Henrik Apr 30 '17 at 8:15
  • I getet the error from fdisk -l will update it right now sorry – Sven Bamberger Apr 30 '17 at 8:16
  • So: After copying the image back with dd, you reboot, see that the BIOS doesn't like the disk, boot back into your live system and run fdisk which gives that error? I would have thought that worked. Are you sure you didn't just copy /dev/sda1 to your imge? Does the rest of fdisk's output (when I've seen similar error, it has always provided more output) look sane? – Henrik Apr 30 '17 at 8:22
  • It looks sane when I mount it and I can retrieve all the data by hand. All partitions are listed and fdisk also say it looks fine. – Sven Bamberger Apr 30 '17 at 8:23
  • That dd must have taken ages to run. Next time use cat. Did dd complete successfully or with an error? If it was successful, the image isn't too large and you need to address the next issue (partition alignment) – roaima Apr 30 '17 at 8:29
2

Your image file is 40KB larger than the disk (976773248 - 976773168 sectors). It can't work to dd the whole image to the disk. I guess your dd command was showing some warnings like "no space left" or something.

But you have luck. The last (6th) partition is just a swap partition. You could use gdisk and mkswap to resize the last partition and to correct the partition table:

$ gdisk /dev/sda

  1. remove the last partition
  2. repair the gpt partition table (should be done automatically)
  3. re-create the last partition (will be a bit smaller than before)

Then format the new swap partition:

$ mkswap /dev/sda6

Notes regarding interactive gdisk usage:

I cannot really predict what gdisk /dev/sda will show you. Type "h" for help. Type "d" and then "6" to remove last partition. "n" and "6" to re-create last partition. Exit and write your changes with "w". gdisk does not write anything unless you exit with "w". If unsure you can always exit/cancel by "q" or "ctrl-c".

  • Can you provide me the whole command please? – Sven Bamberger Apr 30 '17 at 10:05
  • I just deleted the swap partition and it worked. Thank you very very much – Sven Bamberger Apr 30 '17 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.