我尝试将 sdb 克隆到 sdc,但由于边际大小不匹配而失败。我尝试使用 gdisk 进行恢复,但没有成功。我现在有什么选择可以从头开始?源磁盘有大量可用空间,我不需要克隆。
$ sudo dd if=/dev/sdb of=/dev/sdc bs=4M status=progress
1000165343232 bytes (1.0 TB, 931 GiB) copied, 100383 s, 10.0 MB/s[A
dd: error writing '/dev/sdc': No space left on device
238460+0 records in
238459+0 records out
$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: EXTERNAL_USB
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: gpt
Disk identifier: F051C4EE-2188-44D2-8988-A6BFB515F49B
Device Start End Sectors Size Type
/dev/sdb1 2048 644534271 644532224 307.3G unknown
/dev/sdb2 896489472 994146303 97656832 46.6G unknown
/dev/sdb3 644534272 675784703 31250432 14.9G Microsoft basic data
/dev/sdb4 675784704 896489471 220704768 105.2G unknown
/dev/sdb5 994146304 1105475583 111329280 53.1G unknown
Partition table entries are not in disk order.
$ sudo gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.9.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!
Main header: OK
Backup header: ERROR
Main partition table: OK
Backup partition table: ERROR
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.
****************************************************************************
答案1
fdisk -l
使用或比较 /dev/sdb 和 /dev/sdc 的分区布局gdisk -l
。如果它们都匹配,则忽略消息和并让 gdisk 写出正确的备份分区表(使用命令w
– 或者可能v
首先,然后w
)。
你可能还想使用x
(专家菜单)→ e
(将备份重新定位到磁盘末尾),或者 gdisk 可能会自动执行此操作,我不确定。
备份分区表从结尾磁盘,这意味着无论目标磁盘比源磁盘小还是大,都无法正确克隆。(例如,即使磁盘较大并且您有足够的空间,分区表最终也会离末尾太远而无法找到。)
以后克隆此类磁盘分两步进行:
- 仅使用克隆分区布局
sfdisk --dump
(这将在目标磁盘中正确生成分区表); - 使用常规
cp
/dd
(或其文件系统感知变体;例如,ntfsclone
支持跳过 NTFS 分区中未使用的空间,同时partclone
可以对 Ext4 执行相同操作)分别克隆每个分区。