The virt-manager source contains not only virt-manager itself but also a collection of further helpful tools like virt-install, virt-clone and virt-viewer.
Virtual Machine Manager
The virt-manager package contains a graphical utility to manage local and remote virtual machines. To install virt-manager enter:
sudo apt install virt-manager
Since virt-manager requires a Graphical User Interface (GUI) environment it is recommended to be installed on a workstation or test machine instead of a production server. To connect to the local libvirt service enter:
virt-manager -c qemu:///system
You can connect to the libvirt service running on another host by entering the following in a terminal prompt:
virt-manager -c qemu+ssh://virtnode1.mydomain.com/system
The above example assumes that SSH connectivity between the management system and the target system has already been configured, and uses SSH keys for authentication. SSH keys are needed because libvirt sends the password prompt to another process.
Virtual Machine Viewer
The virt-viewer application allows you to connect to a virtual machine’s console like virt-manager reduced to the GUI functionality. virt-viewer does require a Graphical User Interface (GUI) to interface with the virtual machine.
To install virt-viewer from a terminal enter:
sudo apt install virt-viewer
Once a virtual machine is installed and running you can connect to the virtual machine’s console by using:
Similar to virt-manager, virt-viewer can connect to a remote host using SSH with key authentication, as well:
virt-viewer -c qemu+ssh://virtnode1.mydomain.com/system web_devel
Be sure to replace web_devel with the appropriate virtual machine name.
If configured to use a bridged network interface you can also setup SSH access to the virtual machine.
virt-install is part of the virtinst package.
It can help installing classic ISO based systems and provides a CLI options for the most common options needed to do so. To install it, from a terminal prompt enter:
sudo apt install virtinst
There are several options available when using virt-install. For example:
sudo virt-install -n web_devel -r 512 \ --disk path=/var/lib/libvirt/images/web_devel.img,bus=virtio,size=4 -c \ ubuntu-18.04-server-i386.iso --network network=default,model=virtio \ --graphics vnc,listen=0.0.0.0 --noautoconsole -v
There are much more arguments that can be found in the man page, explaining those of the example above one by one:
- -n web_devel
the name of the new virtual machine will be web_devel in this example.
- -r 512
specifies the amount of memory the virtual machine will use in megabytes.
- –disk path=/var/lib/libvirt/images/web_devel.img,size=4
indicates the path to the virtual disk which can be a file, partition, or logical volume. In this example a file named web_devel.img in the /var/lib/libvirt/images/ directory, with a size of 4 gigabytes, and using virtio for the disk bus.
- -c ubuntu-18.04-server-i386.iso
file to be used as a virtual CDROM. The file can be either an ISO file or the path to the host’s CDROM device.
provides details related to the VM’s network interface. Here the default network is used, and the interface model is configured for virtio.
- –graphics vnc,listen=0.0.0.0
exports the guest’s virtual console using VNC and on all host interfaces. Typically servers have no GUI, so another GUI based computer on the Local Area Network (LAN) can connect via VNC to complete the installation.
will not automatically connect to the virtual machine’s console.
- -v: creates a fully virtualized guest.
After launching virt-install you can connect to the virtual machine’s console either locally using a GUI (if your server has a GUI), or via a remote VNC client from a GUI-based computer.
The virt-clone application can be used to copy one virtual machine to another. For example:
virt-clone --auto-clone --original focal
- –auto-clone: to have virt-clone come up with guest names and disk paths on its own
- –original: name of the virtual machine to copy
Also, use -d or --debug option to help troubleshoot problems with virt-clone.
Replace focal and with appropriate virtual machine names of your case.
Warning: please be aware that this is a full clone, therefore any sorts of secrets, keys and for example /etc/machine-id will be shared causing e.g. issues to security and anything that needs to identify the machine like DHCP. You most likely want to edit those afterwards and de-duplicate them as needed.