You can create a snapshot of a KVM virtual machine (VM) or domain in Linux using the virsh
command-line tool.
Here’s the general process for creating a snapshot in a KVM virtual machine or domain:
- Connect to the KVM host: Connect to the KVM host using
ssh
or by using the console directly. - List running VMs/domains: Use the following command to list all running virtual machines or domains on the KVM host:
virsh list
- Create a snapshot: Use the following command to create a snapshot of the specified virtual machine or domain:
virsh snapshot-create-as [domain-name/domain-id] [snapshot-name]
For example, if you want to create a snapshot of a virtual machine with the domain name “myvm”, you would run:
virsh snapshot-create-as myvm myvm-snapshot
- Verify the snapshot: You can verify that the snapshot was created by using the following command:
virsh snapshot-list [domain-name/domain-id]
This will list all snapshots for the specified virtual machine or domain.
Please note that snapshots can take up a significant amount of disk space, especially if the virtual machine is running and actively changing data. Make sure to regularly delete snapshots that are no longer needed to keep disk usage under control.