
我用 dd 製作了一個圖像
sudo dd if=/dev/sda of=/path_to_external_drive/backup.img
現在我想在所有分割區掛載順利後恢復系統。當我做
sudo dd if=backup.img of=/dev/sda
在嘗試啟動系統之前,我沒有收到任何錯誤訊息。
我收到以下錯誤訊息,sudo fdisk -l
因為我想了解為什麼 BIOS 找不到任何分割區。
分區 1 不在實體磁區邊界上開始
因此,我嘗試使用 Live Stick 上的 Disk Image Writer,但它顯示該映像太大 41 kB。
怎麼會發生這種情況?除了購買新的SSD之外,還有其他方法可以恢復系統嗎?
fdisk -l 備份.img:
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
您的映像檔比磁碟大 40KB(976773248 - 976773168 磁區)。它不能將dd
整個映像寫入磁碟。我猜你的 dd 命令顯示了一些警告,例如「沒有剩餘空間」之類的。
但你有運氣。最後一個(第 6 個)分割區只是一個交換分割區。您可以使用gdisk and mkswap
調整最後一個分割區的大小並修正分割區表:
$ gdisk /dev/sda
- 刪除最後一個分割區
- 修復gpt分區表(應該自動完成)
- 重新建立最後一個分割區(會比以前小一點)
然後格式化新的交換分割區:
$ mkswap /dev/sda6
關於互動gdisk
使用的注意事項:
我無法真正預測gdisk /dev/sda
會向您展示什麼。輸入“h”尋求協助。鍵入“d”,然後鍵入“6”以刪除最後一個分割區。 “n”和“6”重新建立最後一個分區。退出並用“w”寫下您的更改。除非您使用「w」退出,否則 gdisk 不會寫入任何內容。如果不確定,您可以隨時透過「q」或「ctrl-c」退出/取消。