virtual-machine - 在 virtualbox 中引导原始磁盘 Windows 10 vm 引导到 grub shell

标签 virtual-machine virtualbox raw-disk

我有一个 Windows 10 和 Kubuntu 18 的双引导设置。按照从这里和那里找到的说明,我设法让 Windows 在 Kubuntu 主机中作为 guest 运行,作为使用 VirtualBox 的 VM。

sudo usermod -a -G disk $USER
VBoxManage internalcommands createrawvmdk -filename "/path/to/vm/win10.vmdk" -rawdisk /dev/sda -partitions 1,3,4 -relative

第一行是避免以 super 用户身份运行 VirtualBox。
当我启动 VM 时,我简要地看到一条错误消息
Boot Failed. EFI DVD/CDROM
SystemBootOrder not found. Initializing defaults.
Creating boot entry "Boot0003" with label "ubuntu" for file "\EFI\ubuntu\shimx64.efi"

然后最终进入 grub shell。现在,当我运行命令时
insmod chain
set root=(hd0,gpt1)
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
boot

Windows 启动并工作得很好,但每次输入这些都不是完全顺利的工作流程。知道如何永久解决这个问题吗?
请注意,我仍然希望能够物理启动到两个操作系统。

谢谢,

最佳答案

我有同样的问题。我修复了它,但随后更新了我的内核,因此 grub 为我重新修复了它!第二次弄清楚会更快,但我认为下次在 StackOverflow 上找到我的答案会更快!

我在/boot/efi/EFI/ubuntu 中的 grub.cfg 文件如下所示:

search.fs_uuid 47d6233f-c0ae-4f89-bf18-184452eac803 root hd0,gpt6
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg

因为我们已经设置了 VirtualBox vmdk 文件,其中只有选定的 Windows 分区才能工作,所以 search.fs_uuid 命令失败了,$root 是空的,所以 grub 找不到 $prefix/grub.cfg (/boot/grub/grub .cfg 在我的 linux rootfs 中,它位于 sda6 ==gpt6)

我通过更改 EFI grub.cfg 来自动化它,注意我的 EFI 系统分区是 2 而不是 1,如您的示例所示:
search.fs_uuid 47d6233f-c0ae-4f89-bf18-184452eac803 root hd0,gpt6 
set prefix=($root)'/boot/grub'
if [ -f $prefix/grub.cfg ]
then
    configfile $prefix/grub.cfg
else
    insmod chain
    set root=(hd0,gpt2)
    chainloader /EFI/Microsoft/Boot/bootmgfw.efi
    boot
fi

现在,如果 grub 可以找到 cfg 文件,它将像以前一样为我提供选择启动的菜单,但如果不能 - 当我在 VirtualBox 中时 - 它只会直接启动到 Win10。

希望这可以帮助!

关于virtual-machine - 在 virtualbox 中引导原始磁盘 Windows 10 vm 引导到 grub shell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51101487/

相关文章:

node.js - 连接到 azure 虚拟机上的 Node.js 服务器

networking - virtualbox 客户端机器 : host name lookup failure in telnet while the same hostname lookup success in ping

c - C 中的文件系统 VS 原始磁盘基准测试

cloud - 在 OpenStack 中创建 VM 的克隆

hadoop - 哪个最好 : Apache Ambari cluster on Physical system with 5 Machine or install on virtual machine with diffrent 5 VM?

windows - 在 Windows 上使用 VirtualBox 为 Kubernetes 创建 Docker 容器

c++ - Windows,打开原始磁盘

azure - Microsoft Lync 能否在 Windows Azure 虚拟机角色上运行?

java - 为什么我的虚拟机中的 R 计算不一致?