Documentation/CreateSnapshot: Difference between revisions
No edit summary |
|||
Line 4: | Line 4: | ||
qemu-img create -f qcow2 -b centos-cleaninstall.img snapshot.img | qemu-img create -f qcow2 -b centos-cleaninstall.img snapshot.img | ||
At this point, you would run QEMU against ''snapshot.img''. Making any changes to its backing file (''centos-cleaninstall.img'') will corrupt this snapshot image. | |||
== Returning to a previous version == | == Returning to a previous version == | ||
A snapshot image cannot be returned to its original state once modified. Instead delete the first snapshot image (''snapshot.img'' in our example), create another snapshot image of the base image as above, and start using the new .img file. | |||
== Modifying the backing file == | |||
Making any changes to a base image (''centos-cleaninstall.img'' in our example) will corrupt its snapshots. Make sure to delete any snapshots before running and modifying the original image. Use the ''qemu-img info'' command to determine an image's backing file. | |||
$ qemu-img info snapshot.img | |||
... | |||
backing file: centos-cleaninstall.img (actual path: centos-cleaninstall.img) | |||
== Temporary snapshots == | |||
QEMU also supports temporary snapshots, where the user does not have to explicitly create a separate .img file. With the ''-snapshot'' flag, any changes made to the virtual machine while it is running are written to temporary files and thrown away when the virtual machine is turned off. No changes are saved to the original .img file. | |||
qemu -hda centos-cleaninstall.img -snapshot |
Revision as of 18:33, 28 November 2010
Create a snapshot
Snapshots in QEMU are images that refer to an original image using Copy-on-Write to avoid changing the original image. If you want to create a snapshot of an existing image called centos-cleaninstall.img, create a new QCow2 file using the -b flag to indicate a backing file. The new image is now a read/write snapshot of the original image -- any changes to snapshot.img will not be reflected in centos-cleaninstall.img.
qemu-img create -f qcow2 -b centos-cleaninstall.img snapshot.img
At this point, you would run QEMU against snapshot.img. Making any changes to its backing file (centos-cleaninstall.img) will corrupt this snapshot image.
Returning to a previous version
A snapshot image cannot be returned to its original state once modified. Instead delete the first snapshot image (snapshot.img in our example), create another snapshot image of the base image as above, and start using the new .img file.
Modifying the backing file
Making any changes to a base image (centos-cleaninstall.img in our example) will corrupt its snapshots. Make sure to delete any snapshots before running and modifying the original image. Use the qemu-img info command to determine an image's backing file.
$ qemu-img info snapshot.img ... backing file: centos-cleaninstall.img (actual path: centos-cleaninstall.img)
Temporary snapshots
QEMU also supports temporary snapshots, where the user does not have to explicitly create a separate .img file. With the -snapshot flag, any changes made to the virtual machine while it is running are written to temporary files and thrown away when the virtual machine is turned off. No changes are saved to the original .img file.
qemu -hda centos-cleaninstall.img -snapshot