2022-09-29 12:27:36 +00:00
|
|
|
|
Building a VM with virt-install
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Introduction
|
|
|
|
|
|
|
|
|
|
This assumes that the network will be used in "macvtap" mode. This is
|
2022-09-29 19:41:36 +00:00
|
|
|
|
the preferred method, as it is faster than a regular bridge and does
|
|
|
|
|
not need any additional network configuration on the host.
|
2022-09-29 12:27:36 +00:00
|
|
|
|
|
|
|
|
|
The disadvantage of macvtap is that host-to-vm and vm-to-host
|
|
|
|
|
communication is blocked. This can be worked around with an
|
|
|
|
|
"internal" switch, or by having the macvtap connection bind to a
|
|
|
|
|
second interface.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Creating the VM
|
|
|
|
|
|
|
|
|
|
The following command assumes the OS is "rhel9.1" and the network
|
|
|
|
|
card is "eno1". It should be run as the root user or with sudo, and
|
|
|
|
|
should be run inside tmux for safety.
|
|
|
|
|
|
|
|
|
|
virt-install --name rhel9 \
|
|
|
|
|
--osinfo rhel9.1 \
|
2022-09-29 20:35:10 +00:00
|
|
|
|
--boot uefi \
|
2022-09-29 12:27:36 +00:00
|
|
|
|
--cdrom /var/lib/libvirt/isos/rhel-baseos-9.1-x86_64-dvd.iso \
|
2022-09-30 16:03:59 +00:00
|
|
|
|
--network type=direct,source=enp2s0,source_mode=bridge \
|
2022-09-29 20:35:10 +00:00
|
|
|
|
--graphics vnc \
|
2022-10-01 16:20:42 +00:00
|
|
|
|
--console pty,target.type=virtio \
|
2022-09-29 20:35:10 +00:00
|
|
|
|
--autoconsole none
|
2022-09-29 12:27:36 +00:00
|
|
|
|
|
|
|
|
|
Paths and names should be changed as appropriate. The VNC port can be
|
2022-09-29 20:35:10 +00:00
|
|
|
|
found for this example by running "virsh vncdisplay rhel9".
|
|
|
|
|
|
|
|
|
|
The disk will be created in the default location, which is normally
|
|
|
|
|
/var/lib/libvirt/images. To change this, add "path=/path/file.qcow2"
|
|
|
|
|
to the "--disk" option. Specify the size by adding "size=20" for a
|
2022-09-30 11:03:20 +00:00
|
|
|
|
20 GB disk.
|
2022-09-29 20:35:10 +00:00
|
|
|
|
|
2022-09-30 10:59:27 +00:00
|
|
|
|
|
|
|
|
|
Tips
|
|
|
|
|
|
2022-09-29 20:35:10 +00:00
|
|
|
|
For a virtio network card on Windows machines, add "model=virtio" to
|
|
|
|
|
the --network option.
|
2022-09-29 12:27:36 +00:00
|
|
|
|
|
2022-09-30 11:04:32 +00:00
|
|
|
|
Other useful options are "--memory 4096" for 4 GB RAM, and
|
2022-09-30 11:03:20 +00:00
|
|
|
|
"--vcpus 2" for a dual-CPU guest.
|
2022-09-29 19:32:24 +00:00
|
|
|
|
|
2022-09-29 12:27:36 +00:00
|
|
|
|
A list of supported operating systems can be found by running:
|
|
|
|
|
|
|
|
|
|
virt-install --osinfo list
|