Set Up Headless Windows 10 Virtual Machine on Remote Linux Server

I have a remote server with Intel E5 1620v2 CPU which supports VT-x, VT-d and EPT. The server runs with Debian Stretch and I need to set up a headless Window 10 virtual machine on it. After comparing different virtualizer products, I chose VirtualBox, which is free, and use Windows Remote Desktop as client.

Install Virtualbox on Debian Stretch

$ echo "deb http://download.virtualbox.org/virtualbox/debian stretch contrib" >> /etc/apt/sources.list
$ curl -O https://www.virtualbox.org/download/oracle_vbox_2016.asc
$ sudo apt-key add oracle_vbox_2016.asc
$ sudo apt-get update
$ sudo apt-get install virtualbox-5.1

Install VirtualBox Extension Pack for vrde support

$ wget http://download.virtualbox.org/virtualbox/5.1.22/Oracle_VM_VirtualBox_Extension_Pack-5.1.22-115126.vbox-extpack
$ sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.1.22-115126.vbox-extpack

Create Windows 10 virtual machine

Suppose that your Windows image was named Windows10.iso and located in /home/user/Windows10.iso

$ sudo VBoxManage createvm --name "Windows10" --ostype Windows10_64 --register
$ sudo VBoxManage modifyvm "Windows10" --memory 4096
$ sudo VBoxManage createhd --filename "Windows10.vdi" --size 50000
$ sudo VBoxManage storagectl "Windows10" --name "SAS Controller" --add sas --controller LSILogicSAS
$ sudo VBoxManage storagectl "Windows10" --name "IDE Controller" --add ide --controller PIIX4
$ sudo VBoxManage storageattach "Windows10" --storagectl "SAS Controller" --port 0 --device 0 --type hdd --medium "Windows10.vdi"
$ sudo VBoxManage storageattach "Windows10" --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium "/home/user/Windows10.iso"
$ sudo VBoxManage storagectl "Windows10" --name "SAS Controller" --hostiocache on
$ sudo VBoxManage modifyvm "Windows10" --vrde on
$ sudo VBoxManage modifyvm "Windows10" --vrdeport 5000
$ sudo VBoxManage modifyvm "Windows10" --cpus 2
$ sudo VBoxManage modifyvm "Windows10" --nestedpaging on
$ sudo VBoxManage modifyvm "Windows10" --largepages on
$ sudo VBoxManage natnetwork add --netname natnet1 --network "10.11.0.0/24" --enable
$ sudo VBoxManage natnetwork start --netname natnet1
$ sudo VBoxManage modifyvm "Windows10" --nic1 natnetwork --nat-network1 natnet1
$ sudo VBoxManage startvm "Windows10" --type headless

Now a rdp client can be used with host ip and port 5000 using VIrtualBox vrde feature to the guest to finish Windows10 installation. After installation, Windows remote desktop can be configured so we can have a better experience. Suppose guest ip was 10.11.0.2, we have to configure vm natnetwork for port forwarding.

$ sudo VBoxManage natnetwork modify --netname natnet1 --port-forward-4 "rdp:tcp:[]:5589:[10.11.0.2]:3389"

Now a rdp client can be used with host ip and port 5589 to rdp to the guest. If you also want to install VBoxGuestAdditions, you can change dvddrive medium.

$ sudo VBoxManage storageattach "Windows10" --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium "/usr/share/virtualbox/VBoxGuestAdditions.iso"

Then you can rdp to your guest to install VBoxGuestAdditions.

blackgiulia
blackgiulia

放眼四野直至星穹,追溯时光直至永恒,需要思考的事情太多,每个生命的时间太少

comments powered by Disqus
Next
Previous