User Tools

Site Tools


public:managing_kvm_on_debian

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
public:managing_kvm_on_debian [2024/05/07 21:19] – [Creating a network bridge] thomaspublic:managing_kvm_on_debian [2024/05/17 20:56] (current) thomas
Line 6: Line 6:
  
 <code> <code>
-sudo apt install --no-install-recommends qemu-system libvirt-clients libvirt-daemon-system virtinst qemu-utils dnsmasq swtpm swtpm-tools ovmf bridge-utils+sudo apt install --no-install-recommends qemu-system libvirt-clients libvirt-daemon-system virtinst qemu-utils dnsmasq swtpm swtpm-tools ovmf bridge-utils libvirt-daemon-driver-storage-zfs
 </code> </code>
  
Line 46: Line 46:
 </pool> </pool>
 </code> </code>
 +
 +You can also use a ZFS dataset as storage pool, with this alternative XML configuration:
 +
 +<code>
 +<pool type="zfs">
 +  <name>default</name>
 +  <source>
 +    <name>pool1/kvm</name>
 +  </source>
 +</pool>
 +</code>
 +
 +:!: Note that this does not support libvirt snapshots. You will need to make snapshots via ZFS manually, which may not be ideal.
  
 Then, create the pool based on the definition and make sure it autostarts: Then, create the pool based on the definition and make sure it autostarts:
Line 156: Line 169:
  
 <code> <code>
-virt-install --network bridged [...]+virt-install --network network=bridged [...]
 </code> </code>
  
Line 172: Line 185:
 --graphics vnc,listen=0.0.0.0,password=foobar --noautoconsole \ --graphics vnc,listen=0.0.0.0,password=foobar --noautoconsole \
 --disk size=50 --memory 4096 --disk size=50 --memory 4096
 +--network network=bridged
 </code> </code>
  
-You can then connect with a VNC client to the host to perform the installation.+You can then connect with a VNC client to the host to perform the installation. The recommended client is [[https://tigervnc.org/|TigerVNC]], as it natively supports a protocol extension that maps the keyboard correctly by default.
  
 Some useful options: Some useful options:
   * ''--tpm backend.type=emulator,backend.version=2.0,model=tpm-tis'': To set a virtual TPM.   * ''--tpm backend.type=emulator,backend.version=2.0,model=tpm-tis'': To set a virtual TPM.
  
-More examples can be found in [[public:virt-install_examples|this article]].+More examples can be found in [[public:virt-install_examples|this article]]. If you want to find out what os-variants are possible, you can list them as follows: 
 + 
 +<code> 
 +apt install libosinfo-bin 
 +osinfo-query os 
 +</code>
  
 ===== Listing running VMs ===== ===== Listing running VMs =====
Line 193: Line 212:
 </code> </code>
  
-===== Forcing a VM to stop =====+If the server had NVRAM enabled, you must specify the ''nvram'' option to delete it without errors:
  
 <code> <code>
-virsh destroy windows-server-2022+virsh undefine windows-server-2022 --nvram 
 +</code> 
 +===== Stopping a guest ===== 
 + 
 +This will ask a VM to shut down: 
 + 
 +<code> 
 +virsh shutdown <name> 
 +</code> 
 + 
 +This will force a VM to shut down: 
 +<code> 
 +virsh destroy <name>
 </code> </code>
 ===== Editing a VM's XML configuration ===== ===== Editing a VM's XML configuration =====
Line 204: Line 235:
 </code> </code>
  
 +===== Finding the VNC display for a guest =====
 +
 +<code>
 +virsh vncdisplay <name>
 +</code>
 +
 +or
 +
 +<code>
 +virsh domdisplay <name>
 +</code>
 +
 +This snippet will list out the displays for all guests:
 +
 +<code>
 +for dom in $(virsh list --name); do echo -n "$dom: "; virsh domdisplay $dom; done
 +</code>
 +
 +===== Managing media =====
 +
 +Listing attached media:
 +
 +<code>
 +virsh domblklist <guestname>
 +</code>
 +
 +To replace a disk or cd-rom with another:
 +
 +<code>
 +virsh change-media <guestname> /path/to/current/disk.img /path/to/new/disk.img
 +</code>
 +
 +Or to simply eject a disk:
 +
 +<code>
 +virsh change-media vm1 hdc --eject
 +</code>
 ===== Resources ===== ===== Resources =====
  
Line 209: Line 277:
   * http://thomasmullaly.com/2014/11/16/the-list-of-os-variants-in-kvm/   * http://thomasmullaly.com/2014/11/16/the-list-of-os-variants-in-kvm/
   * https://libvirt.org   * https://libvirt.org
 +  * https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/
 +  * https://serverfault.com/questions/334199/how-to-find-which-screen-and-thus-port-the-vnc-ui-for-a-kvm-guest-has-or-how
public/managing_kvm_on_debian.1715116751.txt.gz · Last modified: by thomas

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki