Skip to content

Instantly share code, notes, and snippets.

@0xSheepdog
Last active November 6, 2022 23:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xSheepdog/f064737b4264c80ffd85eb19a5383fbf to your computer and use it in GitHub Desktop.
Save 0xSheepdog/f064737b4264c80ffd85eb19a5383fbf to your computer and use it in GitHub Desktop.
howto create a new KVM guest at the CLI with virt-install
source: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/sect-guest_virtual_machine_installation_overview-creating_guests_with_virt_install
The following example installs a virtual machine from an ISO image:
# virt-install \
--name guest1-rhel7 \
--memory 2048 \
--vcpus 2 \
--disk size=8 \
--network default \
--cdrom /path/to/rhel7.iso \
--os-variant rhel7
The following example imports a virtual machine from a virtual disk image:
# virt-install \
--name guest1-rhel7 \
--memory 2048 \
--vcpus 2 \
--network default \
--disk /path/to/imported/disk.qcow \
--import \
--os-variant rhel7
The following example installs a virtual machine from a network location:
(The --location http://example.com/path/to/os option specifies that the installation tree is at the specified network location.)
# virt-install \
--name guest1-rhel7 \
--memory 2048 \
--vcpus 2 \
--network default \
--disk size=8 \
--location http://example.com/path/to/os \
--os-variant rhel7
The following example installs a virtual machine using PXE:
(When installing a virtual machine using the PXE boot protocol, both the --network option specifying a bridged network and the --pxe option must be specified.)
# virt-install \
--name guest1-rhel7 \
--memory 2048 \
--vcpus 2 \
--network default \
--disk size=8 \
--network=bridge:br0 \
--pxe \
--os-variant rhel7
The following example installs a virtual machine using a kickstart file:
(The initrd-inject and the extra-args options specify that the virtual machine will be installed using a Kickstarter file.)
# virt-install \
--name guest1-rhel7 \
--memory 2048 \
--vcpus 2 \
--network default \
--disk size=8 \
--location http://example.com/path/to/os \
--os-variant rhel7 \
--initrd-inject /path/to/ks.cfg \
--extra-args="ks=file:/ks.cfg console=tty0 console=ttyS0,115200n8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment