Bookmark this page

Guided Exercise: Creating and Using Image Snapshots

In this exercise, you will create and restore virtual machine snapshots.

Outcomes

You should be able to:

  • Create a snapshot of a virtual machine.

  • Revert a virtual machine to an earlier state using a snapshot.

Log in to workstation as the student user with student as the password.

On workstation, run the lab snapimex-snapshots start command. This command runs a start script that determines if the Red Hat Virtualization environment is configured and working.

[student@workstation ~]$ lab snapimex-snapshots start
  1. Create a snapshot of the rhel-vm1 virtual machine. If there is more than one rhel-vm1 virtual machines, use the one located in clusterone.

    1. Using the https://rhvm.lab.example.com URL log into the Administration Portal as admin with the internal profile. Use redhat as the password.

    2. In the menu, click Compute, then Virtual Machines.

    3. Right-click the row for the rhel-vm1 virtual machine in the development data center, and then click Create Snapshot. The Create Snapshot window displays.

    4. Enter rhel-vm1-snapshot as a description for the snapshot in the Description field. Verify that the rhel-vm1_Disk1 disk is selected in the Disks to include section. Click OK to create the snapshot.

    5. In Compute >> Virtual Machines, select the row for the rhel-vm1 virtual machine and click on the machine name. Select Snapshots. Click on the rhel-vm1-snapshot snapshot. Click on General. Verify that the value of the Status field is OK. It may take up to a minute to create this snapshot.

  2. Modify the Message of the Day (MOTD) on the rhel-vm1 virtual machine.

    1. In the menu, click Compute, then click on Virtual Machines.

    2. Highlight the row containing the rhel-vm1 virtual machine by clicking an empty cell in that row. Click on Run to start the virtual machine.

    3. Right-click the row for the rhel-vm1 virtual machine, and then select Console. Accept the opening of the console.vv file using Remote Viewer by clicking the OK button. When the warning box displays, click on Allow.

    4. Log into the rhel-vm1 virtual machine as root using redhat as the password.

    5. Verify that the MOTD file for the rhel-vm1 virtual machine is empty.

      [root@localhost ~]# cat /etc/motd
      [root@localhost ~]# 
    6. Modify /etc/motd to contain the string RHV managed virtual machine.

      [root@localhost ~]# vi /etc/motd
      RHV managed virtual machine
      
    7. Log out of rhel-vm1.

      [root@localhost ~]# logout
  3. Revert rhel-vm1 back to the rhel-vm1-snapshot snapshot.

    1. In the menu, click Compute, and then click on Virtual Machines.

    2. Highlight the row for the rhel-vm1 virtual machine by clicking on an empty cell, and then select Shutdown. The Shut down Virtual Machine(s) window displays. Click OK to shut down rhel-vm1.

    3. Verify that the value of the Status field for the rhel-vm1 virtual machine is Down. You may need to scroll the virtual machine list window to the right. It may take a few seconds for RHV-M to mark rhel-vm1 as Down.

    4. Click on the name of the rhel-vm1 virtual machine. A new window opens with the virtual machine configuration.

    5. Click on the Snapshots tab.

    6. Select the snapshot with the description rhel-vm1-snapshot. Click the Preview drop-down menu and select Custom. The Custom Preview Snapshot window displays.

    7. Select the radio button for the snapshot with the description rhel-vm1-snapshot. Verify that the check box for the rhel-vm1_Disk1 disk is selected. Click OK to revert rhel-vm to the rhel-vm-snapshot snapshot.

    8. Click on Compute >> Virtual Machines at the top of the page.

    9. In the row for the rhel-vm1, verify that the value of the Status field transitions from Image Locked to Down.

    10. Click on the name of the rhel-vm1 virtual machine, and then click on Snapshots. Click on the General menu for the rhel-vm1-snapshot. Verify that the value of the Status field for the rhel-vm1-snapshot snapshot is IN_PREVIEW. Click the Commit button. When the Commit Snapshot window displays, click on OK.

    11. In the menu, click on Events. Verify that the message Commiting a Snapshot-Preview for VM rhel-vm1 has been completed displays. This confirms that RHV-M successfully restored the rhel-vm-snapshot snapshot in the rhel-vm virtual machine.

  4. Verify that rhel-vm1 properly rolled back to the state in the rhel-vm1-snapshot snapshot.

    1. In the menu, click Compute, and then select Virtual Machines.

    2. Right-click the row for the rhel-vm1 virtual machine, and then select Run. Verify that the value of the Status field for the rhel-vm1 virtual machine is Up. It may take up to a minute for the rhel-vm virtual machine to start.

    3. Right-click the row for the rhel-vm1 virtual machine, and then select Console. Log in using root as the user and redhat as the password.

    4. Using the cat command, verify that the MOTD for the rhel-vm1 virtual machine is empty.

      [root@localhost ~]# cat /etc/motd
      [root@localhost ~]#  
    5. Log out of the rhel-vm1 virtual machine.

      [root@localhost ~]# logout
  5. Delete the rhel-vm1-snapshot snapshot.

    1. In Virtual Machines, select the rhel-vm1 virtual machine by clicking on the name. The rhel-vm1 virtual machine is in clusterone.

    2. Go to Snapshots. Select the rhel-vm1-snapshot snapshot. Click Delete. The Delete Snapshot window displays. Click OK.

    3. Confirm that RHV-M removes the rhel-vm1-snapshot snapshot from the snapshot listing. It may take up to a minute.

Finish

On workstation, run the lab snapimex-snapshots finish script to complete this exercise.

[student@workstation ~]$ lab snapimex-snapshots finish

This concludes the guided exercise.

Revision: rh318-4.3-c05018e