如何将 GRUB 安装到使用 Ventoy 启动的 VDI 中?

如何将 GRUB 安装到使用 Ventoy 启动的 VDI 中?

我有一个 Ubuntu Server 22.04 安装,它从使用 Ventoy 启动的 VDI 映像运行,我正在尝试apt-get upgrade

当重新安装 GRUB 时,我收到以下消息:

The GRUB boot loader was previously installed to a disk that 
is no longer present, or whose unique identifier has changed 
for some reason. It is important to make sure that the       
installed GRUB core image stays in sync with GRUB modules and
grub.cfg. Please check again to make sure that GRUB is       
written to the appropriate boot devices.

1. /dev/sda2 (33 MB; ) on 32017 MB TS32GSSD420K
2. none of the above

(Enter the items or ranges you want to select, separated by 
spaces.)

GRUB install devices:

/dev/sda2是 Ventoy 的 EFI 分区,而不是 VDI 内部的分区。尝试以/dev/mapper/ventoy设备身份进入会导致同样的提示,因此我完成了升级而没有重新安装 GRUB,现在正在尝试修复它。

我照做了sudo grub-mkdevicemap,它给了我一个/boot/grub/device.map物理磁盘,如下所示:

(hd0)   /dev/disk/by-id/ata-TS32GSSD420K_D964580002
(hd1)   /dev/disk/by-id/ata-WDC_WD10EZEX-22MFCA0_WD-WCC6Y5ZE6VAL
(hd2)   /dev/disk/by-id/ata-WDC_WD10EZEX-60WN4A0_WD-WCC6Y1VULY52
(hd3)   /dev/disk/by-id/ata-Samsung_SSD_860_QVO_4TB_S4CXNF0M423112D

将内容更改为

(hd0)   /dev/mapper/ventoy

导致其中一个分区出现错误( ),并且参考输出(即 /boot)/dev/mapper/ventoy1中的先前错误也出现相同的错误。sudo apt-get upgrade/dev/mapper/ventoy2

ansel@enya:~$ sudo grub-install /dev/mapper/ventoy
Installing for x86_64-efi platform.
grub-install: error: cannot find a GRUB drive for /dev/mapper/ventoy1.  Check your device.map.
ansel@enya:~$

相关fdisk -l输出如下:

Disk /dev/sda: 29.82 GiB, 32017047552 bytes, 62533296 sectors
Disk model: TS32GSSD420K    
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: D0FA3E5E-2C2A-5658-FABE-84A0C9AE6291

Device        Start      End  Sectors  Size Type
/dev/sda1      2048 62467719 62465672 29.8G Linux filesystem
/dev/sda2  62467720 62533255    65536   32M EFI System

Disk /dev/mapper/ventoy: 16 GiB, 17179869184 bytes, 33554432 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
Disklabel type: gpt
Disk identifier: 2820B8E5-E365-41C4-94D9-B1DC8E03B3F2

Device                Start      End  Sectors  Size Type
/dev/mapper/ventoy1    2048  1103871  1101824  538M EFI Syste
/dev/mapper/ventoy2 1103872  4773887  3670016  1.8G Linux fil
/dev/mapper/ventoy3 4773888 33552383 28778496 13.7G Linux fil


Disk /dev/mapper/ventoy1: 538 MiB, 564133888 bytes, 1101824 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
Disklabel type: dos
Disk identifier: 0x00000000


Disk /dev/mapper/ventoy2: 1.75 GiB, 1879048192 bytes, 3670016 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/ventoy3: 13.72 GiB, 14734589952 bytes, 28778496 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

将各个分区的行添加到 /boot/grub/device.map 会导致 GRUB 说这些行无效并被忽略:

ansel@enya:~$ cat /boot/grub/device.map
(hd0)   /dev/mapper/ventoy
(hd0,1) /dev/mapper/ventoy1
(hd0,2) /dev/mapper/ventoy2
(hd0,3) /dev/mapper/ventoy3
ansel@enya:~$ sudo grub-install /dev/mapper/ventoy
Installing for x86_64-efi platform.
grub-install: warning: the device.map entry `hd0,1' is invalid. Ignoring it. Please correct or delete your device.map.
grub-install: warning: the device.map entry `hd0,2' is invalid. Ignoring it. Please correct or delete your device.map.
grub-install: warning: the device.map entry `hd0,3' is invalid. Ignoring it. Please correct or delete your device.map.
grub-install: error: cannot find a GRUB drive for /dev/mapper/ventoy1.  Check your device.map.
ansel@enya:~$

我怎样才能让 GRUB 识别各个分区?

谢谢。

相关内容