This guide covers installing Windows Server 2019 as a VirtualBox guest on Ubuntu Server, configuring it to auto-start via systemd, and migrating Active Directory Domain Services roles from an existing domain controller. The process applies when migrating services for security updates, hardware changes, or virtualisation.
Prerequisites
- VirtualBox 7 installed on Ubuntu Server (headless installation covered in the referenced post)
- Windows Server 2019 ISO image
- Domain administrator credentials
- Available IP address with matching DNS record in the existing domain
- Sufficient disk space for the virtual machine and ISO storage
Step 1: Prepare ISO Storage
Create a directory for ISO images on the VirtualBox host. The commands below assume a user named vbox runs the VirtualBox service. Adjust ownership and paths to match your installation.
sudo mkdir -p /opt/virtualbox/ISOs
sudo chown vbox:root /opt/virtualbox -R
sudo chmod 775 /opt/virtualbox -RCopy the Windows Server 2019 ISO to this directory.
Step 2: Create the Virtual Machine
Using the VirtualBox web interface or VBoxManage, create a new virtual machine with settings appropriate for Windows Server 2019. Allocate at least 2 GB RAM, 2 CPU cores, and 40 GB disk space. Attach the virtual CD-ROM to the Windows Server ISO.
Boot the guest and complete the Windows Server installation. When prompted, select Windows Server 2019 Standard or Datacenter depending on your licensing. Complete the initial administrator password setup.
Step 3: Configure Networking and Domain Membership
After the initial boot, configure a static IPv4 address on the guest that matches the DNS record you prepared. Set the DNS server to point to your existing domain controller.
Join the server to the domain using the System Properties dialog. The server will restart after joining the domain.
Step 4: Install Windows Updates
Before installing Active Directory services, install all available updates through Windows Update. This may require multiple passes and reboots. Continue until no further updates are offered.
Step 5: Configure Systemd Auto-Start
On the VirtualBox host, create a systemd service unit to start this guest automatically at boot. Replace server_name with the actual name of your virtual machine as it appears in VirtualBox, and replace vbox_username with the user account running VirtualBox.
sudo nano /etc/systemd/system/server_name.serviceAdd the following configuration:
[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.targetThe ExecStartPre and ExecStopPost delays give the virtual machine time to complete startup and shutdown processes without being interrupted.
Enable and start the service:
sudo systemctl enable server_name
sudo systemctl start server_nameCheck the service status:
systemctl status server_nameThe output should show the service as active with a message confirming the VM started successfully.
Restart the VirtualBox host to verify the guest starts automatically on boot.
Step 6: Install Active Directory Domain Services
On the Windows Server guest, open Server Manager. Use the Add Roles and Features wizard to install the Active Directory Domain Services and DNS Server roles.
After installation completes, promote the server to a domain controller using the Post-Deployment Configuration wizard in Server Manager. Select the option to add a domain controller to an existing domain. Provide domain administrator credentials when prompted.
The server will restart after promotion completes.
Step 7: Migrate FSMO Roles
If you intend to decommission the original domain controller, you must first transfer all Flexible Single Master Operations (FSMO) roles to the new server.
On the new domain controller, open PowerShell as Administrator and verify the current role holders:
netdom query fsmo
Transfer all five FSMO roles to the new server. Replace server_name with the hostname of the new domain controller.
Move-ADDirectoryServerOperationMasterRole server_name -OperationMasterRole 0,1,2,3,4
The role numbers correspond to:
- 0: PDC Emulator
- 1: RID Master
- 2: Infrastructure Master
- 3: Schema Master
- 4: Domain Naming Master
Confirm the transfer when prompted. Verify the roles moved successfully:
netdom query fsmo
Step 8: Decommission the Old Domain Controller
On the old domain controller, open Server Manager and use the Remove Roles and Features wizard to demote the server. This removes the Active Directory Domain Services role and restarts the server as a standalone member server.
After the old server restarts, remove it from the domain entirely if it is no longer needed.
Step 9: Clean Up Active Directory
On the new domain controller, open Active Directory Sites and Services. Expand the Sites container and locate any references to the old server. Delete the server object from the site configuration.
Open DNS Manager and check all forward and reverse lookup zones. Remove any DNS records still pointing to the old server’s IP address. Common locations include:
- A records in the domain zone
- SRV records under
_msdcs,_sites,_tcp, and_udp - PTR records in reverse lookup zones
Verify the domain is functioning correctly by logging in to a domain-joined workstation and confirming Group Policy updates, DNS resolution, and authentication all work as expected.
Troubleshooting
Virtual machine does not start automatically: Check the systemd service status with systemctl status server_name. Verify the service is enabled with systemctl is-enabled server_name. Check journalctl for error messages with journalctl -u server_name.
Role transfer fails: Confirm the new domain controller has replicated all directory partitions from the old server. Check replication status with repadmin /replsummary. Verify network connectivity and DNS resolution between domain controllers.
DNS errors after migration: Ensure the new domain controller is listed as a DNS server in the IP configuration of all domain-joined machines. Update DHCP scope options if DNS is assigned via DHCP. Force a DNS registration on the new server with ipconfig /registerdns.
AI assistance is used on this site for language, formatting, and turning research into a consistent template. It is not used to perform the underlying research or verify technical claims. Every command, configuration, and step in this post is tested by hand before publication.