![如何在双启动笔记本电脑克隆硬盘后恢复 grub](https://linux22.com/image/1182138/%E5%A6%82%E4%BD%95%E5%9C%A8%E5%8F%8C%E5%90%AF%E5%8A%A8%E7%AC%94%E8%AE%B0%E6%9C%AC%E7%94%B5%E8%84%91%E5%85%8B%E9%9A%86%E7%A1%AC%E7%9B%98%E5%90%8E%E6%81%A2%E5%A4%8D%20grub.png)
我有一台双启动(Windows/Linux)笔记本电脑,配有 500GB SSD,我按照下面描述的步骤将 SSD 更换为 1TB SSD。当我重新启动时,它直接启动到 Windows,没有 grub 菜单。为什么会发生这种情况?我该如何恢复 grub 菜单?
这是我做的:
- 从实时启动盘启动笔记本电脑(运行 Linux Mint)
- 使用 dd 将整个 500GB SSD 复制到网络驱动器
- 关闭笔记本电脑并用 1GB SSD 替换 SSD。
- 使用实时启动棒再次启动并使用 dd 将网络驱动器上的文件复制回 SSD。
- 无需实时启动即可重启
我知道这会导致我的新 SSD 有一半未被使用;我希望稍后能解决这个问题。
dd 工作正常,或者至少我可以从启动棒挂载所有分区(包括活动分区)。这是输出fdisk -l
:
Disk /dev/loop0: 1.8 GiB, 1912557568 bytes, 3735464 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
GPT PMBR size mismatch (1000215215 != 1953525167) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
Disk /dev/nvme0n1: 931.53 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: KINGSTON SKC2500M81000G
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: 282E2059-1738-4156-802F-50E4A4E71652
Device Start End Sectors Size Type
/dev/nvme0n1p1 2048 1026047 1024000 500M EFI System
/dev/nvme0n1p2 1026048 1288191 262144 128M Microsoft reserved
/dev/nvme0n1p3 1288192 205020339 203732148 97.2G Microsoft basic data
/dev/nvme0n1p4 205021184 206086143 1064960 520M Windows recovery environment
/dev/nvme0n1p5 206088192 214087679 7999488 3.8G Linux swap
/dev/nvme0n1p6 214087680 969730047 755642368 360.3G Linux filesystem
/dev/nvme0n1p7 969730048 970651647 921600 450M Microsoft basic data
/dev/nvme0n1p8 970651648 997961727 27310080 13G Windows recovery environment
/dev/nvme0n1p9 997961728 1000204287 2242560 1.1G Windows recovery environment
Disk /dev/mapper/vg-root: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/vg-home: 300.32 GiB, 322462285824 bytes, 629809152 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/sda: 14.93 GiB, 16008609792 bytes, 31266816 sectors
Disk model: Cruzer Blade
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: dos
Disk identifier: 0x5b137364
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 0 3974271 3974272 1.9G 0 Empty
/dev/sda2 632 8567 7936 3.9M ef EFI (FAT-12/16/32)
/dev/sda3 3977216 31266815 27289600 13G 83 Linux
我尝试使用以下命令(从实时启动棒)重新安装 grub。这些命令有助于在较早的 Windows 更新后恢复 grub,并且运行时没有错误,但这次没有恢复 grub。
mount /dev/mapper/vg-root /mnt
mkdir /efi
mount /dev/nvme0n1p1 /efi
grub-install --directory=/mnt/usr/lib/grub/x86_64-efi --boot-directory=/mnt/boot --efi-directory=/efi
问题可能是由新磁盘的不同 UUID 引起的吗?我可能错了,但据我所知,磁盘 UUID 存储在磁盘本身上,因此应该与其余数据一起克隆。那么,可能出了什么问题,我该如何重新激活 grub?
以下是一些硬件详细信息:
笔记本电脑:戴尔 XPS 15(9550)
旧 SSD:PM951 NVMe SAMSUNG 512GB
新款 SSD:金士顿科技 KC2500 M.2 1000 GB PCI Express 3.0 3D TLC NVMe
Pastebin 链接:http://paste.ubuntu.com/p/DkMGvNXdYq/