2026-03-12 21:01:38
This commit is contained in:
91
tiddlywiki/KVM notes.txt
Executable file
91
tiddlywiki/KVM notes.txt
Executable file
@@ -0,0 +1,91 @@
|
||||
-- virsh usefull commands
|
||||
-------------------------
|
||||
# create new domain
|
||||
virt-install \
|
||||
--graphics vnc,listen=0.0.0.0 \
|
||||
--name=mandalore \
|
||||
--vcpus=2 \
|
||||
--memory=4096 \
|
||||
--network bridge=br0 \
|
||||
--network bridge=br0 \
|
||||
--cdrom=/mnt/yavin4/kit/CentOS/CentOS-8.2.2004-x86_64-minimal.iso \
|
||||
--disk /datastore/mandalore/hdd_01.img,size=6 \
|
||||
--os-variant=centos8
|
||||
|
||||
# get OS Variant
|
||||
osinfo-query os
|
||||
|
||||
# destroy a domain
|
||||
virsh destroy mandalore
|
||||
|
||||
# delete VM and underlying storage
|
||||
virsh undefine mandalore --remove-all-storage
|
||||
|
||||
|
||||
# adding disk to VM
|
||||
# on Dom0 create the disk (RAW format in exemple)
|
||||
qemu-img create -f raw /datastore/mandalore/app_01.img 8G
|
||||
# change the owner of the image ad permissions
|
||||
chown qemu:qemu /datastore/mandalore/app_01.img
|
||||
chmod 600 /datastore/mandalore/app_01.img
|
||||
# on DomU list block devices
|
||||
lsblk
|
||||
# or to have the sorted list of block devices
|
||||
fdisk -l | grep '^Disk /dev/vd[a-z]'
|
||||
# pick the next available device, ex: vdb
|
||||
# return to Dom0 and attach the disk
|
||||
virsh attach-disk mandalore /datastore/mandalore/app_01.img vdb --driver qemu --subdriver raw --targetbus virtio --persistent
|
||||
# to list the disk of a domain, execute from Dom0:
|
||||
virsh domblklist seedmachine --details
|
||||
|
||||
# to detach a disk
|
||||
virsh detach-disk mandalore vdb --persistent
|
||||
|
||||
|
||||
# to list the network interfaces of a domain, execute from Dom0:
|
||||
virsh domiflist mandalore
|
||||
# add network interface
|
||||
virsh attach-interface --domain vortex-db01 --type bridge --source br0 --model virtio --persistent
|
||||
# remove network interface
|
||||
virsh detach-interface --domain ylesia-db01 --mac 52:54:00:8f:40:3c --type bridge
|
||||
|
||||
|
||||
# dump domain XML config file
|
||||
virsh dumpxml mandalore
|
||||
|
||||
# define domain from XML config file
|
||||
virsh define --file /mnt/yavin4/tmp/seedmachine.xml
|
||||
|
||||
|
||||
# list all defined pool on Dom0
|
||||
virsh pool-list --all
|
||||
|
||||
# deleting a pool
|
||||
virsh pool-destroy atrisia1
|
||||
virsh pool-undefine atrisia1
|
||||
|
||||
# import (define) VM from XML file
|
||||
virsh define /mnt/yavin4/data/d.backup_vm/KVM_seed/Centos8_2020-10-25/seedmachine.xml
|
||||
|
||||
# clone VM
|
||||
virt-clone \
|
||||
--original mandalore \
|
||||
--name ossus \
|
||||
--file /datastore/ossus/hdd_01.img \
|
||||
--file /datastore/ossus/app_01.img
|
||||
|
||||
# KVM BUG: error: internal error: unknown feature amd-sev-es
|
||||
Workaround:
|
||||
mkdir -p /etc/qemu/firmware
|
||||
touch /etc/qemu/firmware/50-edk2-ovmf-cc.json
|
||||
|
||||
# Install KVM on CentOS8
|
||||
https://www.cyberciti.biz/faq/how-to-install-kvm-on-centos-8-headless-server/
|
||||
|
||||
# Online unicast MAC adress generator for network interface
|
||||
https://www.hellion.org.uk/cgi-bin/randmac.pl
|
||||
|
||||
# Static MAC Generator for KVM
|
||||
# from http://blog.zencoffee.org/2016/06/static-mac-generator-kvm/
|
||||
MAC=$(date +%s | md5sum | head -c 6 | sed -e 's/\([0-9A-Fa-f]\{2\}\)/\1:/g' -e 's/\(.*\):$/\1/' | sed -e 's/^/52:54:00:/')
|
||||
echo $MAC
|
||||
Reference in New Issue
Block a user