Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

install, to provision new virtual machines; and virt-clone, to clone
existing virtual machines.


You can do similar things with virt-install as with vmbuilder,
shown earlier in this chapter. The major differences are the options available
and that virt-install can also make desktop images that include a GUI,
which is accessible using VNC. See Chapter 19, “Remote Access with SSH,
Telnet, and VNC,” for a discussion of VNC.


Here is an example:


Click here to view code image
matthew@seymour:~$ sudo virt-install -n hopper -r 512 --disk
path=/var/lib/libvirt/images/hopper.img,size=20 -c /dev/cdrom --
accelerate --
connect=qemu:///system --vnc --noautoconsole –v


This example includes the following options:


-n  hopper—Defines  the name    of  the new VM
-r 512—Specifies the amount of memory the virtual machine will be
allotted, in megabytes
—disk path=...—Specifies the path to the virtual disk, which can be a
file, a partition, or a logical volume (in this case, a 20GB file named
hopper.img in /var/lib/libvirt/images)
-c /dev/cdrom—Specifies the path to the host’s CD-ROM device
(though you can also use an ISO file)
—accelerate—Enables the use of the kernel’s acceleration
—connect—Defines the hypervisor to use
—vnc—Exports the guest using a VNC virtual console
—noautoconsole—Prevents automatic connection to the virtual
machine’s console
-v—Creates a fully virtualized guest

To copy a virtual machine, use virt-clone:


Click here to view code image
matthew@seymour:~$ sudo virt-clone -o hopper -n knuth -f
/var/lib/libvirt/images/
knuth.img –connect=qemu:///system


This example includes the following options:

Free download pdf