A little trick to save time.

Share this link

When you are working in your lab, you regularly need to reinstall your virtual machine to start a new configuration.
If you use a tool like Virtual Box, you can save virtual machine images and restore them.
But if you use KVM, you can’t do that, and it takes time to reinstall the system.
To avoid this waste of time, you can set up your virtual machine inside a unique volume group (here vg_root with at least 1GB of free space) and use the snapshot feature available since RHEL6. This way, you only need to reboot and wait one or two minutes (the time for the snapshot to be restored).

The command is called snap and takes one parameter:
– begin: to start the snapshot,
– rollback: to destroy the snapshot and remove all the previous changes,
– commit: to destroy the snapshot and keep the changes.

#!/bin/sh
if [ "$#" -ne "1" ]; then
echo "Syntaxe: snap [begin|commit|rollback]"
exit
fi

case $1 in
begin) lvcreate --size 1G -s --name lv_snap /dev/vg_root/lv_root ;;
commit) lvremove -f /dev/vg_root/lv_snap ;;
rollback) lvconvert --merge /dev/vg_root/lv_snap ;;
esac
Posted in RHEL6

Leave a Reply

Be the First to Comment!

Notify of
wpDiscuz

RHCSA7: Task of the day

Allowed time: 3 minutes.
Check that you've got no SELinux policy violations.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a caching-only DNS server to forward DNS queries.

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...

Recent Comments