Changes

Jump to: navigation, search

OPS235 Lab 5 - CentOS7 - VMware

2 bytes added, 13:35, 25 May 2016
no edit summary
=== Part 1: Manage LVM Graphically===
[[Image:lvm1.png|thumb|500px|right|The '''system-config-lvm''' application allows the Linux system administrator to manage LVMs Graphically. Your LVM information for '''centos2centos3''' VM should be similarly displayed.]]# Let's learn to administer (manage) our LVM graphically for our '''centos2centos3''' Virtual Machine.# Launch your '''centos2centos3''' VM and open a shell terminal.
# CentOS provides a tool called '''system-config-lvm''' to graphically administer LVM.<br><br>'''NOTE:''' This tool may be replaced by a future graphical LVM management tool and is NOT currently available in the default repositories. We will now perform a "work-around" in order to make the system-config-lvm utility work in our system.<br><br>
# Issue the following command to download the system-config-lvm rpm:<br><b><code><span style="color:#3366CC;font-size:1.2em;">wget https://kojipkgs.fedoraproject.org//packages/system-config-lvm/1.1.18/1.fc19/noarch/system-config-lvm-1.1.18-1.fc19.noarch.rpm</span></code></b><br>(Although it is an rpm file for the Fedora Distribution, it will also work for Centos7).<br><br>
<li>Now issue the commands '''n''' (new partition), '''p''' (primary partition), '''3''' (i.e. next available partition number). When prompted for initial block, '''press enter to accept the default beginning block size''', and '''type: +2G''' at ending block (create 2GB for partition) and '''press enter'''. </li>
<li>At the fdisk prompt, issue the command '''p''' to review the partition information, then type '''w''' to save partition table and exit (ignore WARNING message).</li>
<li>You <u>'''must'''</u> restart your centos2 centos3 VM to allow changes to take effect</li>
<li>Open a terminal as root, and format your newly-created partition by issuing the command: <b><code><span style="color:#3366CC;font-size:1.2em;">mkfs -t ext4 /dev/vda3</span></code></b><br>(or ''mkfs -t ext4 /dev/sda3'')</li>
</ol>
<li>'''Restart system-config-lvm'''. You should notice a section at the bottom indicating <u>Unallocated</u> Physical Volumes. Click on the <u>unallocated</u> partition /dev/vda3 and then click '''Add to Existing Volume Group''' (click on other button in next screen to continue). The screen should now show the partition ''/dev/vda3'' contained in our default Volume Group (refer to diagram on right-side for reference).</li>
<li>Click on Logical View (i.e. above home, root, swap), and then click on '''Create New Logical Volume''' button and fill out the details for this new logical volume including: size: '''1GB''', LV Properties: '''linear''', file system: '''ext4''' file system name: '''archive''', select '''mount''' and mount it at: '''/archive'''. Have the system create the directory ''/archive'' if it does not exist (Refer to diagram on right for reference).</li>
<li>Confirm that this new Logical Volume now exists by changing to the directory /archive. Did you need to restart your centos2 centos3 VM to confirm that the '''/archive''' directory is now on your '''centos2centos3''' VM?</li>
<li>Use system-config-lvm to resize (i.e. edit) the '''archive''' logical volume to '''1.5 GB''' and verify your results.</li>
</ol>
===Part 2: Managing LVM Via Command Line & Adding Virtual Hard Drives===
[[Image:add_virtual_disk.png|thumb|400px|right|You can add virtual hard disks for a VM by changing to the '''Details''' section for the VM (as opposed to ''console''), click '''Add Hardware''', fill information in the '''Add New Virtual Hardware''' dialog box and clicking '''Finish'''.]]
Let's say that you have run out of disk space on your '''centos3centos4''' VM, and you need more space on the root file-system in order to host more web-pages, or to support a larger database. What are your options? Getting a replacement hard-drive would probably require re-installation of the operating system and/or backing up and restoring data on the old hard disk.
Because we're using LVM we can avoid this problem. We can '''add a new <u>virtual</u> hard-drive''' (which will serve as a physical volume) to the volume group, and extend the root logical volume to make use of the new available space. Creating virtual hard drives is not only inexpensive, but a great way for students to learn now to simulate growing the size of the file system.
'''Perform the following operations to increase the size of lv_root in centos3centos4:'''
# Perform this Part in your '''centos3centos4''' VM.
# Run the following commands and make note of the output:
::<b><code><span style="color:#3366CC;font-size:1.2em;">ls /dev/vd*</span></code></b>
<li>Go back to the '''console''' view</li>
<li>Issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">ls /dev/vd*</span></code></b>, what has changed?</li>
<li>Use '''fdisk''' (''refer to how to use in Part 1'') to create a new single primary partition for '''/dev/vdb''' that fills the entire disk, save partition table (accepting defaults prompts would work), restart your '''centos3centos4''' VM and then '''format''' that partition for file type: '''ext4'''.</li>
<li>Now we'll make the new device a '''physical volume''', add it to the '''volume group''', and extend '''lv_root''':</li>
</ol>
== Part 1: Mounting and Un-mounting Partitions ==
[[Image:mount.png|thumb|700px|right|Using the '''mount''' command with no arguments displays file-systems that are already mounted. The Linux system administrator can use the '''mount''' and '''umount''' commands to connect and disconnect different partitions from the file-system to perform maintenance.]]
# Perform this part in your '''centos2centos3''' VM.
# As you may recall in Part 1 of Investigation 1, we created another logical volume called '''archive''' using the graphical application '''system-config-lvm'''. This logical volume should be mounted (connected) to our existing file-system (2GB).
# Issue the following command: <b><code><span style="color:#3366CC;font-size:1.2em;">mount</span></code></b>
# View the contents of the file-system table /etc/fstab by issuing the following command:<br><b><code><span style="color:#3366CC;font-size:1.2em;">cat /etc/fstab</span></code></b>
# Note the line that automatically mounts a file-system (''/dev/sda3'', type ''ext4'') to '''/archive'''. This was automatically performed for you via the '''system-config-lvm''' utility.
# View and record the fields for the '''/archive''' mount in your lab logbook, and then issue the following command to reconnect or mount '''/archive''':<br><b><code><span style="color:#3366CC;font-size:1.2em;">mount &nbsp; -t ext4 &nbsp; /dev/centos_centos2centos_centos3/archive &nbsp; /archive</span></code></b><br><br>'''NOTE:''' If you are having problem mounting, use the /dev pathname listing in your /etc/fstab file.<br><br># Confirm that this file-system has been properly mounted. Note: You could have also issued the command: '''mount -a''' to <u>automatically</u> mount the file-systems contained in the '''/etc/fstab''' file.<br><br>Tip: If you had to do manually configure /etc/fstab (eg. only in text-based mode - centos3centos4), you could have issued the command (as root):<br> <b><code><span style="color:#3366CC;font-size:1.2em;">echo "/dev/centos_centos2centos_centos3/archive /archive ext4 defaults 1 2" >> /etc/fstab</span></code></b><br>(although we don't need to do this, since it was already done).<br><br>
# '''A curious question''': If root needs to unmount the '''/home''' directory for maintenance but we had to first login in graphically as a regular user, then su to "root", isn't our regular user still logged in so we can't un-mount the /home directory?!? How can we as a Linux System Administrator get around the problem (hint: you already learned it somewhere in lab3!!! Wow, using what we already taught can pay-off in the future ... lol!).
Monitoring disk space activity helps provide Linux system administrators information to help take corrective action before problems can occur.
# Remain in your '''centos2centos3''' VM for this section.
# Issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">df -h</span></code></b>
# Note the disk space usage for '''/''', '''/home''', and '''/archive''' partitions.
#Perform this section in your '''c7hostcentos1''' machine
#Make certain you are logged in as '''root'''.
#Download, study, and run the following shell script. Issue the command:<br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">wget https://scs.senecac.on.ca/~murray.saul/monitor-disk-space.bash</span></code></b>
'''Arrange proof of the following on the screen:'''
<ol><li><span style="color:green;font-size:1.5em;">&#x2713;</span> '''centos2centos3''' VM:<blockquote><ul><li>'''Logical Volume''', '''Physical Volume''', and '''Volume Group''' information </li><li>Contents of '''/etc/fstab''' file</li><li>Proof that '''/archive''' has been mounted</li></ul></blockquote><li><span style="color:green;font-size:1.5em;">&#x2713;</span> '''centos3centos4''' VM:<blockquote><ul><li>Proof of virtual hard disk creation</li><li>'''Logical Volume''', '''Physical Volume''', and '''Volume Group''' information </li></ul></blockquote></li><li><span style="color:green;font-size:1.5em;">&#x2713;</span> '''c7hostcentos1''' Machine:<blockquote><ul><li>Proof of creation of the shell script: '''monitor-disk-space.bash'''</li><li>Crontab entry for '''root''' account</li></ul></blockquote><li><span style="color:green;font-size:1.5em;">&#x2713;</span> '''Lab5''' log-book filled out.</li></ol>
13,420
edits

Navigation menu