Abstract
| Goal | Manage virtual machine snapshots and disk images. |
| Objectives |
|
| Sections |
|
| Lab |
Managing Virtual Machine Images |
After completing this section, you should be able to create, restore, and delete snapshots of virtual machine images.
A snapshot is a view of a virtual machine that includes the operating system and applications on any or all available disks at a given point in time. An administrator may take a snapshot of a virtual machine before making changes to it. This can protect against errors that might have unintended consequences. If there is a problem, the administrator can revert the state of the virtual machine to one recorded by the snapshot.
Red Hat Virtualization allows you to take live snapshots of running virtual machines, as well as snapshots of stopped virtual machines. RHV-M supports several snapshots of a virtual machine, but it can only use a single snapshot at a time.
You can shut down the virtual machine and permanently roll the disk image back to an earlier snapshot. When you do, RHV-M discards all snapshots taken at later points in time. Before committing to the rollback, you can temporarily preview a particular snapshot by booting it to confirm that it is the one you want to use.
Snapshots can also be used to create new virtual machines. You can clone a virtual machine from an older snapshot rather than cloning directly from a current virtual machine. A clone is a copy of that virtual machine on new hardware. Be aware that a clone is likely to have machine specific data and configuration settings from the original virtual machine. This may or may not be desired. As an alternative, you can use a snapshot to create a "sealed template" that can be used to create virtual machines from an image that has had this machine specific information cleared.
Red Hat Virtualization allows you to manually create snapshots for virtual machines with the Administration Portal. A virtual machine needs the RHV guest agent to create a consistent snapshot.
Snapshots are created in the → menu of the Administration console. Right-click the virtual machine to use as the source of the snapshot, and then select from the menu. The Create Snapshot window displays. The virtual machines disks are automatically selected. However, one or more disks can be deselected when creating the snapshot. Enter a description for the snapshot in the Description field.
If the virtual machine is running, you may select the Save Memory check box to save the memory state of the virtual machine in the snapshot. The resulting snapshot looks like a suspended version of the virtual machine. Click to create the snapshot.
After clicking on , click on the name of the virtual machine.
Then, click on Snapshots.
Watch the snapshot display in the bottom window.
Click on General.
The status should display OK.
It may take a minute or so for this value to transition from Locked to OK.
Once you have a snapshot, you can shut down the original virtual machine and relaunch it using an earlier snapshot. You have the option to preview the snapshot before committing to the rollback. In this mode, the virtual machine runs using the virtual image of the snapshot. This allows you to confirm that you have the right snapshot selected.
When you are ready, you can permanently commit to the rollback. The active image for the virtual machine reverts to the snapshot, and all snapshots newer than the one selected for rollback are permanently discarded.
To preview and roll back a virtual machine state using a snapshot, click the → menu item in the Administration Portal. Select a virtual machine from the list, and make sure that it has been shut down. Select the Snapshots tab for the virtual machine by clicking on the name of the virtual machine, and then clicking on the Snapshots tab. Find the snapshot that you want to restore and select it from the list.
To see information about the snapshot, click the button. If the snapshot has a saved memory state, then a window opens with a prompt to restore memory. The snapshot moves to the state IN_PREVIEW, which indicates that it is ready to run. In Preview mode, you are simply trying to decide if you have selected the correct snapshot. If you Undo the preview, then any changes you make are discarded. If you Commit the snapshot, then changes made in the preview are retained.
To run the preview on a temporary basis, click on Run from the Snapshots tab. When you have decided whether or not to roll back to that snapshot, you can shut down the virtual machine.
If you have decided to roll back to that snapshot permanently, then click the Commit option on the Snapshots tab. This rolls the state of your virtual machine back to that snapshot on a permanent basis, and discards any snapshots that were taken more recently. Then, Run the virtual machine normally to restart it.
Alternatively, if you decide not to roll back to that snapshot, click the Undo option on the Snapshots tab. The snapshot changes state from In Preview to OK, and your original image changes state from Locked to OK. You can now run the virtual machine normally, or you can try rolling back to a different snapshot.
The decision to commit to a particular snapshot is irreversible. The formerly current image state, any snapshot newer than the snapshot you committed, and all unique associated data, is permanently lost.
Any existing snapshot can be used to clone a virtual machine. Remember, a clone is a copy of a virtual machine created on new hardware. It can be useful to create a clone from a snapshot instead of a current virtual machine, for example, to make a copy of some older state of that virtual machine. Alternatively, you may want to permanently revert to an earlier snapshot, and you may want to clone later snapshots before they are deleted.
To clone a virtual machine from an existing snapshot, click on , then click on in the Administration Portal and select a virtual machine from the list. Select the Snapshots tab for the virtual machine by clicking on the name of the virtual machine, then clicking on the Snapshots tab. Find the snapshot you want to clone and select it from the list, and then click Clone. This opens a new window, Clone VM from Snapshot, which is very similar to the New Virtual Machine window.
At a minimum, set a Name for the cloned virtual machine. You can customize other details as well. Then, click to create the cloned virtual machine.
Watch the status of the virtual machine on the → tab. Once the status switches to Down, you may run the new machine.
A cloned virtual machine may still have data from its source image. You might not want this if you are trying to create a new virtual machine with a similar configuration rather than an exact copy.
As an alternative, you can use the snapshot to create a sealed template that has been cleared of unique data, and then create virtual machines from that template. A template can be created from a snapshot by using the Make Template option instead of Clone.
Chapter 8, Deploying and Managing Virtual Machines discusses how to create and use templates.
To delete a snapshot using the Administration Portal, click on , and then click on . Select the row for the virtual machine associated with the snapshot. Click on the name of the virtual machine then select the Snapshots tab. Select the snapshot to delete, and then click .
The Delete Snapshot window opens to confirm that you want to permanently remove that snapshot. If you do, click to delete the snapshot. In the Snapshots tab, verify that the snapshot is no longer displayed. It may take a minute or so to delete the snapshot.
Further information is available in the Administrative Tasks chapter of the Virtual Machine Management Guide for Red Hat Virtualization; at https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.3/html-single/virtual_machine_management_guide/index#chap-Administrative_Tasks