KVM Command
☰ Table of Content
Some KVM frequently used commands.
Connection string
virsh and virt-manager use same connection string.
Local
1
virsh -c qemu:///system
Remote
1
virsh -c qemu+ssh://user@hostname/system
Remote from MacOS
1
virsh -c qemu+ssh://user@hostname/system?socket=/var/run/libvirt/libvirt-sock
VM
|
|
Snapshot
List
1
virsh snapshot-list <vm name>
Create
1 2
virsh snapshot-create -domain <vm name> virsh snapshot-create-as --domain <vm name> --name <snapshot name>
Revert
1
virsh snapshot-revert <vm name> <snapshot name>
Delete
1
virsh snapshot-delete --snapshotname <snapshot name> <vm name>
Network
|
|
Pool and Vol
|
|
Image
Create
1 2
qemu-img create -f <format> <filename> <size> qemu-img create -f qcow2 ubuntu.img 500M
vmdk(vmware) and vdi(virtualbox) are supported.
Snapshot
1
qemu-img create -f qcow2 -b ubuntu.master.qcow2 ubuntu.qcow2
Info
1
qemu-img info <filename>
Resize
1 2 3 4
qemu-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 10M
Check Linux Commands for resizing partition after an image resize.
John Siu
Update: 2022-05-12