Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mmonkey/5efc93145748c90ccbb509e7cc8e2f81 to your computer and use it in GitHub Desktop.
Save mmonkey/5efc93145748c90ccbb509e7cc8e2f81 to your computer and use it in GitHub Desktop.
[VirtualBox] Run Windows10 Headlessly on Linux

https://redplus.me/post/set-up-headless-windows-10-virtual-machine-on-remote-linux-server/ https://www.ostechnix.com/install-oracle-virtualbox-ubuntu-16-04-headless-server/ https://www.howtoforge.com/tutorial/running-virtual-machines-with-virtualbox-5.1-on-a-headless-ubuntu-16.04-lts-server/

VirtualBox Downloads

https://download.virtualbox.org/virtualbox/6.1.6

Add the Repository

sudo apt-add-repository "deb http://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib"
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -

Install VirtualBox

sudo apt-get update
sudo apt-get install virtualbox-6.1

Add User to vboxusers Group

sudo usermod -a -G vboxusers mmonkey
re-login for changes to take effect

Install Extension Pack

wget https://download.virtualbox.org/virtualbox/6.1.6/Oracle_VM_VirtualBox_Extension_Pack-6.1.6.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.6.vbox-extpack

Create Windows10 VM

VBoxManage createvm --name "Windows10" --ostype Windows10_64 --register
VBoxManage modifyvm "Windows10" --memory 8192
VBoxManage createhd --filename "VirtualBox VMs/Windows10/Windows10.vdi" --size 51200
VBoxManage storagectl "Windows10" --name "SAS Controller" --add sas --controller LSILogicSAS
VBoxManage storagectl "Windows10" --name "IDE Controller" --add ide --controller PIIX4
VBoxManage storageattach "Windows10" --storagectl "SAS Controller" --port 0 --device 0 --type hdd --medium "VirtualBox VMs/Windows10/Windows10.vdi"
VBoxManage storageattach "Windows10" --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium "/<path>/<to>/Windows10.iso"
VBoxManage storagectl "Windows10" --name "SAS Controller" --hostiocache on
VBoxManage modifyvm "Windows10" --vrde on
VBoxManage modifyvm "Windows10" --vrdeport 5000
VBoxManage modifyvm "Windows10" --cpus 4
VBoxManage modifyvm "Windows10" --nestedpaging on
VBoxManage modifyvm "Windows10" --largepages on
VBoxManage modifyvm "Windows10" --usb on
VBoxManage modifyvm "Windows10" --acpi on --nic1 bridged --bridgeadapter1 ens5
VBoxManage modifyvm "Windows10" --graphicscontroller vmsvga
VBoxManage modifyvm "Windows10" --accelerate3d on
VBoxManage modifyvm "Windows10" --vram 256

Running Windows10 VM

VBoxManage startvm "Windows10" --type headless
VBoxManage controlvm "Windows10" poweroff
VBoxManage controlvm "Windows10" reset
VBoxManage controlvm "Windows10" pause

Install VBoxGuestAdditions

VBoxManage storageattach "Windows10" --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium "/<path>/<to>/VBoxGuestAdditions.iso"

Remove boot media

VBoxManage storageattach "Windows10" --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium none

Display Resolution

VBoxManage setextradata global GUI/MaxGuestResolution any
VBoxManage setextradata "Windows10" CustomVideoMode1 1920x1080x32

Attaching a USB Device

VBoxManage list usbhost
VBoxManage controlvm "Windows10" usbattach <UUID>

Always attach a USB Device

VBoxManage list usbhost
VBoxManage usbfilter add 0 --target "Windows10" --name HardwareKey --vendorid 0x04b9 --productid 0x8004
VBoxManage usbfilter add 1 --target "Windows10" --name QE60Plus --vendorid 0x0b4d --productid 0x1112

Delete VM

VBoxManage unregistervm "Windows10" --delete`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment