I just discovered today that one can create VirtualBox VMDK files that simply reference real partitions on local disks and, needless to say, got pretty excited. "This means I can boot my Windows 7 installation from VirtualBox running in Linux!"
I created the VMDK file like so:
sudo VBoxManage internalcommands createrawvmdk -filename .VirtualBox/Hard\ Disks/Windows\ 7\ Local.vmdk -rawdisk /dev/sdb -partitions 2,4,5
Partition 2 is my EFI boot partition, partition 4 is the Windows msft partition, and partition 5 is the actual NTFS Windows partition. This went off without a hitch, so I chowned the VMDK files to my current user so I can run them with my login user.
This led to the first hitch. I can't seem to add this image to VirtualBox as any user except root, and I'd really like to not run it as root if possible. Is there a workaround?
The next hitch is EFI. I enabled EFI booting in VirtualBox, but whenever I boot the EFI/Microsoft/Boot/bootmgfw.efi image, I see the following code:
BlXmiInitialize failed 0xc000009a
and it doesn't boot. Plus, having to use the actual UEFI shell to get things booting is at best a hassle.
How can I get my actual local Windows 7 installation booting as a non-root user from Linux in VirtualBox?
By adding your Linux user to the
disk group, you can use the VMDK drive as a non-root user:
sudo adduser me disk
I still can't get past the boot error, though.
I figured it might be because of other problems, so I tried using my Windows 7 installation disk for startup repair, but it doesn't seem to even see the Windows installation, as the disk prompts me to simply install Windows.
In order to resolve potential problems with it missing vital information, I did the following to create a VMDK of the entire disk, not just individual partitions:
VBoxManage internalcommands createrawvmdk -filename ".VirtualBox/Hard Disks/Windows 7 Local.vmdk" -rawdisk /dev/sdb
/dev/sdb is a virtual drive provided by a hardware Intel RAID card (RS2BL080).