Skip to content

Instantly share code, notes, and snippets.

@rikka0w0
Last active February 7, 2024 10:52
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save rikka0w0/4128493c75285ce62e8c0b46fe8a253e to your computer and use it in GitHub Desktop.
Save rikka0w0/4128493c75285ce62e8c0b46fe8a253e 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/

Installation

$ sudo nano /etc/apt/sources.list
      deb http://download.virtualbox.org/virtualbox/debian stretch contrib
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install linux-headers-$(uname -r) build-essential virtualbox-5.1 dkms
$ sudo systemctl status vboxdrv

Power management:

$ VBoxHeadless --startvm "Windows"
$ VBoxManage controlvm "Windows" poweroff
$ VBoxManage controlvm "Windows" reset
$ VBoxManage controlvm "Windows" pause

Create and config virtual machine:

VBoxManage createvm --name "Windows" --ostype Windows10_64 --register
VBoxManage modifyvm "Windows" --memory 3072 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 enp11s0
VBoxManage modifyvm "Windows" --cpus 2

VBoxManage createhd --filename "/root/VirtualBox VMs/Windows/Windows.vdi" --size 20000

VBoxManage storagectl "Windows" --name "IDE Controller" --add ide --controller PIIX4
VBoxManage storageattach "Windows" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium "/root/VirtualBox VMs/Windows/Windows.vdi"
VBoxManage storageattach "Windows" --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium "/root/VirtualBox VMs/Windows10_1803.iso"

VBoxManage modifyvm "Windows" --vrde on
VBoxManage modifyvm "Windows" --vrdeport 2233
VBoxManage modifyvm "Windows" --longmode on

Delete virtual machine from disk: VBoxManage unregistervm "Windows" --delete

DVD ISO: https://superuser.com/questions/741734/virtualbox-how-can-i-add-mount-a-iso-image-file-from-command-line

@sutra
Copy link

sutra commented Mar 19, 2022

And then what is the password to connect to the VNC port 2233?

@sutra
Copy link

sutra commented Mar 19, 2022

Resolved by VBoxManage modifyvm "Windows" --vrdeproperty VNCPassword=secret, and then the password is secret. Check https://docs.oracle.com/en/virtualization/virtualbox/6.0/admin/otherextpacks.html for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment