13,420
edits
Changes
no edit summary
== Purpose / Objectives of Lab2==
[[Image:hostmachine.png|thumb|right|300px|The c7host Linux server will run virtualization software to install and run 3 virtual machines (installed in lab2). ]]
'''In this lab, you will create three virtual machines'''. This also gives you an opportunity to experiment with different ways of installing CentOS.
You will be learning the following elements of Virtualization in this lab:
::# Author: *** INSERT YOUR NAME ***
::# Date: *** CURRENT DATE ***
::
::
<br>
<ol><li value="4">Save your editing session, but remain in the text editor.</li><li>This shell script is designed particularly for your centos1, centos2, and centos3 VMS.</li><li>The code displayed below will prompt the user if they wish for all VMs to be backed-up; otherwise, allow the user the option of specifying which VMs to be backed-up. Add the following code</li></ol>
<code style="color:#3366CC;font-family:courier;font-size:.9em;">
:: read -p "Backup all VMs? (y|n):" answer # prompt if all VMs to be backed-up
::
::if [ "$answer" = "y" ] # Backup all VMs if answer is yes
::then
:: for num in 1 2 3 # Determinant loop for 3 arguments: 1, 2, and 3
:: do
:: echo "Backing up VM #$num"
:: gzip < /var/lib/libvirt/images/centos$num.img > /root/centos$num.img.backup.gz
:: echo "VM #$num BACKUP DONE"
:: done
::elif [ "$answer" = "n" ]
::then
:: read -p "Which VM should be backed up? (1/2/3): " numanswer
:: until echo $numanswer | grep "^[123]$" >> /dev/null # Look for match of single digit: 1,2, or 3
:: do
:: read -p "Invalid Selection. Select 1, 2, or 3: " numanswer
:: done
:: echo "Backing up VM #$numanswer"
:: gzip < /var/lib/libvirt/images/centos$numanswer.img > /root/centos$numanswer.img.backup.gz
:: echo "VM #$numanswer BACKUP DONE":
::else
:: echo "Invalid Selection... Aborting program"
:: exit 2
::fi
</code>