Posted on

Virtual Windows to VirtualBox

If you have a Windows Hyper-V device file you can clone it to work with VirtualBox

Most distibutions provides virtualbox in their package repos. You will also be needing VirtualBox Extension Pack which can be downloaded from the above link.

DISCLAIMER: Below instructions may not work with Mac OS.

To be able to attach USB storage devices or other USB devices you must assign the host user to the group ‘vboxusers’ manually. Check current group membership

$ groups
lp wheel network video audio storage users

Assign your user to the group

$ sudo gpasswd -a $USER vboxusers

Logoff to make the group membership active

In this document we assume the following to be the host

  • A modern CPU with at least 2 cores, 4GB RAM, Intel lydkort
  • We use english foldernames
  • You have a Hyper-V VHDX with a Windows 10
  • Our virtual machine is named “win10”

Create a folder for your virtual machine (NOTE: the escaped space in the VirtualBox foldername)

$ mkdir -P ~/VirtualBox\ VMs/win10

Clone the vhdx-file to vdi

$ VBoxManage clonehd /path/to/windows.vhdx ~/VirtualBox\ VMs/windows/win10.vdi

The GUI is an easier option so you don’t need to follow the instructions below because you can create the virtual machine using the GUI. Instead of creating a new virtual drive – select to attach the existing file which you create in the previous step.

Terminal commands

Create a new virtual machine

$ VBoxManage createvm --name "win10" --ostype "Windows10" --register

Setup ram and cpu – preferably your system has more than two cores – change the number of cpus accordingly

$ VBoxManage modifyvm "win10" --cpus 1 --memory 2048 --longmode on --ioapic on

Setup boot order

$ VBoxManage modifyvm "win10" --boot1 disk --boot2 dvd

Set graphics memory and monitor

$ VBoxManage modifyvm "win10" --vram 128 --monitorcount 1

Attach sound device

$ VBoxManage modifyvm "win10" --audio pulse --audiocontroller hda

Attach a mouse

$ VBoxManage modifyvm "win10" --usb on --usbehci on --mouse usbtablet

Create a network controller using NAT/DHCP

$ VBoxManage modifyvm "win10 --nic1 nat

Create a disk controller

$ VBoxManage storagectl "win10" --name "IDE" --add ide --controller PIIX4 --hostiocache on --bootable

Attach the virtual disk device

$ VBoxManage storageattach "win10" --storagectl "IDE" --port 0 --device 0 --type hdd --medium "win10.vdi"

Assign a an optical storage device

$ VBoxManage storageattach "win10" --storagectl "IDE" --port 1 --device 0 --type dvddrive --passthrough off --medium host:/dev/sr0

Create a shared folder pointing to your Linux-home-folder Documents

$ VBoxManage sharedfolder add "win10" --name $(basename $HOME) --hostpath $HOME/Documents --automount