This was written when latest release version of UTM was v4.5.3
.
NOTE: Snapshots using qemu-img
is not supported for macOS VMs due to .img
image format as other pre-configured non-macOS VMs are using .qcow2
as the storage backend, which is well-supported.
Credit goes to lnxbil for mentioning this workaround
-
Run
brew install qemu
on macOS with Homebrew installed already. -
Right-click the VM on the left pane of the UTM window app and select Show in Finder.
-
The easiest way to determine the location of the
.utm
VM file (really, it's a folder) is to right-click it then select New Terminal at Folder to open the Terminal, and it'd take you directly to that directory as your$PWD
. We'll use the same Terminal for the subsequent steps. -
Run
cd Data
.Assuming there's only one
.qcow2
file listed in theData
directory as it would be conveniently manageable dealing with just one. Here are the syntaxes you'd only need to know to perform the snapshots usingqemu-img
command:PLEASE NOTE: Snapshots cannot be created, applied, listed, or deleted while the VM is running. It must be in either in
suspended
orstopped
state.Command syntax: snapshot [--object objectdef] [--image-opts] [-U] [-q] [-l | -a snapshot | -c snapshot | -d snapshot] filename Parameters to snapshot subcommand: 'snapshot' is the name of the snapshot to create, apply or delete '-a' applies a snapshot (revert disk to saved state) '-c' creates a snapshot '-d' deletes a snapshot '-l' lists all snapshots in the given image
-
To create the snapshot, run:
qemu-img snapshot F8793221-25FF-47CE-8163-347DD16963E6.qcow2 -c fresh_install
It's a strong recommendation to use a unique (unused names in the list of snapshots) descriptive
TAG
name in the last argument even though you can reuse the same name. If you attempt to reuse the same name, the new snapshot would be created with higherID
value than the original or previous snapshots with the same name, which means you would not be able to conveniently delete the latest snapshot as the original or previous snapshots have the higher priority. -
To list the snapshot, run:
qemu-img snapshot F8793221-25FF-47CE-8163-347DD16963E6.qcow2 -l
Output of the command (ex. containing 2 snapshots with same name):
Snapshot list: ID TAG VM_SIZE DATE VM_CLOCK ICOUNT 1 fresh_install 0 B 2024-06-26 21:45:02 0000:00:00.000 0 2 fresh_install 0 B 2024-06-26 21:45:14 0000:00:00.000 0
-
To apply the snapshot, run:
You can only apply the change to the VM if it's in a
suspended
orstopped
state.qemu-img snapshot F8793221-25FF-47CE-8163-347DD16963E6.qcow2 -a fresh_install
Although, please note that the above command would use the oldest snapshot if the
TAG
name is the same.To reference the snapshot by its
ID
instead (regardless of the duplicatedTAG
names), use the following command:qemu-img snapshot F8793221-25FF-47CE-8163-347DD16963E6.qcow2 -a 2
-
To delete the snapshot, run:
You can only delete the snapshot if the associated VM is in a
suspended
orstopped
state.qemu-img snapshot F8793221-25FF-47CE-8163-347DD16963E6.qcow2 -d fresh_install
Just like the apply command in the previous step, the command would delete the oldest snapshot if the
TAG
name is the same. However, the snapshot cannot be deleted by itsID
value as shown in the snapshot list. So, it's strongly encouraged to give snapshot name a uniqueTAG
name. -
To view the actual disk size versus the virtual size along with a list of associated snapshots, you can use the command:
qemu-img info F8793221-25FF-47CE-8163-347DD16963E6.qcow2
Please remember, you cannot list snapshots while the VM is running due to
.qcow2
file being locked during use, preventing write operations.