Changes

Jump to: navigation, search

OPS235 Lab 5 - CentOS7

546 bytes added, 12:15, 27 November 2019
no edit summary
{{Admon/caution|THIS IS AN OLD VERSION OF THE LAB|'''This is an archived version. Do not use this in your OPS235 course.'''}}
[[Category:OPS235]]
The purpose of this lab is to discuss demonstrate how a Linux system administrator can monitor hard disk space availability, and to manage file system size via the Logical Volume Manager (LVM) application. This lab will also demonstrate how to manually mount (i.e. connect) and unmount (disconnect) partitions to file system directories, and demonstrate how to have partitions including adjusting the size of their automatically mounted to directories upon Linux systems if space is requiredsystem startup.
<u>Main Objectives</u>
*[http://www.cyberciti.biz/faq/howto-format-create-linux-filesystem/ mkfs]
*[http://man7.org/linux/man-pages/man5/fstab.5.html /etc/fstab]
*[http://v1code.corenominaltutsplus.orgcom/howtotutorials/scheduling-setuptasks-awith-crontabcron-file/ jobs--net-8800 Using crontab]
|}
</ol>
</li>
<li>Click on '''Logical View''' (i.e. above home, root, swap) and then click '''Create New Logical Volume''' button. What happens? Why do you think this happened?<br><br>We will now create another partition ('''/dev/vda3''') using the '''fdisk''' utility, format this newly-created partition so we can create another logical volume called '''archive'''.<br><br> </li>
<li>Quit the '''system-config-lvm''' application.</li>
<li>In the terminal as root, issue the command: <b><code><span style="color:#3366CC;font-size:1.2em;">ls /dev/vd*</span></code></b><br><br>'''NOTE:''' If nothing displays, issue the command: '''ls /dev/sd*''' and use that device pathname '''/dev/sda''' instead.<br><br>
<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 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 /etcdev/sda3'')</li>
</ol>
{| width="40%" align="right" cellpadding="10"
'''Answer Part 1 observations / questions in your lab log book.'''
 
===Part 2: Managing LVM Via Command Line & Adding Virtual Hard Drives===
<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 '''centos3''' 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>
# 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_centos2/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 - centos3), you could have issued the command (as root):<br> <ib><code><span style="color:#3366CC;font-size:1.2em;">echo "/dev/centos_centos2/archive /archive ext4 defaults 1 2" >> /etc/fstab</ispan></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!).
<br><br>
<ol>
<li value="5">Quickly view the tutorial about the <b>[http://v1code.corenominaltutsplus.orgcom/howtotutorials/scheduling-setuptasks-awith-crontabcron-file/ jobs--net-8800 Using crontab]</b> file to understand the purpose of this
file and how to basically set up a schedule to run a shell script.</li>
<li>Issue the following command to setup a crontab entry for root:<br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">crontab -e</span></code></b></li><li>Enter the following line in order to run at 6:00 on the first day of every month:<br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">0 6 1 * * /root/monitor-disk-space.bash #Runs first day of each month (6:00 am)</span></code></b></li><li>'''Save''' the crontab entry.</li><li>Confirm that the entry was properly saved by issuing the following command:<br><b><code><span style=" pointer-events:none;cursor:default;color:#3366CC;font-size:1.2em;">crontab -l</span></code></b></li></ol>

Navigation menu