How to Create a Headless VM on Ubuntu Using VirtualBox
A headless virtual machine on Ubuntu using VirtualBox runs in the background without opening a normal desktop window on your screen. This setup lets you run server software or test code without a graphical user interface taking up space on your desktop.
Oracle VM VirtualBox starts your Ubuntu 24.04 guest system directly in the background. You control the running virtual machine using a tool called VBoxManage, which runs right from your regular command prompt or terminal window.
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
Install VirtualBox on your system if you have not already done so.
Post-installation procedures allow immediate deployment of new virtual hardware configurations.
Create VM directory
To create a storage directory for your headless VM Ubuntu VirtualBox setup, you need to use the terminal to generate the required folder structure and virtual hardware profile. Running the VBoxManage command registers a new Ubuntu virtual machine on your system so you can configure its settings and install the operating system without a graphical interface.
Executing the command below generates the required VirtualBox directory structure.
Laying the groundwork starts with provisioning the virtual hardware profile. A command will create a new Ubuntu 24.04 VM, giving it a name so you can configure it later.
sudo VBoxManage createvm --name Ubuntu2404 --ostype Ubuntu_64 --register --basefolder /var/vbox
Successful execution yields a confirmation message resembling the output below.
Virtual machine 'Ubuntu2404' is created and registered.
UUID: 613dde34-dfa1-4342-9a04-f54c19b44b19
Settings file: '/var/vbox/Ubuntu2404/Ubuntu2404.vbox'
Change VM properties
Hardware parameters like processor count, allocated RAM, and networking configuration undergo modification using the command displayed below.
sudo VBoxManage modifyvm Ubuntu2404 --cpus 4 --memory 8192 --nic1 nat --boot1 dvd --vrde on --vrdeport 5001
Create the VM storage
To create the VM storage for your headless Ubuntu VirtualBox setup, you must configure a storage controller and a virtual hard disk file to house the operating system and user data. Using the VBoxManage command line tool allows you to set the disk format and file size in megabytes before attaching the new drive to your virtual machine.
You create a virtual hard drive from the storage by running the `VBoxManage createmedium disk` command. This command takes the storage's path and the desired disk size, for example, `VBoxManage createmedium disk --format VDI "path/to/your/disk.vdi" --size 20480` to create a 20GB disk image.
sudo VBoxManage createhd --filename /var/vbox/Ubuntu2404/Ubuntu2404.vdi --size 20480 --format VDI --variant Standard
Successful completion returns terminal feedback matching the example below.
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: 703b125d-987c-41a1-a2c8-ba15baa2d7ec
Attaching the newly generated hard drive requires the subsequent instruction.
sudo VBoxManage storageattach Ubuntu2404 --storagectl Ubuntu2404_SATA --port 1 --type hdd --medium /var/vbox/Ubuntu2404/Ubuntu2404.vdi
Populated with storage controllers, the environment stands ready for an operating system. Inspection of system parameters occurs through the query below.
sudo VBoxManage showvminfo Ubuntu2404
The console prints configuration details similar to this block.
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
Hardware provisioning reaches completion.
Attach Ubuntu installation ISO
To attach the Ubuntu installation ISO (an archive containing the operating system's setup files) to your headless VM in VirtualBox, you use the storageattach command in the terminal. Linking this installer image connects a virtual disc to the machine, allowing your virtual hardware to boot directly into the setup utility when you start the server.
Acquiring the installer image precedes binding it to the hardware profile via the terminal.
sudo VBoxManage storageattach Ubuntu2404 --storagectl Ubuntu2404_SATA --port 0 --type dvddrive --medium ~/Downloads/ubuntu-24.04.2-desktop-amd64.iso
Mounted installation media allows powering on the environment using the instruction below.
sudo VBoxManage startvm Ubuntu2404 --type headless
Proper execution triggers confirmation output comparable to the text below.
Waiting for VM "Ubuntu2404" to power on...
VM "Ubuntu2404" has been successfully started.
Establishing remote desktop connectivity requires pointing an RDP client toward the host alongside [vrdeport] port 5001 [VMHostIPaddress:vrdeport] to complete the operating system installation.
192.168.48.128:5001

Conclusion:
Running a virtual machine through the command line keeps resource overhead low.
- 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.
Following these procedures establishes efficient command-line virtualization management.
Was this guide helpful?
About the Author
Richard
Tech Writer, IT Professional
Richard is a writer at Geek Rewind who turns complex IT tasks into clear, step-by-step guides. He draws on years of hands-on experience in system administration and enterprise IT operations, focusing on Windows, Linux and WordPress: the problems people actually run into, and the fixes that work. His server and WordPress guides come from systems he runs himself. Richard builds and maintains the platform behind Geek Rewind, from its Ubuntu servers and Nginx configuration to its custom WordPress plugins. Many new tutorials start with readers' questions, and he's always glad to answer them in the comments.
No comments yet — be the first to share your thoughts!