homehowtokbslinksaboutcontactprojectsmusic

Index > Help Tutorials > QEMU/KVM
  1. Check CPU
  2. Install package
  3. Setup bridge
  4. Increase VM disk

    Check CPU compatibility

    kvm-ok
    You may need to install CPU checker
    apt install cpu-checker
    Go up

    Install package

    1. Minimum installation
      sudo apt-get install virt-manager ssh-askpass-gnome --no-install-recommends
      
    2. Full installation
      sudo apt-get install virt-manager ssh-askpass-gnome
      
    Go up

    Setup bridge

    1. Backup old configuration
      mv /etc/netplan/installer-config.yaml /etc/netplan/installer-config.yaml.orig
      
    2. Create new networking configuration
      cat << eot >> /etc/netplan/99_networking.yaml
      network:
        version: 2
        renderer: networkd
        ethernets:
          eth0:
            dhcp4: no
      
        bridges:
          br0:
            interfaces: [eth0]
            dhcp4: no
            addresses:
             - 10.10.10.10/24
            routes:
             - to: default
               via: 10.10.10.1
            nameservers:
             search:
              - home.nt
             addresses:
              - 10.10.10.4
              - 10.10.10.1
              - 8.8.8.8
      eot
      
    3. Apply new network config
      netplan apply
    4. Next change network to bridge mode on the VM
    Go up

    Increase VM disk

      Note: Using vm as name for virtual machine in this example, please adjust the VM name if needed
    1. List running VMs
      virsh list
    2. Shutdown running VM
      virsh shutdown vm
    3. Confirm that it is powered off
      virsh list
    4. Get disk path
      sudo virsh domblklist vm
    5. Check existing disk size, adjust path if needed
      qemu-img info /var/lib/libvirt/images/vm.qcow2
    6. Check for snapshots, you need to delete them before increasing the size
      sudo virsh snapshot-list vm
    7. Delete them if found, adjust the name of VM and snapshot
      sudo virsh snapshot-delete --domain vm --snapshotname snapshot1
    8. Increase size by 10GB
      qemu-img resize /var/lib/libvirt/images/vm.qcow2 +10G
    9. All done, time to start VM
      virsh start vm
    10. Grow VM partition
      1. SSH to the VM
        ssh user@vm
      2. List partitions
        lsblk
      3. Grow partition number (you will get from above command, adjust it if needed)
        growpart /dev/vda 2
      4. Resize filesystem
        resize2fs /dev/vda2
      5. Verify the size
        df -hT | grep /dev/vda
    Go up