How to change the partition that grub loads from?

How to change the partition that grub loads from?

我的系统中安装了两个 M.2 NVMe 驱动器,从任何一个驱动器启动都会从第二个驱动器的第八个分区(18.04 安装)加载 grub。我通过查看 /boot/grub/grub.cfg 确认了这一点,它与 grub 菜单的内容相匹配。

据我了解其工作原理,这意味着两个磁盘上的 EFI 系统分区都“指向”nvme1n1p8。

我正在尝试为第二个驱动器的第七个分区上的 Ubuntu 20.04 安装设置内核参数,update-grub 会在那里更新 /boot/grub/grub.cfg,但我无法访问此菜单(例如,该菜单将显示 18.04 作为替代方案,主顶部条目为“Ubuntu”(转到 20.04))。

我认为我需要做的就是运行 install-grub 并选择要用哪个磁盘覆盖 grub。它应该会像我希望的那样指向 nvme1n1p7。

However I am curious if there is some kind of a less intrusive way to perform this edit. Maybe I could go dig around in the efi partition itself and edit whatever specifies the 8th partition with the 7th partition... This would be handy if for whatever reason I wanted to check (without actually booting and testing) from a running OS which ESP points at which partition. I'm skeptical that this would be practical vs. just trying it. But I'm curious how it works. But I definitely won't bother if it involves hexediting.

答案1

I had to install grub-efi-amd64 in order for grub-install to work, and i had to mount /dev/nvme1n1p1 to /boot/efi (which I mkdir'd), and then grub-install --target=x86_64-efi /dev/nvme1n1 worked and the grub that was set up now gets loaded.

Now I can decide which OS's grub menu and config to load by choosing which drive to boot from the motherboard UEFI boot menu.

相关内容