User Tools

Site Tools


linux:apps:kvm

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
linux:apps:kvm [2025/09/21 11:05] – [Installation] oscarlinux:apps:kvm [2025/10/21 20:15] (current) oscar
Line 1: Line 1:
 ====== KVM ====== ====== KVM ======
-S2YLNY0HA01587+ 
 +---- 
 ===== Installation ===== ===== Installation =====
 Install all the required for the installation of Qemu, KVM hypervisor, and Libvirt  Install all the required for the installation of Qemu, KVM hypervisor, and Libvirt 
Line 55: Line 57:
 In order to manage virtual machines as a regular user, that user needs to be added to the libvirt group: In order to manage virtual machines as a regular user, that user needs to be added to the libvirt group:
  
-  # usermod -aG libvirt,kvm USERNAME+  # adduser <username> libvirt 
 +       or  (not sure if kvm group is needed) 
 +  # usermod -aG libvirt,kvm <username>
  
 === User-specific and system-wide VMs === === User-specific and system-wide VMs ===
-By default, if virsh is run as a normal user it will connect to libvirt using qemu:///session URI string. This URI allows virsh to manage only the set of VMs belonging to this particular user. To manage the system set of VMs (i.e., VMs belonging to root) virsh should be run as root or with qemu:///system URI:+By default, if virsh is run as a normal user it will connect to libvirt using: **qemu:%%///%%session** URI string. This URI allows virsh to manage only the set of VMs belonging to this particular user.  
 + 
 +To manage the system set of VMs (i.e., VMs belonging to root) virsh should be run as root or with: **qemu:%%///%%system** URI:
  
   $ virsh --connect qemu:///system list --all   $ virsh --connect qemu:///system list --all
Line 67: Line 73:
  
 ===== Libvirt default network ===== ===== Libvirt default network =====
-If you use libvirt to manage your VMs, libvirt provides a NATed bridged network named "default" that allows the host to communicate with the guests. This network is available only for the system domains (that is VMs created by root or using the "qemu:system" connection URI). VMs using this network end up in 192.168.122.1/24 and DHCP is provided to them via dnsmasq. This network is not automatically started. To start it use:+If you use libvirt to manage your VMs, libvirt provides a NATed bridged network named "default/virbr0" that allows the host to communicate with the guests.  
 +<code> 
 +3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000 
 +    link/ether 52:54:00:f5:c4:41 brd ff:ff:ff:ff:ff:ff 
 +    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0 
 +       valid_lft forever preferred_lft forever 
 +</code> 
 +This network is available only for the system domains (that is VMs created by root or using the "qemu:system" connection URI). VMs using this network end up in 192.168.122.1/24 and DHCP is provided to them via dnsmasq. This network is not automatically started. To start it use:
   virsh --connect=qemu:///system net-start default   virsh --connect=qemu:///system net-start default
  
Line 104: Line 117:
 ===== Shrink KVM  qcow2 image ===== ===== Shrink KVM  qcow2 image =====
   qemu-img convert -O qcow2 source.qcow2 shrunk.qcow2   qemu-img convert -O qcow2 source.qcow2 shrunk.qcow2
-===== Links =====+===== Make SATA disk available in Windows Client =====   
 +To make a SATA disk partition available in a Windows VM add the disk to the domain’s xml config file by hand. First find the id of the partition that you want to add. Rather than using /dev/sda you should use /dev/disk/by-id/ where you get from
  
 +   ls -l /dev/disk/by-id
 +
 +Now edit the ///etc/libvirt/qemu/${YOUR_VM}.xml// file and add a <disk> section to the <devices> section:
 +<code>
 +# nano /etc/libvirt/qemu/${YOUR_VM}.xml
 +
 +or 
 +
 +virsh edit ${YOUR_VM}
 +----------------------------------------------
 +<disk type='block' device='disk'>
 +    <driver name='qemu' type='raw'/>
 +    <source dev='/dev/disk/by-id/{the-partition-id}'/>
 +    <target dev='vdb' bus='virtio'/>
 +</disk>
 +</code>
 +This will make the host’s partition available in the guest as /dev/vdb (D:). After changing a domain’s config by hand, you have to reload the config by hand. Log in to your host and issue this command:
 +
 +  # virsh define /etc/libvirt/qemu/${YOUR_VM}.xml
 +  
 +  Domain YOUR_VM defined from /etc/libvirt/qemu/${YOUR_VM}.xml
 +  
 +===== Links =====
   * [[https://wiki.debian.org/KVM#Installation]]   * [[https://wiki.debian.org/KVM#Installation]]
  
linux/apps/kvm.1758452736.txt.gz · Last modified: by oscar