Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sistematico/8ad1f316767428a1510431c7d6b9a23b to your computer and use it in GitHub Desktop.
Save sistematico/8ad1f316767428a1510431c7d6b9a23b to your computer and use it in GitHub Desktop.
Easy instructions to get virt-manager qemuv/kvm running on Arch

Easy instructions to get QEMU/KVM and virt-manager up and running on Arch

  1. Make sure your cpu support kvm with below command:

     grep -E "(vmx|svm)" --color=always /proc/cpuinfo
    
  2. Make sure BIOS have enable “Virtualization Technology”.

  3. User access to /dev/kvm so add your account into kvm(78) group:

     sudo gpasswd -a USER_NAME kvm
    
  4. Loading kernel modules kvm_intel or kvm_amd depend on your CPU, Add module name in /etc/modules-load.d/kvm.conf:

     kvm_intel
    
  • Load module:

    modprobe kvm_amd
    
  1. Install qemu, virt-manager, dnsmasq and iptables:

     sudo pacman -S qemu virt-manager dnsmasq iptables ebtables dnsmasq
    
  2. Run and enable boot up start libvirtd daemon:

     systemctl start libvirtd
    
     systemctl enable libvirtd
    
  3. Use PolicyKit authorization create /etc/polkit-1/rules.d/50-libvirt.rules (before /etc/polkit-1/rules.d/50-org.libvirt.unix.manage.rules) as below context:

/* Allow users in kvm group to manage the libvirt
daemon without authentication */
polkit.addRule(function(action, subject) {
    if (action.id == "org.libvirt.unix.manage" &&
        subject.isInGroup("kvm")) {
            return polkit.Result.YES;
    }
});
  1. You will need to create the libvirt group and add any users you want to have access to libvirt to that group:

     groupadd libvirt
    
     sudo gpasswd -a USER_NAME libvirt
    
  2. Check network interface status:

     sudo virsh net-list --all
    
  • If it is inactive start it using:

     sudo virsh net-start default
    
  1. Now you can use virt-manager manager your virtual machine.

What to do if default network interface is not listed

  • If virsh net-list is not listing any network interface just reinitialize it with,

    sudo virsh net-define /usr/share/libvirt/networks/default.xml
    
  • Then just autostart it like so,

    sudo virsh net-autostart default 
    
  1. Things to do after installing a Windows VM.
  • Check and install drivers on your guest Windows VM, probably virtio-win is a nice place to start.

How to extend / increase a Windows Partition on KVM QEMU VM

We have a Windows 7 VM running on Ubuntu KVM. I needed to give the Windows 7 machine more disk space. This turns out to be really easy (when you know how).

  1. Shutdown the VM

     virsh shutdown hostname
    
  2. Increase the qcow2 image

Find the qcow2 file of the VM and take a backup (just in case).

cp hostname.qcow2 hostname.qcow2.backup
qemu-img resize hostname.qcow2 +100GB
  1. Start the VM

     virsh start hostname
    
  2. Extend the partition in Window

Windows has a really good partition management utility built into it. Search for disk management

Reference:

Original guide - http://wood1978.dyndns.org/~wood/wordpress/2013/07/22/arch-linux-setup-kvm-with-virt-manager-gui/comment-page-1/

KVM @ Arch Wiki - https://wiki.archlinux.org/index.php/KVM

libvirt @ Arch Wiki - https://wiki.archlinux.org/index.php/Libvirt

QEMU @ Arch Wiki - https://wiki.archlinux.org/index.php/QEMU

Network Interface Status - http://ask.xmodulo.com/network-default-is-not-active.html

Networking libvirt wiki - https://wiki.libvirt.org/page/Networking#NAT_forwarding_.28aka_.22virtual_networks.22.29

Fedora Wiki - Windows Virtio Drivers - https://stg.fedoraproject.org/wiki/Windows_Virtio_Drivers

Extend disk size Windows partition KVM QEMU VM - https://www.randomhacks.co.uk/how-to-extend-increase-a-windows-partition-on-kvm-qemu-vm/

Increasing a KVM machine disk space - https://serverfault.com/questions/324281/how-do-you-increase-a-kvm-guests-disk-space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment