KVM Command
☰ Table of Content
Some KVM frequently used commands.
Connection string
virsh and virt-manager use same connection string.
Local
1virsh -c qemu:///systemRemote
1virsh -c qemu+ssh://user@hostname/systemRemote from MacOS
1virsh -c qemu+ssh://user@hostname/system?socket=/var/run/libvirt/libvirt-sock
VM
| |
Snapshot
List
1virsh snapshot-list <vm name>Create
1 2virsh snapshot-create -domain <vm name> virsh snapshot-create-as --domain <vm name> --name <snapshot name>Revert
1virsh snapshot-revert <vm name> <snapshot name>Delete
1virsh snapshot-delete --snapshotname <snapshot name> <vm name>
Network
| |
Pool and Vol
| |
Image
Create
1 2qemu-img create -f <format> <filename> <size> qemu-img create -f qcow2 ubuntu.img 500Mvmdk(vmware) and vdi(virtualbox) are supported.
Snapshot
1qemu-img create -f qcow2 -b ubuntu.master.qcow2 ubuntu.qcow2Info
1qemu-img info <filename>Resize
1 2 3 4qemu-img resize <filename> [+|-]<size> qemu-img resize ubuntu.img 550M # set image to new size, use --shrink if new size is smaller qemu-img resize ubuntu.img +10M # increase image size by 10M qemu-img resize --shrink ubuntu.img -10M # decrease image size by 10MCheck Linux Commands for resizing partition after an image resize.
John Siu
Update: 2022-05-12