Booting raw-disk windows 10 vm in virtualbox boots to grub shell

我是研究僧i 提交于 2019-12-09 12:36:10

问题


I have a dual-boot setup with Windows 10 and Kubuntu 18. Following instructions found from here and there I managed to get the Windows to run as guest in Kubuntu host as a VM using VirtualBox.

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

The first line is to avoid running VirtualBox as superuser.
When I boot the VM, I briefly see an error message

Boot Failed. EFI DVD/CDROM
SystemBootOrder not found. Initializing defaults.
Creating boot entry "Boot0003" with label "ubuntu" for file "\EFI\ubuntu\shimx64.efi"

and then end up in grub shell. Now, when I run the commands

insmod chain
set root=(hd0,gpt1)
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
boot

Windows boots and works just fine but entering these every time is not exactly smooth workflow. Any idea how to permanently fix this? Please note that I'd still like to be able to physically boot into both OS's.

Thanks,


回答1:


I had the same problem. I fixed it, but then updated my kernel and so grub re-un-fixed it for me! Figuring it out for the second time was quicker, but I figured it'd be even quicker next time to find my answer on StackOverflow!

My grub.cfg file in /boot/efi/EFI/ubuntu looked like this:

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

Because we have setup the VirtualBox vmdk file with only the selected partitions for Windows to work, the search.fs_uuid command was failing, $root was empty and so grub can't find $prefix/grub.cfg (/boot/grub/grub.cfg in my linux rootfs which is on sda6==gpt6)

I automated it by changing the EFI grub.cfg, note my EFI System partition is 2 not 1 as in your example:

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

Now if grub can find the cfg file it will give me the menu to select the boot as before, but if it can't - when I'm in VirtualBox - it'll just boot straight into Win10.

Hope this helps!



来源:https://stackoverflow.com/questions/51101487/booting-raw-disk-windows-10-vm-in-virtualbox-boots-to-grub-shell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!