Skip to content

Instantly share code, notes, and snippets.

@coolbrg
Forked from mayurah/kvm_cheatsheet.sh
Created July 30, 2016 08:16
Show Gist options
  • Save coolbrg/9633287db003a93607dc792ae61d914d to your computer and use it in GitHub Desktop.
Save coolbrg/9633287db003a93607dc792ae61d914d to your computer and use it in GitHub Desktop.
KVM / QEMU Cheatsheet
# List System(s)
virsh -c qemu:///system list
virsh list # List running
virsh list --all # List all
# Open guest VM console
virsh console <instance>
# Control specific instance
virsh start <instance>
virsh shutdown <instance>
virsh destroy <instance>
virsh suspend <instance>
virsh resume <instance>
## Install the Virtualization groups:
$ yum grouplist | grep -i virt
Virtualization
Virtualization Client
Virtualization Platform
Virtualization Tools
$ yum grouplist | grep -i virt | while read line
do
yum -y groupinstall "${line}"
done
Create another LV for images:
$ lvcreate -L 200g -n ignite vg00
$ mkfs.ext4 /dev/vg00/ignite
$ mkdir -p -m 755 /ignite
## // Edit fstab
/dev/mapper/vg00-ignite /ignite ext4 defaults 1 2
$ mount /ignite
$ mkdir -p -m 755 /ignite/images
$ chcon --reference /var/lib/libvirt/images /ignite/images
$ rmdir /var/lib/libvirt/images
$ ln -s /ignite/images /var/lib/libvirt/images
# Define instances
virsh dumpxml <instance> >dump.xml
virsh create dump.xml # Create from XML
virsh edit <instance>
virsh undefine <instance>
virsh blockresize <instance> --path vda --size 100G
virsh dominfo
virsh vcpuinfo
virsh nodeinfo
virsh quit # Leave CLI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment