linux:apps:kvm
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:apps:kvm [2023/08/06 11:14] – oscar | linux:apps:kvm [2025/10/21 20:15] (current) – oscar | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== KVM ====== | ====== KVM ====== | ||
| + | |||
| + | ---- | ||
| ===== Installation ===== | ===== Installation ===== | ||
| 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, | + | |
| + | | ||
| + | | ||
| === 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:/// | + | 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:/// | $ virsh --connect qemu:/// | ||
| Line 65: | Line 71: | ||
| $ export LIBVIRT_DEFAULT_URI=' | $ export LIBVIRT_DEFAULT_URI=' | ||
| + | |||
| + | ===== Libvirt default network ===== | ||
| + | If you use libvirt to manage your VMs, libvirt provides a NATed bridged network named " | ||
| + | < | ||
| + | 3: virbr0: < | ||
| + | link/ether 52: | ||
| + | inet 192.168.122.1/ | ||
| + | | ||
| + | </ | ||
| + | This network is available only for the system domains (that is VMs created by root or using the " | ||
| + | virsh --connect=qemu:/// | ||
| + | |||
| + | To make the default network start automatically use: | ||
| + | |||
| + | virsh --connect=qemu:/// | ||
| + | |||
| + | ===== Change XML configuration ===== | ||
| + | Extract the xml from an existing qcow2 image by: | ||
| + | virsh dumpxml Windows-11 > Windows-11.xml | ||
| + | Edit and modify the tags in the XML file. | ||
| + | Undefine the XML config from the old vm to prevent an error because of a duplicate UUID: | ||
| + | virsh undefine --nvram Windows-11 | ||
| + | or | ||
| + | virsh undefine Windows-11 | ||
| + | Import / define the new XML file: | ||
| + | virsh define Windows-11.xml | ||
| + | Of course you will have to stop and start the vm for the changes to take effect: | ||
| + | virsh destroy name_of_vm | ||
| + | virsh start name_of_vm | ||
| ===== Error Access ISO files, etc. ===== | ===== Error Access ISO files, etc. ===== | ||
| - | Directory, that libvirt is using for storing/ | + | Directory, that libvirt is using for storing/ |
| $ sudo su -s /bin/bash libvirt-qemu | $ sudo su -s /bin/bash libvirt-qemu | ||
| Line 78: | Line 113: | ||
| Or any other paths that have full r others rights. | Or any other paths that have full r others rights. | ||
| + | ===== Convert VirtualBox to KVM ===== | ||
| + | qemu-img convert -f vdi -O qcow2 virtualbox-name.vdi kvm-name.qcow2 | ||
| + | ===== Shrink KVM qcow2 image ===== | ||
| + | qemu-img convert -O qcow2 source.qcow2 shrunk.qcow2 | ||
| + | ===== 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 / | ||
| - | ===== Links ===== | + | ls -l / |
| + | Now edit the /// | ||
| + | < | ||
| + | # nano / | ||
| + | |||
| + | or | ||
| + | |||
| + | virsh edit ${YOUR_VM} | ||
| + | ---------------------------------------------- | ||
| + | <disk type=' | ||
| + | <driver name=' | ||
| + | <source dev='/ | ||
| + | <target dev=' | ||
| + | </ | ||
| + | </ | ||
| + | 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 / | ||
| + | | ||
| + | Domain YOUR_VM defined from / | ||
| + | | ||
| + | ===== Links ===== | ||
| * [[https:// | * [[https:// | ||
linux/apps/kvm.1691320479.txt.gz · Last modified: by oscar
