Skip to content

KVM

KVM🔗

Check CPU virtualisation support

1
2
3
ls /dev/kvm
# or
lsmod | grep kvm

Config and Management🔗

Cumbersome directly, but tools exist to help

  • libvirt: command line tool
  • GUI: GNOME Boxes, …

Quick-start🔗

Following RedHat guide

  1. confirm CPU virtualisation: sudo grep -E 'svm|vmx' /proc/cpuinfo
  2. obtain image, e.g. from OpenStack image guide
  3. customisee VM

    1
    2
    3
    4
    5
    6
    7
    virt-customize \
    -a /var/lib/libvirt/images/imagetest1.qcow2 \
    --hostname vmlab01 \
    --root-password password:rootpw \
    --ssh-inject 'root:file:labkey.pub' \
    --uninstall cloud-init \
    --selinux-relabel
    
  4. install VM (requires active network1)

    1
    2
    3
    4
    5
    6
    7
    8
    virt-install \
    --name vmlab01 \
    --memory 1024 \
    --vcpus 1 \
    --disk /var/lib/libvirt/images/image.qcow2 \
    --import \
    --os-type linux --os-variant generic \
    --noautoconsole
    
  5. access VM

    1
    2
    virsh domifaddr vmlab01
    ssh -i labkey root@192.168.122.76
    

References🔗


  1. error network ... not active:

    1
    2
    3
    4
    # virsh net-list --all
    virsh net-start default
    # start at boot
    virsh net-autostart default