Difference between revisions of "Virt-install"

From wikieduonline
Jump to navigation Jump to search
 
(104 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Draft}}
+
{{lowercase}}
<code>[[virt-install]]</code> is part of <code>[[virtinst]]</code> package.
+
<code>[[virt-install]]</code> script is part of <code>[[virtinst]]</code> package.  
 
* https://linux.die.net/man/1/virt-install
 
* https://linux.die.net/man/1/virt-install
 +
* https://github.com/virt-manager/virt-manager/blob/master/man/virt-install.rst
  
  
virt-install --prompt
 
  
== '''virt-install --import''' ==
+
== Options ==
 +
* <code>[[--cloud-init]]</code> since 3.0.0 (Sep 2020) <ref>https://github.com/virt-manager/virt-manager/blob/master/NEWS.md#release-300-september-15-2020</ref>
 +
* <code>--unattended</code> Since release 2.2.0 (June 17, [[2019]])
 +
* <code>[[--install]] fedora29</code> since release 2.2.0 (June 17, [[2019]]) (See also: [[libosinfo]])
 +
* <code>[[virt-install --prompt|--prompt]]</code> (No longer supported)
 +
* <code>[[virt-install --import|--import]]</code>
  
<code>virt-install --import</code> Skip the OS installation process
+
== Examples ==
 +
* <code>[[virt-install --install]] [[ubuntu20.10]] --memory 2048 [[--disk]] size=2</code>
 +
* <code>virt-install --install [[ubuntu20.10]] --memory 2048 --disk size=2 [[--extra-args]]='console=ttyS0'</code>
 +
* <code>virt-install --install [[ubuntu20.10]] --memory 2048 --disk size=2 [[--graphics]] [[vnc]],listen=0.0.0.0</code>
 +
* <code>virt-install --install [[fedora29]] --memory 2048 --disk size=2</code>
  
sudo virt-install  
+
== Example Virtual Machine using [[virtio]] ==
  --name VM_NAME
+
* <code>[[virt-install]] --autostart --check all=on --name YOUR_VM_MACHINE --memory VM_MEMORY --vcpus VM_CPUs --os-variant ubuntu18.04 --cdrom VM_INSTALLATION_MEDIA --disk /path/libvirt/VM_STORAGE_POOL_NAME/YOUR_VM_MACHINE.[[qcow2]] --[[noautoconsole]] --wait TIME_TO_WAIT [[--network (KVM)|--network]] type=direct,source=eno111,source_mode=bridge,model=[[virtio]]</code>
  --import
 
  --ram 2048
 
  --vcpus=4
 
  --os-type=linux
 
  --os-variant=ubuntu18.04
 
  --nographics
 
  --disk /path/to/your/image/IMAGE_NAME.img
 
 
 
With no OS option:
 
<code>sudo virt-install --name VM_NAME --import --ram 2048 --disk /path/to/your/image/IMAGE_NAME.img</code>
 
WARNING  No operating system detected, VM performance may suffer. Specify an OS with --os-variant for optimal results.
 
WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
 
WARNING  No console to launch for the guest, defaulting to --wait -1
 
Starting install...
 
Domain installation still in progress. Waiting for installation to complete.
 
 
 
<ref>http://www.admin-magazine.com/Articles/Generate-VM-Images-with-virt-builder</ref>
 
  
 +
[[virt-install]]
 +
  --autostart
 +
  --check all=on
 +
  --name YOUR_VM_MACHINE
 +
  [[--memory]] VM_MEMORY
 +
  --vcpus VM_CPUs
 +
  --[[os-type]] linux
 +
  --[[os-variant]] ubuntu20.04
 +
  [[--graphics none]]
 +
  --wait TIME_TO_WAIT
 +
  --network type=direct,source=eno111,source_mode=bridge,model=[[virtio]]
 +
  [[--disk]] /path/libvirt/VM_STORAGE_POOL_NAME/YOUR_VM_MACHINE.[[qcow2]]
 +
  [[--cdrom]] PATH_TO_INSTALLATION_MEDIA
  
 +
Example:
 +
[[virt-install]]
 +
  --autostart
 +
  --check all=on
 +
  --name YOUR_VM_MACHINE
 +
  [[--memory]] 8192
 +
  --vcpus VM_2
 +
  --[[os-type]] linux
 +
  --[[os-variant]] ubuntu20.04
 +
  [[--disk]] [[/srv/]]libvirt/YOUR_VM_MACHINE.[[qcow2]],size=25
 +
  [[--graphics none]]
 +
  --network type=direct,source=eno111,source_mode=bridge,model=[[virtio]]
  
 
Other options:
 
Other options:
  --noautoconsole
+
  --[[qemu]]-commandline
--network type=direct,source=ETH_INTERFACE,source_mode=bridge,model=virtio
 
  
(--extra-args only work if specified with --location)
+
Using [[kickstart]] file:
  --extra-args "hostname=YOUR_HOSTNAME console=ttyS0 ip=10.10.10.10 dns=8.8.8.8 gateway=10.10.10.1 netmask=255.255.255.0 ks=file:/ks.cfg"
+
  [[--extra-args]] "ks=file:/ks.cfg console=ttyS0"
    (ks=file:/ks.cfg Kickstarter file)
 
  
 +
== [[KVM networking]] ==
 +
[[--network]] network=default
 +
--network=bridge:br0
 +
--network=bridge:virbr0
 +
--network type=direct,source=eth01,source_mode=[[bridge]],model=[[virtio]]
  
== Virt-install Windows ==
+
--[[vcpus]]=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#]
  
[[qemu-img create]] -f qcow2 IMAGE_NAME.img  10G
 
virt-install --name=TEST --os-type=windows --disk path=/path/to/your/precreated_image/IMAGE_NAME.img --cdrom=/path/to/your/iso/Win10_1909_EnglishInternational_x64.iso --graphics [[spice]] --ram=1024
 
Starting install...
 
Domain installation still in progress. Waiting for installation to complete.
 
  
  
=== Virt-install with errors ===
 
virt-install --connect=qemu:'''///'''system --name=mywin --os-type=windows  -r 1024 --cpus=1 --os-variant=win2k3 --hvm --cdrom=/path/to/en_windows_2k3.iso --disk path=/path/to/win2k3.img --accelerate --network=bridge:br0 --vnc
 
  
  WARNING  Graphics requested but DISPLAY is not set. Not running [[virt-viewer]].
+
  ERROR    Network not found: no network with matching name 'default'
WARNING  No console to launch for the guest, defaulting to --wait -1
 
  
 +
== Logs ==
 +
~/.cache/virt-manager/virt-install.log
 +
[Wed, 05 Feb 2020 16:30:36 virt-install 2890] DEBUG (virt-install:744) Domain state after install: 1
  
 +
== [[virt-install --import]] ==
  
 +
== [[Virt-install Windows]] ==
  
  
  WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
+
== Examples ==
 +
[[virt-install]] --install ubuntu18.04 --memory 2048 --disk size=2 [[--graphics]] vnc,listen=192.168.1.1 --name YOUR_NAME
 +
WARNING  [[KVM acceleration not available]], using 'qemu'
 +
Using ubuntu18.04 [[--location]] http://archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64
 +
  WARNING  Graphics requested but DISPLAY is not set. Not running [[virt-viewer]].
 
  WARNING  No console to launch for the guest, defaulting to --wait -1
 
  WARNING  No console to launch for the guest, defaulting to --wait -1
Starting install...
 
ERROR    Cannot get interface MTU on 'br0': No such device
 
Domain installation does not appear to have been successful.
 
If it was, you can restart your domain by running:
 
  virsh --connect qemu:///system start mywin
 
otherwise, please restart your installation.
 
 
 
ERROR    Cannot read CA certificate '/etc/pki/CA/cacert.pem': No such file or directory
 
 
 
 
WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
 
WARNING  No console to launch for the guest, defaulting to --wait -1
 
 
Starting install...
 
ERROR    internal error: process exited while connecting to monitor: 2020-02-05T10:13:42.360993Z
 
qemu-system-x86_64: -device ide-cd,bus=ide.0,unit=1,drive=drive-ide0-0-1,id=ide0-0-1,bootindex=1: Failed to get shared "write" lock
 
Is another process using the image?
 
Domain installation does not appear to have been successful.
 
If it was, you can restart your domain by running:
 
  virsh --connect qemu:///system start MY_DOMAIN
 
otherwise, please restart your installation.
 
  
 
== Related commands==  
 
== Related commands==  
* <code>--virt-type kvm</code> or <code>--virt-type qemu</code>
+
* <code>[[--virt-type]] kvm</code> or <code>--virt-type qemu</code>
* <code>[[virt-builder]]</code>
+
* <code>[[virt-builder]]</code> included in libguestfs-tools package.
 
* <code>[[qemu-img]]</code>
 
* <code>[[qemu-img]]</code>
 
* <code>[[virt-rescue]]</code> Run a rescue shell on a virtual machine
 
* <code>[[virt-rescue]]</code> Run a rescue shell on a virtual machine
 
* <code>[[virsh pool-define-as]]</code>
 
* <code>[[virsh pool-define-as]]</code>
* <code>[[virt-manager]]</code> and <code>[[virt-viewer]]</code>
+
* <code>[[virt-manager]]</code>, <code>[[virt-viewer]]</code> and <code>[[remote-viewer]]</code>
 +
* <code>[[virt-clone]]</code>
 +
* [[Packer install]]
 +
* <code>[[multipass launch]]</code>
 +
* <code>[[virt-sysprep]]</code>
 +
* <code>[[virsh define]]</code>
 +
* <code>[[virt-customize]]</code>
  
 
== Activities ==
 
== Activities ==
Line 98: Line 102:
 
* Clone a machine using: <code>[[virt-clone]]</code>
 
* Clone a machine using: <code>[[virt-clone]]</code>
 
* [[Install KVM in an Ubuntu Server]]
 
* [[Install KVM in an Ubuntu Server]]
 +
* Read Use <code>virt-install</code> and connect by using a local VNC client: https://docs.openstack.org/image-guide/virt-install.html
 +
* [[Install virtio-win]]
 +
* Understand <code>[[--location]]</code> and <code>[[--extra-args]]='console=ttyS0'</code> options
 +
* Understand <code>[[--arch]]</code> option
 +
* Changelog: https://github.com/virt-manager/virt-manager/blob/master/NEWS.md
 +
 +
== Related terms ==
 +
* [[Ignition]]
 +
* <code>--[[hvm]]</code>
  
 
== See also ==
 
== See also ==
 +
* {{virt-install}}
 +
* {{libvirtd}}
 +
* {{virsh}}
 
* {{KVM}}
 
* {{KVM}}
 
* {{virtinst}}
 
* {{virtinst}}

Latest revision as of 17:14, 5 November 2021

virt-install script is part of virtinst package.


Options[edit]

Examples[edit]

Example Virtual Machine using virtio[edit]

  • virt-install --autostart --check all=on --name YOUR_VM_MACHINE --memory VM_MEMORY --vcpus VM_CPUs --os-variant ubuntu18.04 --cdrom VM_INSTALLATION_MEDIA --disk /path/libvirt/VM_STORAGE_POOL_NAME/YOUR_VM_MACHINE.qcow2 --noautoconsole --wait TIME_TO_WAIT --network type=direct,source=eno111,source_mode=bridge,model=virtio
virt-install 
 --autostart
 --check all=on
 --name YOUR_VM_MACHINE
 --memory VM_MEMORY
 --vcpus VM_CPUs
 --os-type linux
 --os-variant ubuntu20.04
 --graphics none
 --wait TIME_TO_WAIT
 --network type=direct,source=eno111,source_mode=bridge,model=virtio
 --disk /path/libvirt/VM_STORAGE_POOL_NAME/YOUR_VM_MACHINE.qcow2
 --cdrom PATH_TO_INSTALLATION_MEDIA

Example:

virt-install 
 --autostart
 --check all=on
 --name YOUR_VM_MACHINE
 --memory 8192
 --vcpus VM_2
 --os-type linux
 --os-variant ubuntu20.04
 --disk /srv/libvirt/YOUR_VM_MACHINE.qcow2,size=25
 --graphics none
 --network type=direct,source=eno111,source_mode=bridge,model=virtio

Other options:

--qemu-commandline

Using kickstart file:

--extra-args "ks=file:/ks.cfg console=ttyS0"

KVM networking[edit]

--network network=default
--network=bridge:br0
--network=bridge:virbr0
--network type=direct,source=eth01,source_mode=bridge,model=virtio
--vcpus=VCPUS[,maxvcpus=MAX][,sockets=#][,cores=#][,threads=#]



ERROR    Network not found: no network with matching name 'default'

Logs[edit]

~/.cache/virt-manager/virt-install.log
[Wed, 05 Feb 2020 16:30:36 virt-install 2890] DEBUG (virt-install:744) Domain state after install: 1

virt-install --import[edit]

Virt-install Windows[edit]

Examples[edit]

virt-install --install ubuntu18.04 --memory 2048 --disk size=2 --graphics vnc,listen=192.168.1.1 --name YOUR_NAME
WARNING  KVM acceleration not available, using 'qemu'
Using ubuntu18.04 --location http://archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64
WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
WARNING  No console to launch for the guest, defaulting to --wait -1

Related commands[edit]

Activities[edit]

Related terms[edit]

See also[edit]

  • https://github.com/virt-manager/virt-manager/blob/master/NEWS.md#release-300-september-15-2020
  • Advertising: