WIndows 2019 Server on Virtualbox Headless
Create a virtual server on the system built here, and set it to startup automatically.
0 . Latest updates and prerequisites.
2023.10.01 – First draft, Windows 2019 Server on VirtualBox 7 for Ubuntu Server.
2024.10.27 – Updated for Ubuntu 24.04.
Leave a comment if the post is missing some detail.
Domain administrator permissions to move roles and services is required as well as access to the Virtualbox system. This posts assumes the steps on this post have been followed or a similar Virtualbox service is being used, on Ubuntu 24.04 or similar..
1 . Create a Windows Server guest profile.
Create somewhere convenient for ISO images on the server or within reach of the VirtualBox services:
sudo mkdir -p /opt/virtualbox/ISOs
sudo chown vbox:root /opt/virtualbox -R
sudo chown 775 /opt/virtualbox -R
Create a profile for a Windows 2019 Server using appropriate settings, including, connecting the vCD-ROM to the ISO file:
Start the virtual server and connect using an RDP client to the specified port, in this case, 9000:
Using the basic Microsoft Terminal Server Client, connect to the host address at the specified port:
2 . Start the Windows virtual machine and setup as required.
As in this post, using RDP to the guest console, setup the server; give the server a name, fixed IP and domain membership, etc.. Don’t forget the passthru key combination for ctrl-alt-del is ctrl-alt-end.
Restart the server and install all updates possible in the Operating system itself:
Make sure the server has a fixed IPv4 address with a matching DNS record or other, suitable network installation details in the current infrastructure.
3 . Create a startup file for the VirtualBox profile.
Create a start-up file on the VirtualBox server so the guest auto starts, replace “server_name”:
sudo nano /etc/systemd/system/server_name.service
Create a configuration as such, but with values for “your environment”vbox_username” and “server_name”:
[Unit]
Description=vm1
Requires=network.target
After=network.target virtualbox.service
Before=runlevel2.target shutdown.target
[Service]
User=vbox_username
Group=vboxusers
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStartPre=/bin/sleep 30
ExecStart=/usr/bin/VBoxManage startvm server_name --type headless
ExecStop=/usr/bin/VBoxManage controlvm server_name acpipowerbutton
ExecStopPost=/bin/sleep 30
[Install]
WantedBy=multi-user.target
Notice above, there is a pause before the start and after the stop to allow the server to gracefully complete its processes without being started too soon or shut off too early.
Enable the configuration:
systemctl enable server_name
Start the service if it is not yet:
systemctl start server_name
Check the service status:
systemctl status server_name
Should look like this:
root@server40:~# systemctl status server_name
● serve_name.service - vm1
Loaded: loaded (/etc/systemd/system/server_name.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2023-10-01 17:00:27 UTC; 33s ago
Process: 828 ExecStartPre=/bin/sleep 10 (code=exited, status=0/SUCCESS)
Process: 2452 ExecStart=/usr/bin/VBoxManage startvm server41 --type headless (code=exited, >
CPU: 42ms
Oct 01 17:00:16 server40 systemd[1]: Starting vm1...
Oct 01 17:00:27 server40 VBoxManage[2452]: Waiting for VM "server41" to power on...
Oct 01 17:00:27 server40 VBoxManage[2452]: VM "server41" has been successfully started.
Oct 01 17:00:27 server40 systemd[1]: Started vm1.
root@server40:~# systemctl status server41
● server41.service - vm1
Loaded: loaded (/etc/systemd/system/server41.service; enabled; vendor preset: enabled)
Active: active (exited) since Sun 2023-10-01 17:00:27 UTC; 9min ago
Process: 828 ExecStartPre=/bin/sleep 10 (code=exited, status=0/SUCCESS)
Process: 2452 ExecStart=/usr/bin/VBoxManage startvm server41 --type headless (code=exited, >
CPU: 42ms
Oct 01 17:00:16 server40 systemd[1]: Starting vm1...
Oct 01 17:00:27 server40 VBoxManage[2452]: Waiting for VM "server41" to power on...
Oct 01 17:00:27 server40 VBoxManage[2452]: VM "server41" has been successfully started.
Oct 01 17:00:27 server40 systemd[1]: Started vm1.
The server now starts as a service, with each boot. Depending on the resources available, more virtual servers can be added in a variety of configurations.
With virtualisation, it is important to use as fast as possible hardware to mitigate the resource contention that is inevitable.
4 . Supporting this blog.
This type of content takes a lot of effort to write. Each post is drafted, researched, then tested multiple times, even a simple step or detail might take more than a few hours to go from the idea to a published blog post.
Did you notice there are no adverts on this site?
If you feel I have saved you some time, you can support me by;
- hosting with DigitalOcean, like I do – click here to go to DigitalOcean.
- buying me a beer through PayPal – click here to go to PayPal.
©horsefreeglue.com, 2024. Unauthorized use and/or duplication of this material without express and written permission from this site’s author and/or owner is strictly prohibited. Excerpts and links may be used, provided that full and clear credit is given.