← Back to blog
bpdubuntu

Creating an Ubuntu Server VM Entirely from the Command Line

31 October 2025bpd · ubuntu

Automate VM Creation with `virt-install`

While graphical tools are convenient, true automation comes from the command line. The ‘Ubuntu System Administration Guide’ demonstrates the power of the `virt-install` utility, which allows you to create and provision a new virtual machine with a single, comprehensive command.

The `virt-install` Command

The book provides an example command that specifies everything needed to create a new VM:

sudo virt-install --name ubuntu-guest --os-variant ubuntu20.04 --vcpus 2 --ram 2048 --location http://... --disk size=5 ...

This command defines the VM’s name, OS type, CPU and RAM allocation, the location of the installation media (a network URL in this case), and the disk size. Executing this command will start the VM and connect you to its console, allowing you to complete the standard text-based Ubuntu Server installation directly in your terminal.


This post is based from content of the book Ubuntu System adminstration guide. And the book can be found here https://www.amazon.com/stores/Mattias-Hemmingsson/author/B0FF5CQX13