Last active
December 31, 2025 15:02
-
-
Save Nurlan199206/dc4154cebcaebb6593dc0709854946b7 to your computer and use it in GitHub Desktop.
KVM examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| sudo apt install qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virtinst -y | |
| sudo adduser $USER libvirt | |
| sudo adduser $USER kvm | |
| mkdir -p /var/lib/libvirt/boot | |
| cd /var/lib/libvirt/boot | |
| wget https://mirror.fst.kz/ubuntu-cd/24.04.3/ubuntu-24.04.3-live-server-amd64.iso | |
| qemu-img create -f qcow2 -F qcow2 \ | |
| -b /home/ubuntu/cloud-native/noble-server-cloudimg-amd64.img \ | |
| /var/lib/libvirt/images/myvm.qcow2 20G | |
| sudo virt-install --name myvm --ram 2048 --vcpus 2 --disk path=/var/lib/libvirt/images/myvm.qcow2,size=20,format=qcow2 --os-variant ubuntu24.04 --network network=default,model=virtio --cdrom=/var/lib/libvirt/images/iso/ubuntu-24.04.3-live-server-amd64.iso --graphics vnc --boot uefi | |
| virsh destroy myvm - выключить вм | |
| virsh undefine --nvram myvm - удалить вм | |
| rm -rf /var/lib/libvirt/images/myvm.qcow2 | |
| virsh dumpxml myvm | grep "mac address" | |
| sudo virsh net-dumpxml default | |
| virsh net-autostart default | |
| virsh net-destroy default && virsh net-start default | |
| sudo virsh net-update default add ip-dhcp-host \ | |
| "<host mac='52:54:00:02:c1:b8' name='myvm' ip='192.168.200.24'/>" \ | |
| --live --config |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment