kvm

Debian bookworm

   1 sudo apt update
   2 sudo apt upgrade 
   3 egrep -c '(vmx|svm)' /proc/cpuinfo
   4 grep -E --color '(vmx|svm)' /proc/cpuinfo
   5 sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon
   6 sudo apt install virt-manager -y
   7 sudo virsh net-list --all
   8 sudo virsh net-start default
   9 sudo virsh net-autostart default
  10 sudo modprobe vhost_net
  11 lsmod | grep vhost
  12 ip a | grep wlp2s0
  13 /sbin/ifconfig
  14 sudo nano /etc/network/interfaces
  15 # add an IP in the network range 
  16 auto br0
  17 iface br0 inet dhcp
  18         bridge_ports wlp2s0
  19 
  20 sudo systemctl restart networking.service
  21 
  22 # create VM disk 
  23 sudo qemu-img create -f qcow2 /tmp/netbsd.qcow2 8G 
  24 cd /tmp/
  25 wget https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.3/images/NetBSD-9.3-amd64.iso 
  26 
  27 sudo virt-install \
  28 --virt-type kvm \
  29 --name Netbsd \
  30 --ram 2024 \
  31 --disk /tmp/netbsd.qcow2 \
  32 --network network=default --graphics vnc,listen=0.0.0.0 \
  33 --noautoconsole \
  34 --os-variant=generic \
  35 --cdrom=/tmp/NetBSD-9.3-amd64.iso
  36 
  37 sudo virsh list --all
  38 sudo apt install tigervnc-viewer
  39 sudo virsh vncdisplay Netbsd
  40 :0
  41 vncviewer & # connect to :0
  42 
  43 sudo virsh list --all 
  44 sudo virsh start Netbsd
  45 sudo virsh list --all 
  46 sudo virsh vncdisplay Netbsd
  47 vncviewer 
  48 
  49 # see all the installed VMs
  50 sudo virsh list --all
  51 # Stop running VM
  52 sudo virsh stop Netbsd 
  53 # start
  54 sudo virsh start Netbsd 
  55 # save the state of a  VM
  56 sudo virsh save Netbsd Netbsd-save
  57 # restore a saved VM
  58 sudo virsh restore Netbsd-save
  59 # reboot  
  60 sudo virsh reboot Netbsd
  61 # suspend VM
  62 sudo virsh suspend Netbsd
  63 # resume
  64 sudo virsh resume Netbsd
  65 # shutdown
  66 sudo virsh shutdown Netbsd
  67 # delete
  68 sudo virsh destroy Netbsd
  69 
  70 # Uninstall 
  71 sudo apt remove qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon virt-manager tigervnc-viewer
  72 sudo apt autoremove 

kvm (last edited 2024-01-31 00:33:42 by vitor)