KVM: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 64: Line 64:
<li> [https://mintguide.org/tools/340-kvm-virtualization-on-a-home-pc-with-linux-mint.html KVM virtualization on a home PC with Linux Mint] </li>
<li> [https://mintguide.org/tools/340-kvm-virtualization-on-a-home-pc-with-linux-mint.html KVM virtualization on a home PC with Linux Mint] </li>
<li> [https://www.linuxtechi.com/install-configure-kvm-ubuntu-18-04-server/ How to Install and Configure KVM on Ubuntu 18.04 LTS Server]. I skip step 4: Configure Network Bridge for KVM virtual Machines. </li>
<li> [https://www.linuxtechi.com/install-configure-kvm-ubuntu-18-04-server/ How to Install and Configure KVM on Ubuntu 18.04 LTS Server]. I skip step 4: Configure Network Bridge for KVM virtual Machines. </li>
<li> How to bring down br0 and delete it? After some messing up I need to delete br0.
<pre>
sudo ip link set br0 down
sudo brctl delbr br0
</pre></li>
<li> '''[https://www.answertopia.com/ubuntu/ubuntu-essentials/ Ubuntu 20.04 Essentials (book)]''' &rarr; [https://www.answertopia.com/ubuntu/creating-an-ubuntu-kvm-networked-bridge-interface/ Creating an Ubuntu 20.04 KVM Networked Bridge Interface]. It is based on a Ubuntu Desktop environment. The description is quite detailed. Have not tried yet! </li>
<li> '''[https://www.answertopia.com/ubuntu/ubuntu-essentials/ Ubuntu 20.04 Essentials (book)]''' &rarr; [https://www.answertopia.com/ubuntu/creating-an-ubuntu-kvm-networked-bridge-interface/ Creating an Ubuntu 20.04 KVM Networked Bridge Interface]. It is based on a Ubuntu Desktop environment. The description is quite detailed. Have not tried yet! </li>
<li>[https://www.tecmint.com/install-kvm-on-ubuntu/ How to Install KVM on Ubuntu 20.04]
<li>[https://www.tecmint.com/install-kvm-on-ubuntu/ How to Install KVM on Ubuntu 20.04]

Revision as of 17:30, 29 November 2020

Resource

libvirt

  • https://en.wikipedia.org/wiki/Libvirt. libvirt is an open-source API, daemon and management tool for managing platform virtualization.[3] It can be used to manage KVM, Xen, VMware ESXi, QEMU and other virtualization technologies.
  • https://libvirt.org/
  • Check libvirt version: sudo head -n2 /var/log/libvirt/qemu/ubuntu2004.log # on Ubuntu 20.04 it shows 6.0.0

Install

Install on Ubuntu

Install qemu-system-arm in Ubuntu

  • sudo apt install qemu-system-arm
  • How to emulate Raspberry Pi in QEMU which is based on qemu-rpi-kernel-Qemu kernel for emulating Rpi on QEMU.
    mkdir rpi-vm && cd rpi-vm
    git clone https://github.com/dhruvvyas90/qemu-rpi-kernel.git
    
    # Download Raspbian Buster Lite
    # from https://www.raspberrypi.org/downloads/raspberry-pi-os/
    dd if=/dev/zero bs=1M count=4096 >> 2020-08-20-raspios-buster-armhf-lite.img
    
    sudo losetup -f -P --show 2020-08-20-raspios-buster-armhf-lite.img
    
    sudo mount -o rw /dev/loopXp2 /mnt
    
    sudo nano /mnt/etc/fstab
    
    sudo nano /etc/ld.so.preload # Comment out the line and save the file. 
    # Then unmount with the following commands:
    # sudo umount /mnt
    # sudo losetup -d /dev/loopX
    
    qemu-system-arm \
      -M versatilepb \
      -cpu arm1176 \
      -m 256 \
      -kernel qemu-rpi-kernel/kernel-qemu-4.19.50-buster \
      -hda 2020-08-20-raspios-buster-armhf-lite.img \
      -append "dwc_otg.lpm_enable=0 root=/dev/sda2 console=tty1 rootfstype=ext4 elevator=deadline rootwait" \
      -dtb qemu-rpi-kernel/versatile-pb-buster.dtb \
      -no-reboot \
      -serial stdio
    
    # We can install a desktop. See 
    # https://www.raspberrypi.org/forums/viewtopic.php?t=133691
    

Install on CentOS

snapshot

  • How to Create, Revert and Delete KVM Virtual machine (domain) snapshot with virsh command, How to create snapshot in Linux KVM VM/Domain
    $ sudo su
    # virsh list --all
    
    # virsh snapshot-create-as --domain win10 --name win10_snap --description "Windows 10 snapshot"    # Create a snapshot
    # virsh snapshot-list win10
    # virsh snapshot-info --domain win10 --snapshotname win10_snap
    
    # virsh snapshot-revert win10 win10_snap    # Restore
    
    # virsh snapshot-delete --domain win10 --snapshotname win10_snap
    
  • To create a snapshot using the GUI, open virtualization manager window. In the VM properties, click on the icon (two displays overlapped) which is on the right of the menu, which says Manage VM snapshots.

GUI manager

Network

Back and restore images

How to KVM Backup and Restore in Linux

# Backup 
virsh list --all
virsh dumpxml win10 > /MyBackup/win10.xml
sudo cp /var/lib/libvirt/images/win10.qcow2 /MyBackup/win10.qcow2
sudo chown $USER:$USER /MyBackup/*.qcow2

# Restore Making
sudo virsh undefine win10
ls -l /etc/libvirt/qemu
virsh list --all
sudo rm /var/lib/libvirt/images/win10.qcow2
sudo cp /MyBackup/win10.qcow2 /var/lib/libvirt/images/
sudo virsh define --file /MyBackup/win10.xml
# virsh start win10

Cheat sheet

KVM Cheatsheet

Run macOS on KVM / QEMU

How To run macOS on KVM / QEMU