我正在尝试克隆具有 PMBR 分区和坏扇区的 1TB 磁盘。该磁盘上有可用的 Windows 分区,并且可以通过 MBR 启动。
blkid
无法识别分区
/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:
我尝试使用gdisk
( 2
) ( r
) ( b
) ( w
) 但结果不想写
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 无法识别分区,我尝试了 gparted,Rescue system partitions
但它扫描了一整晚,什么也没得到。
使用: cfdisk /dev/sdc
工作正常
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
如何在 fedora 或 PartedMagic live 下挂载分区?谢谢
答案1
始终从对磁盘进行扇区级备份开始。使用例如ddrescue
或类似 之类的东西dd conv=noerror,notrunc,sync
,或者任何你认为合适的东西。低级工具是首选,因为它们可以让你更好地控制正在发生的事情。
我怀疑磁盘的一些前导扇区是坏的。这就是为什么 GPT 恢复效果不佳的原因。如果是这种情况(您可以通过在备份后阅读dmesg
或检查的输出dd
或日志文件来检查ddrescue
),您可能会成功执行以下操作:将此扇区级备份转储到与失败设备大小完全相同的设备上。然后尝试在克隆的设备上恢复分区表。
另外,如果您获得的分区表是正确的,您可以尝试使用或cfdisk
“手动”在内核中设置分区块设备(请阅读以了解详细信息)。partx
kpartx
man partx
不使用相同大小的附加设备来执行所有恢复操作的有效方法是使用 qemu 虚拟磁盘。您设置备份设备的映像覆盖,该设备将是您的故障磁盘或更好的备份映像文件:
qemu-img create -f qcow2 -b /dev/sdX -F raw /tmp/snap.qcow2
/tmp
必须有足够的空间来容纳所有“更新”的扇区,具体取决于故障规模,范围可能从几十兆字节到几千兆字节。sdX
是您的故障设备。
现在,将图像作为网络块设备附加到系统:
qemu-nbd -c /dev/nbd0 /tmp/snap.qcow2
您可能需要nbd
先加载模块。
写入/dev/nbd0
将最终进入snap.qcow2
,并且将从中执行读取(如果有这样的扇区),如果映像中仍然没有这样的扇区,则从后端设备执行读取。现在,对 执行所有恢复操作/dev/nbd0
,例如,尝试修复其上的 GPT,然后恢复分区。
答案2
我最终使用了 Nikita 的提示,并进行了模拟。
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
然后我使用了 2
,r
(恢复),l
(加载 MBR 并创建 GPT - 因为 GPT 分区已损坏), w
(写入磁盘)
clonezilla
不想工作,因为新磁盘较小,即使他们建议使用-C
跳过在命令行中检查目标磁盘大小,但它不起作用。因此直接镜像的命令行将是(使用 clonezilla)
sbin/ocs-onthefly -g auto -e1 auto -e2 -j2 -r -rescue -icds -C -v -sfsck -k -pa choose -f nbd1 -t sdb
我必须手动在新磁盘中创建分区,格式化它们,mount
然后使用rsync
最后一步是启动到 Windows 安装 USB - 修复模式。进入command prompt
diskpart
内部选择
list vol
- 列出卷
sel vol X
- 选择用于 UEFI 启动的第一个 FAT32 分区的卷
assign letter b:
- 分配字母以便能够写入启动 efi 启动
bcdboot c:\Windows /l en-us /s c: /f All
写入 MBR 记录(如果您需要传统启动)(假设系统磁盘在 C: 下)
bcdboot c:\Windows /s b: /f UEFI
- 将 EFI 启动记录写入 EFI 分区,以便您可以在新机器上启动。
这必须手动完成,但实际上这比使用 clonezilla、ddrescue 并尝试保存/复制分区要快得多。因此,如果您遇到类似问题,您可以节省一些时间。
问候