This guide shows how to install Ubuntu VMs on an Ubuntu 24.04 host using only command line options with virt-manager. By default, virt-manager wants to use a GUI installer, but we'll use the virt-install command line tool instead to create VMs that connect directly to your LAN via a network bridge.
What you'll learn:
- Create a persistent network bridge for LAN access
- Install Ubuntu VMs using serial console (no GUI needed)
- Manage VMs with virsh commands
- VMs will appear as separate devices on your network with their own IP addresses
Want to create a VM quickly without setting up bridging? Use this command after installing packages:
# Install packages first
sudo apt update
sudo apt install -y virt-manager libvirt-daemon-system libvirt-clients bridge-utils qemu-kvm
# Create VM with NAT (uses default virbr0)
sudo virt-install \
--name my-vm \
--disk path=/vm/my-vm.qcow2,size=20,bus=virtio,format=qcow2 \
--os-variant ubuntu20.04 \
--vcpus 2 \
--ram 2048 \
--location http://ftp.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/ \
--network bridge=virbr0,model=virtio \
--graphics none \
--extra-args='console=ttyS0,115200n8 serial'Follow the installer prompts, then get the IP with: sudo virsh net-dhcp-leases default
For LAN access (VMs get IPs from your router), continue reading below.
sudo apt update
sudo apt install -y virt-manager libvirt-daemon-system libvirt-clients bridge-utils qemu-kvmAdd your user to the libvirt group:
sudo usermod -aG libvirt $USERImportant: Log out and log back in after this command.
If you want your VMs to get IP addresses from your LAN DHCP server (instead of NAT), you need to create a network bridge first. Skip to Part 2 if you're okay with VMs using NAT (virbr0).
Find your active network interface:
ip link
# Or using NetworkManager
nmcli device statusLook for your physical interface (e.g., enp5s0, eth0, eno1). Note the name for later steps.
nmcli connection show --activeNote the connection name associated with your physical interface (e.g., "Wired connection 2").
Replace br0 with your desired bridge name and configure for DHCP:
sudo nmcli connection add type bridge ifname br0 con-name br0 \
ipv4.method auto ipv6.method auto connection.autoconnect yesReplace enp5s0 with your physical interface name:
sudo nmcli connection add type ethernet ifname enp5s0 \
con-name enp5s0-to-br0 master br0Warning: This will cause a brief network interruption (5-10 seconds).
First, bring down your existing connection (replace name):
sudo nmcli connection down "Wired connection 2"Then bring up the bridge:
sudo nmcli connection up br0Wait 5-15 seconds for DHCP to assign an IP:
# Watch for IP assignment
watch -n 1 ip addr show br0
# Or check periodically
ip addr show br0 | grep "inet "Check bridge status:
ip addr show br0You should see an IP address (e.g., inet 10.0.1.93/24).
Verify connectivity:
ping -c 3 8.8.8.8Check active connections:
nmcli connection show --active | grep -E "(br0|enp5s0)"You should see:
br0connection onbr0device (bridge)enp5s0-to-br0connection onenp5s0device (ethernet)
Bridge setup is complete! This configuration persists across reboots.
Before creating your VM, decide which networking mode to use:
Bridge Mode (br0) - Recommended if you completed Part 1
- VMs get IP addresses from your LAN DHCP
- VMs appear as separate devices on your network
- Easier to access from other devices
- Use
--network bridge=br0in virt-install command
NAT Mode (virbr0) - Default, no setup needed
- VMs use libvirt's built-in NAT network
- VMs get 192.168.122.x addresses
- VMs can access internet but are isolated from LAN
- Use
--network bridge=virbr0in virt-install command
The examples below use bridge=br0 (LAN mode). Replace with bridge=virbr0 for NAT mode.
sudo apt update
sudo apt install -y virt-manager libvirt-daemon-system libvirt-clients \
bridge-utils qemu-kvmsudo usermod -aG libvirt $USERImportant: Log out and log back in for group changes to take effect.
Verify:
groups | grep libvirtFor Ubuntu 24.04.4:
cd /vm
curl -L -o ubuntu-24.04.4-live-server-amd64.iso \
https://releases.ubuntu.com/24.04/ubuntu-24.04.4-live-server-amd64.isoThis will take several minutes (~2-3 GB download).
Verify download:
ls -lh ubuntu-24.04.4-live-server-amd64.iso
file ubuntu-24.04.4-live-server-amd64.isoFile size should be around 2.5-3 GB and type should be "ISO 9660".
Before creating the VM, confirm the bridge is up:
ip addr show br0 | grep "inet "You should see an IP address.
Run the virt-install command with your desired settings:
sudo virt-install \
--name openclaw-vm \
--disk path=/vm/openclaw-vm.qcow2,size=20,bus=virtio,format=qcow2 \
--os-variant ubuntu24.04 \
--vcpus 2 \
--ram 2048 \
--location /vm/ubuntu-24.04.4-live-server-amd64.iso,kernel=casper/vmlinuz,initrd=casper/initrd \
--network bridge=br0,model=virtio \
--graphics none \
--console pty,target_type=serial \
--extra-args='console=ttyS0,115200n8 serial'Parameters explained:
--name openclaw-vm- VM name (change as desired)--disk path=/vm/openclaw-vm.qcow2,size=20- Disk location and size (20 GB)--os-variant ubuntu24.04- OS type for optimization--vcpus 2- Number of CPU cores--ram 2048- RAM in MB (2 GB)--location- ISO path with kernel/initrd locations for console install--network bridge=br0- Connect to your bridge (use LAN DHCP)--graphics none- No GUI, serial console only--console pty,target_type=serial- Use serial console--extra-args- Kernel arguments for serial console
A text-based interactive wizard will launch in your terminal. Follow the prompts:
- Language selection - Choose your language
- Keyboard layout - Select keyboard
- Network configuration - Should auto-detect DHCP from your LAN (or NAT if using virbr0)
- Ubuntu archive mirror - Use default
- Storage configuration - Use entire disk (the virtual disk)
- Profile setup - Create username/password. Important: Make sure you set this up so you can SSH into the server later.
- SSH setup - Recommended: Install OpenSSH server so you can access the VM remotely
- Featured snaps - Select any additional software
The installation will continue and download/install packages. This takes a bit of time:
Make sure to select the OpenSSH server when prompted for additional packages:
Installation will take 10-20 minutes total. When complete, the VM will reboot.
After installation and reboot, press Ctrl + ] to disconnect from the VM console.
If using LAN bridge (br0):
Get the VM's IP address:
sudo virsh domifaddr openclaw-vmOr check your router's DHCP leases - the VM will appear as a separate device on your LAN.
If using default NAT (virbr0):
sudo virsh net-dhcp-leases defaultThis will show you the local IP address assigned by libvirt (usually 192.168.122.x).
Check running VMs:
sudo virsh list --allYou should see your VM in "running" state.
Via SSH (recommended):
ssh username@192.168.122.12Replace with your VM's IP address and the username you created during installation.
Via console:
sudo virsh console openclaw-vm(Press Ctrl + ] to exit)
Via SSH (if installed):
ssh username@<vm-ip-address>sudo virsh start openclaw-vmsudo virsh shutdown openclaw-vmsudo virsh destroy openclaw-vm(Don't worry - "destroy" just means force stop, not delete)
sudo virsh console openclaw-vmsudo virsh list --allsudo virsh dominfo openclaw-vmsudo virsh domifaddr openclaw-vmTo quickly shutdown and remove a VM:
sudo virsh destroy openclaw-vm
sudo virsh undefine openclaw-vm --remove-all-storage
sudo virsh list --allThis will:
- Force stop the VM (
destroy) - Remove the VM definition and all storage (
undefine --remove-all-storage) - List VMs to verify removal
Check if running:
sudo virsh list --state-runningIf running, stop it:
sudo virsh destroy openclaw-vmRemove the VM definition:
sudo virsh undefine openclaw-vm --remove-all-storageThe --remove-all-storage flag removes associated storage automatically.
If the disk file still exists:
ls -lh /vm/openclaw-vm.qcow2
sudo rm /vm/openclaw-vm.qcow2sudo virsh list --allThe VM should no longer appear in the list.
If you need to remove the bridge and return to direct connection:
sudo nmcli connection down br0Replace with your original connection name:
sudo nmcli connection up "Wired connection 2"If you want to completely remove the bridge configuration:
sudo nmcli connection delete br0
sudo nmcli connection delete enp5s0-to-br0Wait longer for DHCP:
# Wait and check every few seconds
for i in {1..15}; do
ip addr show br0 | grep "inet " && break
echo "Waiting for DHCP... ($i/15)"
sleep 1
doneRestart bridge manually:
sudo nmcli connection down br0 && sudo nmcli connection up br0- Check ISO path is correct:
ls -lh /vm/*.iso - Verify ISO isn't corrupted:
file /vm/*.iso(should be "ISO 9660") - For Ubuntu 24.04+, ensure you use the
--locationformat withkernel=casper/vmlinuz,initrd=casper/initrd
Try:
sudo virsh console openclaw-vm --forceOr check VM is running:
sudo virsh list --allCheck VM is using correct bridge:
sudo virsh domiflist openclaw-vmShould show br0 as the source. If not, you may need to recreate the VM with correct --network parameter.
Ensure you're in the libvirt group:
groups | grep libvirtIf not:
sudo usermod -aG libvirt $USERThen log out and back in.
In Step 3 of bridge creation, use:
sudo nmcli connection add type bridge ifname br0 con-name br0 \
ipv4.method manual ipv4.addresses 192.168.1.100/24 ipv4.gateway 192.168.1.1 \
ipv4.dns "8.8.8.8,8.8.4.4" ipv6.method auto connection.autoconnect yesChange size=20 to desired size in GB:
--disk path=/vm/openclaw-vm.qcow2,size=100,bus=virtio,format=qcow2--vcpus 4 \
--ram 8192 \For Ubuntu 20.04 (Focal), which has traditional debian-installer:
sudo virt-install \
--name focal-vm \
--disk path=/vm/focal-vm.qcow2,size=20,bus=virtio,format=qcow2 \
--os-variant ubuntu20.04 \
--vcpus 2 \
--ram 2048 \
--location http://ftp.ubuntu.com/ubuntu/dists/focal/main/installer-amd64/ \
--network bridge=br0,model=virtio \
--graphics none \
--extra-args='console=ttyS0,115200n8 serial'No ISO download needed - installs directly from network!
sudo virt-clone --original openclaw-vm --name openclaw-vm-clone \
--file /vm/openclaw-vm-clone.qcow2This guide covered:
- ✓ Creating a persistent network bridge with NetworkManager
- ✓ Installing virtualization packages
- ✓ Downloading Ubuntu ISO
- ✓ Creating and installing Ubuntu VM with serial console
- ✓ Managing VMs (start/stop/console)
- ✓ Removing VMs and cleaning up
- ✓ Troubleshooting common issues
Your VM now has full LAN access via the bridge and will receive DHCP addresses from your router, appearing as a separate device on your network.