I'm trying to clone 1TB disk with PMBR partition and bad sectors. Which has working Windows partitions on it, and is bootable via MBR.
blkid
doesn't recognize partitions
/dev/sdc: PTTYPE="PMBR"
gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.7
Caution: invalid main GPT header, but valid backup; regenerating main header
from backup!
Caution! After loading partitions, the CRC doesn't check out!
Warning: Invalid CRC on main header data; loaded backup partition table.
Warning! Main and backup partition tables differ! Use the 'c' and 'e' options
on the recovery & transformation menu to examine the two tables.
Warning! One or more CRCs don't match. You should repair the disk!
Main header: ERROR
Backup header: OK
Main partition table: ERROR
Backup partition table: ERROR
Partition table scan:
MBR: hybrid
BSD: not present
APM: not present
GPT: damaged
Found valid MBR and corrupt GPT. Which do you want to use? (Using the
GPT MAY permit recovery of GPT data.)
1 - MBR
2 - GPT
3 - Create blank GPT
Your answer:
I tried in gdisk
with (2
) (r
) (b
) (w
) but result didn't want to write
Warning! Main partition table overlaps the first partition by 34 blocks!
You will need to delete this partition or resize it in another utility.
Warning! Secondary partition table overlaps the last partition by
17599083851618035976 blocks!
You will need to delete this partition or resize it in another utility.
Problem: partitions 121 and 119 overlap:
Partition 121: 925735787758310161 to 13474437941687892909
Partition 119: 11147454187938441805 to 15638604846186930334
Problem: partitions 121 and 120 overlap:
Partition 121: 925735787758310161 to 13474437941687892909
Partition 120: 3391649715396322562 to 7297187905800799496
Problem: partitions 122 and 120 overlap:
Partition 122: 3391649715396322562 to 7297187905800799496
Partition 120: 3391649715396322562 to 7297187905800799496
Problem: partitions 122 and 121 overlap:
Partition 122: 3391649715396322562 to 7297187905800799496
Partition 121: 925735787758310161 to 13474437941687892909
Problem: partitions 123 and 119 overlap:
Partition 123: 925735787758310161 to 13474437941687892909
Partition 119: 11147454187938441805 to 15638604846186930334
Problem: partitions 123 and 120 overlap:
Partition 123: 925735787758310161 to 13474437941687892909
Partition 120: 3391649715396322562 to 7297187905800799496
Problem: partitions 123 and 121 overlap:
Partition 123: 925735787758310161 to 13474437941687892909
Partition 121: 925735787758310161 to 13474437941687892909
Problem: partitions 123 and 122 overlap:
Partition 123: 925735787758310161 to 13474437941687892909
Partition 122: 3391649715396322562 to 7297187905800799496
Problem: partitions 124 and 119 overlap:
Partition 124: 10336404087008029236 to 15113227714779688721
Partition 119: 11147454187938441805 to 15638604846186930334
Problem: partitions 124 and 121 overlap:
Partition 124: 10336404087008029236 to 15113227714779688721
Partition 121: 925735787758310161 to 13474437941687892909
Problem: partitions 124 and 123 overlap:
Partition 124: 10336404087008029236 to 15113227714779688721
Partition 123: 925735787758310161 to 13474437941687892909
Aborting write operation!
Aborting write of new partition table.
clonezilla doesn't recognize partitions
I tried gparted and Rescue system partitions
but it was scanning all night and nothing.
using: cfdisk /dev/sdc
works fine
Disk: /dev/sdc
Size: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Label: dos, identifier: 0x9f9fd106
Device Boot Start End Sectors Size Id Type
>> /dev/sdc1 1 206846 206846 101M ee GPT
/dev/sdc2 * 206848 617201663 616994816 294.2G 7 HPFS/NTFS/exFAT
/dev/sdc3 617201664 1916342271 1299140608 619.5G 7 HPFS/NTFS/exFAT
/dev/sdc4 1916342272 1953316862 36974591 17.6G c0 unknown
Free space 1953316864 1953525167 208304 101.7M
How can I mount partitions under fedora or PartedMagic live? Thanks
I ended up using tips from Nikita, and made emulation
qemu-img create -f qcow2 -b /dev/sdc -F raw /tmp/snap.qcow2
dnf install nbd
modprobe nbd
qemu-nbd -c /dev/nbd0 /tmp/snap.qcow2
gdisk /dev/ndb0
Then I used
2
,r
(recover),l
(load MBR and create GPT - as GPT partition was corrupted),w
(write to disk)clonezilla
didn't want to work as new disk was smaller and even though they suggest to use-C
to skip checking target disk size in commandline, but it doesn't work. So command line for direct mirror would be (with clonezilla)sbin/ocs-onthefly -g auto -e1 auto -e2 -j2 -r -rescue -icds -C -v -sfsck -k -pa choose -f nbd1 -t sdb
I had to manually create partitions in the new disk, format them,
mount
them and usersync
The last step is to boot into Windows install USB - Repair mode. Go to
command prompt
diskpart
inside choose
list vol
- To list Volumessel vol X
- Select volume of the first FAT32 partition for UEFI bootassign letter b:
- Assign letter to be able to write boot efi bootbcdboot c:\Windows /l en-us /s c: /f All
write MBR record if you need legacy boot (Assuming System disk is under C:)bcdboot c:\Windows /s b: /f UEFI
- Write EFI boot record to EFI partition so you can boot on new machines.It has to be done manually, but it would actually be quicker then playing with clonezilla, ddrescue, trying to save/copy partitions. So if you come accross similar problem you can save some time.
Regards
Always begin with taking a sector-level backup of the disk. Do it with e.g.
ddrescue
or even something likedd conv=noerror,notrunc,sync
, or whatever you see as appropriate. The low-level tools are preferred, because they give you much more control on what's going.I suspect some of leading sectors of the disk is bad. That's why restoring of GPT doesn't work well. If that's the case (you can check this by reading
dmesg
or examining output ofdd
or logfile ofddrescue
after taking a backup), you may succeed with the following: dump this sector-level backup onto the device with exactly same size as failed one. Then try to restore partition table on the cloned device.Also, if the partition table you got with
cfdisk
is correct, you can try to set up partition block devices in the kernel "by hand" withpartx
orkpartx
(please, readman partx
for details).The promising way of doing all recovery operations without using additional device of equal size is to use qemu virtual disk. You set up an image overlay of backing device, which will be your faulty disk or better its backup image file:
/tmp
must have enough space to accomondate all "updated" sectors, depending on the failure scale that could range from just tens of megabytes to some gigabytes.sdX
is your faulty device.Now, attach the image to the system as a network block device:
You may need to load module
nbd
first.Writes to the
/dev/nbd0
will be end up intosnap.qcow2
, and reads will be performed from it, if there's such sector, and from backend device if there is still no such sector in the image. Now, do all recovery operations on the/dev/nbd0
, for instance, try to fix GPT on it and then recover partitions.