How to reset Virtual Machine in Redhat 7/8 , Centos 7/8 , Fedora linux ( rht-vmctl reset )

Share on :

How to reset Virtual Machine in Redhat 7/8 , Centos 7/8 , Fedora linux ( rht-vmctl reset )

In our RHCSA & RHCE training we have used a command rht-vmctl reset all , rht-vmctl reset server , rht-vmctl reset desktop to reset Virtual Machines.

Now, Here we are going to create our reset virtual machine command.

Pre-requirments:-

=> Make sure you have a fresh Installed VM.

1 ) Open your Virtual Machine Manager.

Applications > SystemTools > Virtual Machine Manager

2 ) Now using virsh command we will create snapshot of virtual machines .

Note:-Make sure that your Virtual Machine is off.

root[email protected] # virsh
virsh # snapshot-create-as Server MyServer
virsh # snapshot-list Server

3 ) Similarly for Desktop VM :-

[email protected] # virsh
virsh # snapshot-create-as Desktop MyDesktop
virsh # snapshot-list Desktop

4 ) Now we will create a Directory in which we will keep our scripts for our commands.

[email protected] # mkdir /reset
[email protected] # vim /reset/server.sh

#!/bin/bash
echo "####### VIRTUAL MACHINE MANAGER #######"
virsh snapshot-revert Server MyServer
virsh start Server
echo "####### Server Reset Succesfully ######"

:wq

[email protected] # vim /reset/desktop.sh

#!/bin/bash
echo "###### VIRTUAL MACHINE MANAGER ######"
virsh snapshot-revert Desktop MyDesktop
virsh start Desktop
echo "###### Desktop Reset Succesfully ######"

:wq

[email protected] # vim /reset/all.sh

#!/bin/bash
echo "####### VIRTUAL MACHINE MANAGER ######"
virsh snapshot-revert Server MyServer
virsh start Server
virsh snapshot-revert Desktop MyDesktop
virsh start Desktop
echo "####### Server Desktop Reset Succesfully ######"

:wq

5 ) Now we will give execute permission to our scripts .

[email protected] # chmod +x /reset/server.sh
[email protected] # chmod +x /reset/desktop.sh
[email protected] # chmod +x /reset/all.sh

6 ) Now we are going to create custom commands "alias".

echo "alias vm-reset-server='/reset/server.sh'" >> /etc/bashrc
echo "alias vm-reset-desktop='/reset/desktop.sh'" >> /etc/bashrc
echo "alias vm-reset-all='/reset/all.sh'" >> /etc/bashrc

[email protected] # source /etc/bashrc

7 ) Now Execute your Commands and enjoy you own Virtual Machine Reset Commands 🙂

[email protected] # vm-reset-server
[email protected] # vm-reset-desktop
[email protected] # vm-reset-all

Share on :

You may also like...

1 Response

  1. Rajani says:

    Thank you for sharing vauable infromation.
    DevOps Training
    DevOps Online Training
    DevOps Training in Ameerpet

Leave a Reply

Your email address will not be published. Required fields are marked *