How to Create a Headless VM on Ubuntu Using VirtualBox
You can create a headless Ubuntu virtual machine (VM) in VirtualBox using the VBoxManage command-line tool.
A headless VM runs without a graphical interface, ideal for server tasks or automation where direct visual interaction isn’t needed. VirtualBox is free software for running guest operating systems on your host PC.
The VBoxManage utility allows you to fully manage your VMs from the command line, essential for scripting and efficient administration. You’ll use specific commands to set up your VM without needing the VirtualBox GUI, as demonstrated with Ubuntu 24.04.
You create a headless VM on Ubuntu using VirtualBox with the VBoxManage command-line tool. First, create the VM using `VBoxManage createvm`, then configure its properties with `VBoxManage modifyvm`, and finally create and attach storage using `VBoxManage storagectl` and `VBoxManage createhd`.
Install VirtualBox
To create a virtual machine on VirtualBox, you first need to install VirtualBox. If you haven’t installed it yet, check out the post below for installation instructions.
Once VirtualBox is installed, you can start creating your VMs, as shown below.
Create VM directory
Before we create a virtual machine, let’s make a directory to store them.
Run the command below to create a directory for VirtualBox.
sudo mkdir /var/vbox
Create a virtual machine
Now that the VM directory has been created, run the command below to create an Ubuntu 24.04 virtual machine named [Ubuntu2404].
sudo VBoxManage createvm --name Ubuntu2404 --ostype Ubuntu_64 --register --basefolder /var/vbox
If the command is successful, you should see a message like the one below.
Virtual machine 'Ubuntu2404' is created and registered.
UUID: 613dde34-dfa1-4342-9a04-f54c19b44b19
Settings file: '/var/vbox/Ubuntu2404/Ubuntu2404.vbox'
Change VM properties
After creating the Ubuntu virtual machine, you can adjust its properties to modify the CPU, memory size, network settings, and more using the command below.
sudo VBoxManage modifyvm Ubuntu2404 --cpus 4 --memory 8192 --nic1 nat --boot1 dvd --vrde on --vrdeport 5001
Create the VM storage
After configuring the CPU, memory, and other parameters, execute the command below to create storage for the VM.
sudo VBoxManage storagectl Ubuntu2404 --name "Ubuntu2404_SATA" --add SATA
Next, create a hard drive from the storage created with the size by running the command below.
sudo VBoxManage createhd --filename /var/vbox/Ubuntu2404/Ubuntu2404.vdi --size 20480 --format VDI --variant Standard
If the command is successful, you should see something similar to the one below.
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: 703b125d-987c-41a1-a2c8-ba15baa2d7ec
Attach the hard drive created above.
sudo VBoxManage storageattach Ubuntu2404 --storagectl Ubuntu2404_SATA --port 1 --type hdd --medium /var/vbox/Ubuntu2404/Ubuntu2404.vdi
The VM should be created with storage and ready for your operating system. To check the VM details, run the command below.
sudo VBoxManage showvminfo Ubuntu2404
It should display something similar to the one below.
Name: Ubuntu2404
Encryption: disabled
Groups: /
Guest OS: Ubuntu (64-bit)
UUID: 613dde34-dfa1-4342-9a04-f54c19b44b19
Config file: /var/vbox/Ubuntu2404/Ubuntu2404.vbox
Snapshot folder: /var/vbox/Ubuntu2404/Snapshots
Log folder: /var/vbox/Ubuntu2404/Logs
Hardware UUID: 613dde34-dfa1-4342-9a04-f54c19b44b19
Memory size: 8192MB
Page Fusion: disabled
VRAM size: 8MB
CPU exec cap: 100%
HPET: disabled
CPUProfile: host
Chipset: piix3
Firmware: BIOS
Number of CPUs: 4
PAE: enabled
Long Mode: enabled
Triple Fault Reset: disabled
APIC: enabled
X2APIC: enabled
The VM is ready.
Attach Ubuntu installation ISO
If you wish to install Ubuntu OS on a VM, download and attach the ISO file.
Download Ubuntu ISO. Then, please attach it to the VM using the command below.
sudo VBoxManage storageattach Ubuntu2404 --storagectl Ubuntu2404_SATA --port 0 --type dvddrive --medium ~/Downloads/ubuntu-24.04.2-desktop-amd64.iso
Once the ISO is attached, you can start the VM using the command below.
sudo VBoxManage startvm Ubuntu2404 --type headless
If the command was successful, you will see a message similar to the one below.
Waiting for VM "Ubuntu2404" to power on...
VM "Ubuntu2404" has been successfully started.
You can connect to the VM using RDP client to the VM host, followed by the [vrdeport] port 5001 [VMHostIPaddress:vrdeport] to interact with the machine and continue the installation.
192.168.48.128:5001

Conclusion:
So, creating a headless virtual machine on VirtualBox with the command line in Ubuntu 24.04 isn’t too complicated. Here are the key points to remember:
- Preparation: Ensure VirtualBox is installed and a directory for VMs is created.
- VM Creation: This creates the virtual machine with the desired parameters.
- Configuration: Modify VM properties such as CPU and memory using
VBoxManage modifyvm. - Storage Setup: Create a storage controller and hard drive for the VM.
- ISO Attachment: Download the Ubuntu installation ISO and attach it to the VM.
- Launching: Start the VM in headless mode and connect using an RDP client for installation.
These steps will help you efficiently set up and manage virtual machines headlessly.
Can I run a VM headless?
Headless mode allows you to run a virtual machine in the background. UTM needs to be open while the headless virtual machine is running. To setup headless mode, open the virtual machine configuration and delete any display device as well as any serial device that is set to “Built-in Terminal” mode.
What is the difference between normal start and headless start in VirtualBox?
Virtualbox has three start modes: normal (with a window for the VM but window cannot be closed) headless start (no window for the VM, but you can see a screenshot in VBox UI) detachable start (a mix of the above two; window can be closed without turning off VM)
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard, a writer for Geek Rewind, is a tech enthusiast who loves breaking down complex IT topics into simple, easy-to-understand ideas. With years of hands-on experience in system administration and enterprise IT operations, he’s developed a knack for offering practical tips and solutions. Richard aims to make technology more accessible and actionable. He's deeply committed to the Geek Rewind community, always ready to answer questions and engage in discussions.
No comments yet — be the first to share your thoughts!