Difference between revisions of "OPS235 Lab 3 - CentOS7"

From CDOT Wiki
Jump to: navigation, search
Line 1: Line 1:
 
[[Category:OPS235]]
 
[[Category:OPS235]]
  
=Logical Volume Management and Software Package Management=
+
= Software Package Management =
  
==Introduction==
+
== Investigation 1: How do you query the RPM database? ==
  
In this lab you're going to:
+
RPM maintains a database of installed software. This information is very useful to system administrators. In the previous lab you queried that database using RPM with the -q argument. When you query the RPM database, you can separately specify:
 +
:* Do an <u>operational task</u> on one or more packages (like installing or removing a package), using a '''select-option'''
 +
:* What <u>information</u> you want about those packages, using a '''query-option'''
  
:* Learn how to add and remove software packages on your different Linux systems.
+
'''Perform the following steps:'''
:* Learn how to properly adjust your various Linux file systems by using and managing LVM both graphically (centos2) as well as command line (centos3).
 
  
== Required Materials (Bring to All Labs) ==
+
(Perform investigations 1 - 3 in your host machine (c6host)
  
* CentOS 6.5 x86_64 Live DVD
+
# Using information from the man page for <code>rpm</code>, fill in this information:
* CentOS 6.5 x86_64 Installation DVD1
 
* SATA Hard Disk (in removable disk tray)
 
* USB Memory Stick
 
* Lab Logbook
 
  
==Prerequisites==
+
{|width="100%" border="1" cellpadding="5"
 
+
|-
* Completion and Instructor "Sign-off" of Lab 2: [[OPS235 Lab 2 - CentOS6]]
+
!Option
 
+
!Meaning
==Linux Command Online Reference==
+
!Select or query option?
Each Link below displays online manpages for each command (via [http://linuxmanpages.com/ http://linuxmanpages.com]):
+
!Example command
 
+
|-
{|width="100%" cellpadding="5"
+
| -a
|'''LVM Information Utilities:'''
+
|Select all packages
|'''LVM Management Utilities:'''
+
|select-option
|'''Additional Utilities:'''
+
|
|- valign="top"
+
|-
|
+
| -l
*[http://linuxmanpages.com/man8/vgs.8.php vgs]
+
|
*[http://linuxmanpages.com/man8/lvs.8.php lvs]
+
|
*[http://linuxmanpages.com/man8/pvs.8.php pvs]
+
|  
*[http://linuxmanpages.com/man8/vgdisplay.8.php vgdisplay]
+
|-
*[http://linuxmanpages.com/man8/lvdisplay.8.php lvdisplay]
+
| -i
*[http://linuxmanpages.com/man8/pvdisplay.8.php pvdisplay]
+
|Show the package information.
|
+
|
*[http://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-system-config-lvm.html system-config-lvm] (Tutorial)
+
|
*[http://linuxmanpages.com/man8/lvextend.8.php lvextend]
+
|-
*[http://linuxmanpages.com/man8/resize2fs.8.php resize2fs]
+
| -f filename
*[http://linuxmanpages.com/man8/lvcreate.8.php lvcreate]
+
|
*[http://linuxmanpages.com/man8/lvreduce.8.php lvreduce]
+
|
*[http://linuxmanpages.com/man8/pvcreate.8.php pvcreate]
+
|
*[http://linuxmanpages.com/man8/vgextend.8.php vgextend]
+
|-
|
+
|packagename
*[http://linuxmanpages.com/man8/mount.8.php mount]
+
|Select just this package
*[http://linuxmanpages.com/man8/umount.8.php umount]
+
|select-option
*[http://linuxmanpages.com/man8/yum.8.php yum]
+
|
*[http://linuxmanpages.com/man8/rpm.8.php rpm]
 
 
|}
 
|}
  
==Resources on the web==
+
'''Answer the Investigation 1 observations / table contents in your lab log book.'''
Additional links to tutorials and HOWTOs:
 
'''Please read this page to get an overview of LVM:'''<br /><br />
 
:* [[Logical Volume Management]] ('''Note:''' It is recommended to return to this guide as a reference when performing the next several investigations)
 
:* [http://fedoranews.org/alex/tutorial/rpm/ Using the RPM Utility]
 
:* [http://www.centos.org/docs/5/html/yum/ Using the YUM Utility]
 
 
 
 
 
 
 
=Logical Volume Management (Introduction)=
 
 
 
== Check Current LVM Information Prior to Performing Investigations ==
 
 
 
'''LVM''' ('''Logical Volume Management''') is used to manage hard disk drives / partitions for Unix/Linux systems. LVM provides more flexibility than just working with hard disks / hard disk partitions. '''Volume Groups''' are areas used to define '''Physical Volumes''' (i.e. hard disks, disk partitions, or other forms of storage devices). '''Logical Volumes''' are then used to relate directories (mount points) to a specific physical volume or for a "range" or "span" of physical volumes.
 
 
 
Therefore, LVM allows more flexibility and growth potential for Linux systems (for example, having Logical volumes span multiple hard disks). CentOS uses LVM by default upon installation. Other Linux distributions may provide the capacity to install LVM, or later install and then use Logical Volume Management.
 
 
 
'''Although the concept of LVM is simple, it takes practice and preparation (or "thinking ahead") in order to correctly use this valuable tool'''. It is important for students to gain an understanding of LVM, and how to manage their filesystems using LVM. It is recommended for students to read the following resource prior to this lab and/or return to the following resource while performing this lab: [[Logical Volume Management]]
 
 
 
At this point, having completed [[OPS235 Lab 2 - CentOS6|Lab 2]] you should have roughly the following disk storage setup:
 
 
 
('''Note:''' These results are output from the '''vgs''', '''pvs''', and '''lvs''' commands that provide volume group, physical volume and logical volume information for each of the virtual machines that you created in lab2. Before proceeding, check these values with your own system to see if you are generally "on the right track".)
 
 
 
* '''centos1'''
 
 
 
  VG        #PV #LV #SN Attr  VSize VFree
 
  vg_centos1  1  2  0 wz--n- 9.50g    0
 
 
 
  PV        VG        Fmt  Attr PSize PFree
 
  /dev/vda3  vg_centos1 lvm2 a--  9.50g    0
 
 
 
  LV      VG        Attr  LSize Origin Snap%  Move Log Copy%  Convert
 
  lv_root vg_centos1 -wi-ao 8.03g                                   
 
  lv_swap vg_centos1 -wi-ao 1.47g
 
 
 
* '''centos2'''
 
 
 
  VG        #PV #LV #SN Attr  VSize  VFree
 
  vg_centos2  1  3  0 wz--n- 19.51g 7.77g
 
 
 
  PV        VG        Fmt  Attr PSize  PFree
 
  /dev/vda2  vg_centos2 lvm2 a--  19.51g 7.77g
 
 
 
  LV      VG        Attr      LSize Pool Origin Data%  Move Log Cpy%Sync Convert
 
  lv_home vg_centos2 -wi-ao---- 1.95g                                           
 
  lv_root vg_centos2 -wi-ao---- 7.81g                                           
 
  lv_swap vg_centos2 -wi-ao---- 1.97g
 
 
 
* '''centos3  (Note:  This VM has no GUI installed)'''
 
 
  VG        #PV #LV #SN Attr  VSize VFree
 
  vg_centos3  1  3  0 wz--n- 14.51g 4.54g
 
 
 
  PV        VG        Fmt  Attr PSize PFree
 
  /dev/vda3  vg_centos3 lvm2 a--  14.51g 4.54g
 
 
 
  LV      VG        Attr  LSize  Origin Snap%  Move Log Copy%  Convert
 
  lv_home vg_centos3 -wi-ao----  1.00g                                           
 
  lv_root vg_centos3 -wi-ao----  8.00g                                           
 
  lv_swap vg_centos3 -wi-ao---- 992.00m                                   
 
 
* '''c6host (i.e. "removable hard disk" or "disk pack")'''
 
 
 
Does not use LVM. Confirm this using the same commands used above.
 
 
 
{{Admon/note|VM Backups and Recovery|Most of these investigations will take place in your virtual machines. If you make a significant mistake, your virtual machine may not boot. Remember that you created backups of your virtual machines in Lab 2, and you can restore them if something goes wrong.<br /><br />'''Remember: if you did not create backups for all of your VMs, then you don't have any restoration points to fall-back to!'''|}}
 
 
 
== Investigation 4: Extend the size of lv_root using command-line tools ==
 
 
 
Perform this investigation in centos3.
 
 
 
Let's say that you have run out of disk space on your computer (centos3), you need more space on the root filesystem, perhaps to host more webpages or a larger database or new software. What are your options? Getting a replacement harddrive would probably require reinstallation of the operating system and backup/restore of the data.
 
 
 
Because we're using LVM though - we can avoid that. We can add a new harddrive (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.
 
 
 
'''Perform the following operations to increase the size of lv_root in centos3:'''
 
  
<u>'''<font>Steps:</font>'''</u>
+
== Investigation 2: How do you install and remove software with RPM? ==
  
<ol>
+
# Use the graphical file manager (Nautilus) to change to the directory on your Installation DVD. Go to the sub-directory called '''Packages'''. It should contain a file called: <code>lynx-2.8.6-27.el6.x86_64.rpm</code>
<li>Run the following commands and make note of the output:</li>
+
# Execute the following command: <code>rpm -i lynx-2.8.6-27.el6.x86_64.rpm</code>
  <code>ls /dev/vd*
+
# Issue an RPM query to check that lynx is installed. Record this command in your lab log-book.
  pvs
+
# Issue the following command: <code>rpm -e lynx</code>
  vgs
+
# Issue an RPM query to verify that lynx is no longer installed. Record this command in your lab log-book.
  lvs
+
# Issue the following command: <code>rpm -i elinks-0.12.rpm</code>. Did it work? Explain in your lab log-book why this command may not have worked.
  df -h</code>
 
<li>Open the centos3 virtual machine console</li>
 
<li>Go to the hardware details view</li>
 
<li>Click "Add Hardware" and add a new storage device of 2GBs, make sure it's a VirtIO disk.</li>
 
<li>Go back to the console view</li>
 
<li>Run the same ls command (performed in step 1), what's changed?</li>
 
  <li>Now we'll make the new device as a physical volume, add it to the volume group, and extend lv_root:</li>
 
  <code>pvcreate /dev/vdb
 
  
  vgextend vg_centos3 /dev/vdb
+
'''Answer the Investigation 2 observations / questions in your lab log book.'''
  
  lvextend -L +2G -r vg_centos3/lv_root</code>
+
== Investigation 3: How do you install and remove software with ''yum''? ==
<li>Now rerun the ls/pvs/vgs/lvs/df commands. What has changed and what caused those changes?</li>
 
<li>Among the changes, note that your root filesystem is now 2GB bigger - and you have not even rebooted your machine!</li>
 
</ol>
 
  
'''Answer the Investigation 4 observations / questions in your lab log book.'''
+
{{Admon/note|Internet Connection|In order for yum to work you require a connection to the Internet. Establish this connection by using the browser to log into SeneNET}}
  
== Investigation 5: How is LVM managed using system-config-lvm? ==
+
# Change to your home directory.
  
'''Perform this investigation on the VM named ''<u>centos2</u>''.'''
 
[[Image:Ops235_lab4_1.png|thumb|right|Screenshot of system-config-lvm in CentOS. Click to enlarge.]]
 
# Let's learn to administer (manage) our LVM graphically for our '''centos2''' Virtual Machine.<br />CentOS provides a tool called <code>system-config-lvm</code> to graphically administer LVM. The package is not installed by default, so you will need to install it by issuing: (<code>yum install system-config-lvm</code>).
 
 
<ol>
 
<ol>
  <li value="2">Use this tool to determine the current LVM configuration by clicking on the appropriate element and reading the properties in the right-hand panel -- write down the answers:
+
  <li value="2">Issue the command:  <code>yum install elinks</code> and answer <code>y</code> to the question about installation.
  <ol type="a">
 
  <li>What are the names and sizes of the '''PV'''s?</li>
 
  <li>What is the name and size of the '''VG'''?</li>
 
  <li>What are the names and sizes of the '''LV'''s?</li>
 
  <li>Is there any space in the VG which is not allocated to a LV?</li>
 
</ol>
 
</li>
 
<li>Increase the size of the home file-system to '''4 GB''':
 
 
   <ol type="a">
 
   <ol type="a">
   <li>Click on the LV containing the '''home''' filesystem.</li>
+
   <li>Where did ''yum'' get the elinks software?</li>
  <li>Click on ''Edit Properties''.</li>
+
   <li>Why could ''yum'' install elinks when rpm couldn't?</li>
   <li>Change the size to '''4 GB''' and click ''Ok''.</li>
 
 
   </ol>
 
   </ol>
  <li>Create a '''new 3G LV''' (LV Properties: linear) containing an ext4 filesystem named lv_archive and mount it at '''/archive'''
+
</li>
  <li>Backup <code>'''/etc'''</code> into <code>'''/archive'''</code></li>
+
  <li>Issue an RPM query to verify that elinks is installed. Record this command in your lab log-book.</li>
 +
<li>Issue the command: <code>yum remove elinks</code></li>
 +
<li>Issue an RPM query to verify that elinks is no longer installed. Record this command in your lab log-book.</li>
 +
<li>Issue this command: <code>yum info cups</code></li>
 
</ol>
 
</ol>
::* Copy the files in /etc into the filesystem mounted at <code>/archive</code><br />(use the graphical tools or the command line. If using cp, remember to use the -R option).
+
::* Based on the result, do you think that cups is a useful package for your system? If not, try removing it.
 
<ol>
 
<ol>
  <li value="6">Shrink the size of <code>lv_archive</code> to '''1 GB'''.</li>
+
  <li value="8">Unused and unneeded software can present a security risk and ties up disk space needlessly. Find at least 4 other packages (for example: games, sound & video, etc) that you're not using on your system, and remove them. Be careful to ensure that removing those packages does not also remove other software that you do need.</li>
<li>Try shrinking the home file-system. What happens? Why?</li>
 
 
</ol>
 
</ol>
  
'''Answer the Investigation 5 observations / questions in your lab log book.'''
+
'''Answer the Investigation 3 observations / questions in your lab log book.'''
  
= Storage Setup (prior to starting Lab 4) =
+
==Archiving Files / Compiling Software from Source Code==
  
At this point, having completed [[OPS235 Lab 3 - CentOS6|Lab 3]] you should have <u>'''roughly'''</u> the following disk storage setup:<br />
+
Archive files are often used to contain source code for software; in this lab you will also be compiling software from a source code archive.
('''Note:''' These results are output from the '''vgs''', '''lvs''', and '''pvs''' commands within each virtual machine. You will be using these commands in the following lab investigations)<br /><br />
 
  
* '''centos1'''
+
{{Admon/note|Do not Shut-Down VMs Until Instructed|You will be running all 3 VMs eventually when performing this tutorial, Leave all VMs running until you are instructed to shut them down at the end of this lab.|}}
  
  This VM has a GUI and no free space in the VG.
+
===Investigation 1: How do you create an archive file?===
+
{{Admon/note|Use centos3|Perform these steps in the '''centos3''' virtual machine.}}
  VG        #PV #LV #SN Attr  VSize VFree
 
  vg_centos1  1   2  0 wz--n- 9.80G    0
 
 
  LV      VG        Attr  LSize 
 
  lv_root vg_centos1 -wi-ao  8.83G                                   
 
  lv_swap vg_centos1 -wi-ao 992.00M                                   
 
 
  PV        VG        Fmt  Attr PSize PFree
 
  /dev/vda2  vg_centos1 lvm2 a-  9.80G    0
 
  
* '''centos2'''
+
#Boot up your '''centos3''' VM.
 +
#Change your working directory to <code>/usr/share/doc/sudo*</code>
 +
#Use the tar (tape archiver) command to create an archive file named <code>/tmp/archive1.tar</code>
 +
#*<code>tar cvf /tmp/archive1.tar .</code>
  
  This VM has a GUI and free space in the VG.
+
{{Admon/important | Warning! | Don't miss the '''.''' at the end of the <code>tar</code> commands below! It specifies what should go into the archive: the contents of the current directory.}}
 
  VG        #PV #LV #SN Attr  VSize VFree
 
  vg_centos2  1  4  0 wz--n- 19.51g 4.73g
 
 
  LV      VG        Attr  LSize 
 
  lv_archive vg_centos2 -wi-ao---- 1.00g                                           
 
  lv_home    vg_centos2 -wi-ao---- 4.00g                                           
 
  lv_root    vg_centos2 -wi-ao---- 7.81g                                           
 
  lv_swap    vg_centos2 -wi-ao---- 1.97g                                 
 
 
  PV        VG        Fmt  Attr PSize PFree
 
  /dev/vda2  vg_centos2 lvm2 a--  19.51g 4.73g
 
  
* '''centos3'''
+
<ol>
 +
  <li value="4">What do the options c, v, and f mean?</li>
 +
  <li>Record the archive file size.</li>
 +
  <li>Compress the file using <code>gzip</code>:
 +
    <ul>
 +
      <li><code>gzip /tmp/archive1.tar</code></li>
 +
    </ul>
 +
  </li>
 +
  <li>Record the archive file size after compression.</li>
 +
  <li>Make sure you're still in <code>/usr/share/doc/sudo*</code> and then create a compressed archive:
 +
<ul>
 +
      <li><code>tar cvzf /tmp/archive2.tgz .</code></li>
 +
    </ul>
 +
  </li>
 +
  <li>What does the <code>z</code> option do?</li>
 +
  <li>Compare the sizes of <code>/tmp/archive1.tar.gz</code> and <code>/tmp/archive2.tgz</code>. Why are they so close in size?</li>
 +
</ol>
  
  This VM has no GUI installed.
+
'''Answer the Investigation 1 observations / questions in your lab log book.'''
 
  VG        #PV #LV #SN Attr  VSize VFree
 
  vg_centos3  2  3  0 wz--n- 16.50g    0
 
 
  LV      VG        Attr  LSize 
 
  lv_home vg_centos3 -wi-ao----  1.00g                                           
 
  lv_root vg_centos3 -wi-ao----  10.00g                                           
 
  lv_swap vg_centos3 -wi-ao---- 992.00m                                   
 
 
  PV        VG        Fmt  Attr PSize  PFree
 
  /dev/vda3  vg_centos3 lvm2 a--  14.51g 2.54g
 
  /dev/vdb  vg_centos3 lvm2 a--  2.00g 2.00g
 
  
* '''c6host (i.e. "disk pack")'''
+
===Investigation 2: How do you restore files from an archive?===
 +
{{Admon/note|Remain in your centos3 VM|Perform these steps in the '''centos3''' virtual machine.}}
 +
#Create the directory <code>/tmp/extract1</code>
 +
#Change to the <code>/tmp/extract1</code> directory.
 +
#Move the file archive1.tar.gz to your current directory.
 +
#Unzip the first archive you created:
 +
#*<code>gunzip archive1.tar.gz</code>
 +
#Extract the files from the first archive:
 +
#*<code>tar xvf archive1.tar</code>
 +
#Are all the files there?
 +
#Compare <code>/tmp/extract1/README</code> and <code>/usr/share/doc/sudo*/README</code>. Are they exactly the same? Why?
 +
#Create the directory <code>/tmp/extract2</code>
 +
#Move the file archive2.tgz to the <code>/tmp/extract2</code> directory.
 +
#Extract the files from the second archive:
 +
#*<code>tar xvzf /tmp/extract2/archive2.tgz</code>
 +
#Note that this time a separate <code>gunzip</code> command was not needed. Why?
 +
#Repeat the previous command, leaving out the option "z". Does it work? Why?
 +
#Compare the <code>README</code> file in this directory with the original file. Are they exactly the same?
  
  /dev/sdc3        20G  3.7G  15G  20% /
+
'''Answer the Investigation 2 observations / questions in your lab log book.'''
  /dev/sdc2        29G  4.7G  23G  18% /home
 
  /dev/sdc1        97G  48G  45G  52% /var/lib/libvirt/images
 
  
= Logical Volume Management (Continued) =
+
===Investigation 3: How do you build software from source code?===
  
{{Admon/note|Recovering VMs|'''Most of these investigations will take place in you virtual machines.''' If you make a significant mistake, your virtual machine may not boot. Remember that you created backups of your virtual machines in Lab 3, and you can '''restore them if something goes wrong'''.}}
+
Now that you know how to create and decompress "zipped tarball archives", we will demonstrate how to install applications from websites containing these types of archives. Although this method is not as "user-friendly" as using the yum or rpm command, this method is useful if the application is NOT contained in regular software repositories...
 +
{{Admon/note|Use centos2|Perform these steps in the '''centos2''' virtual machine.}}
  
== Resources ==
+
In order to build software from source code, you must have the appropriate software development tools (such as make and gcc) and libraries (such as GTK) installed. The required tools will vary depending on the computer languages used in the software being built.
  
Please read this page to get an overview of LVM:
+
# Issue the following command to install a basic set of development tools and libraries:<br /><code>yum groupinstall "Development Tools" "Development Libraries"</code>
[http://zenit.senecac.on.ca/wiki/index.php/Logical_Volume_Management Logical Volume Management]
 
  
It is recommended to open another window(eg. '''right-click''', '''open in new tab or window''') to make reference to view LVM commands as you perform investigations 1 to 3.
+
{{Admon/note|Installing Development Libraries|In the future, remember the above procedure whenever installing software from source. Sometimes, you need to install additional tools or libraries in order to compile a particular software package}}
  
== Investigation 1: How are LVMs are managed using Command-Line Tools  ==
+
<ol>
# You are going to repeat the same LVM management operations (as your did with the ''centos2'' VM in '''lab3'''), but you will using command-line tools in the '''centos3''' VM. Since the centos3 VM only operates in command-line mode, you will need to refer to the '''"Logical Volume Management"''' link above.
+
  <li value="3">Go to the directory <code>/tmp</code></li>
# Write down the exact commands used at each step, and record appropriate command output:
+
  <li>Use the <code>wget</code> command to download the "tar ball" that contains the source code for the NLED text editor. <code>wget</code> is a command-line tool to download files from the web using the http or ftp protocols.
:: a. Determine the current LVM configuration using the <code>pvs</code>, <code>vgs</code>, and <code>lvs</code> commands.
+
    <ul>
:: b.Grow the home filesystem to 2G using the command <code>lvextend</code> and <code>resize2fs</code>.
+
      <li><code>wget http://cdot.senecac.on.ca/software/nled/nled_2_52_src.tgz</code></li>
:: c.Create a new 2G LV containing an ext4 filesystem and mount it at /archive (use <code>mkdir</code>, <code>lvcreate</code>, <code>mkfs</code>, <code>mount</code>, edit the file <code>/etc/fstab</code> (read the resource: [https://wiki.archlinux.org/index.php/fstab https://wiki.archlinux.org/index.php/fstab] ), and then reboot to confirm automatic mount).
+
    </ul>
:: d.Copy the contents of <code>/etc</code> into <code>/archive</code>.
+
  </li>
:: e.Shrink <code>lv_archive</code> to 1G (use <code>umount</code>, <code>resize2fs</code>, <code>lvreduce</code>,  and <code>mount</code>)
+
  <li>Extract the files. Change to the newly-extracted directory (<code>/tmp/nled-2.52</code>)</li>
 
+
  <li>Check to see if there is a file named <code>configure</code>. If so, run it; if not, skip this step. (Most but not all source code archives contain this file)</li>
== Investigation 2: How can a PV be added to an existing VG using Command-Line Tools? ==
+
  <li>Check to see if there is a file named <code>Makefile</code> or <code>makefile</code>. If so, type the command:
# Add an additional 2 GB virtual disk to your ''<u>centos1</u>'' system, we will use it as an additional physical volume.
+
    <ul>
# Do the rest of this investigation in the command line.
+
      <li><code>make</code></li>
# You should now have both <code>/dev/vda</code> and <code>/dev/vdb</code>.
+
      <li>Did the command work? Why? Use the <code>yum</code> command to install the package '''gcc'''. What do you think the package ''gcc'' does?</li>
# Record the size of the volume group and the amount of free space (Hint: use a command that you learned in a previous lab).
+
    </ul>
# Read the resource [http://tldp.org/HOWTO/Partition/fdisk_partitioning.html Partitioning with fdisk] to learn how to properly create a partition with the fdisk command.
+
  <li>Reissue the <code>make</code> command. Where you successful? What does <code>make</code> do?</li>
# Use fdisk to partition /dev/vdb with a Linux single partition that fills the whole disk.
+
  <li>Issue the command as root: <code>yum list ncurses</code>. What do you see? Issue the command at root: <code>yum search ncurses</code>. What do you observe?</li>
# Check the messages printed when <code>fdisk</code> exits -- you may need to reboot the system in order for the new partition table to take effect.
+
  <li>In this case, you need to install the ncurses development libraries as well. Issue the following command as root: <code>yum install ncurses-devel.x86_64</code>. Now issue the command: <code>make</code></li>
# Mark ''vdb1'' as a physical volume usable by LVM.
+
  <li>Some software distributed as source code can automatically install itself. Try this command:
# Add the new physical volume to the existing volume group.
+
    <ul>
# Verify that the volume group is larger and has more free space.
+
      <li><code>make install</code></li>
 
+
    </ul>
{{Admon/note|Think!|The next part of this investigation requires some research, thought, and creativity.}}
+
  </li>
'''Using that additional space, create a separate filesystem for <code>/home</code>:'''
+
  <li>Most but not all source code archives include the capability of installing themselves this way.</li>
# Create the logical volume <code>lv_home</code> (1G ext4)
+
  <li>If the command <code>make install</code> does not work (how can you tell? What command did you learn from ULI101 to confirm that this command cannot be run from the command line?), copy the <code>nled</code> program manually:
# Find a way to move the contents of <code>/home</code> onto it.
+
    <ul>
# Change your system configuration so that the new filesystem is mounted on <code>/home</code> from now on.
+
      <li><code>cp nled /usr/local/bin</code></li>
 +
    </ul>
 +
  </li>
 +
  <li>Test <code>nled</code> to make sure it works.</li>
 +
  <li>Why did copying the nled executable to /usr/local/bin allow the nled command to be run by name anywhere in the command prompt?</li>
 +
</ol>
  
{{Admon/tip|SELinux relabelling may be required|Your system may report that the files are not present in the new /home filesystem when they are clearly there. This is due to the Security-Enhanced Linux system (SELinux) preventing access to the files, because the files were tampered with (moved) and are no longer recognized as home directory content. You can fix this problem by restoring the file context labels so that SELinux accepts the files as valid home directory content: <code>restorecon -r /home</code>}}
+
'''Answer the Investigation 3 observations / questions in your lab log book.'''
  
== Investigation 3: How can I use fdisk to manage storage on my disk pack? ==
 
'''On your <u>c6host</u> (i.e. "disk pack"), using your choice of the GUI and/or command-line tools:'''
 
# Create a new partition or logical drive ('''NOT a logical volume!''') - minimum 5G, leaving at least 10G free space in the extended partition.
 
# Format that partition (i.e. put a filesystem on it).
 
# Make sure it's mounted automatically on a mountpoint of your choosing (easiest is to create a new directory for a mountpoint).
 
  
= Updated backup instructions =
 
  
If you completed this lab correctly - please make sure you are still making full backups of your virtual machines.
 
  
Remember adding a new harddrive to centos3? You will need to back up that drive as well. If you don't - you will only have half of your machine backed up, which is of no use for a recovery.
 
  
 
= Completing the lab =
 
= Completing the lab =

Revision as of 07:31, 28 March 2015


Software Package Management

Investigation 1: How do you query the RPM database?

RPM maintains a database of installed software. This information is very useful to system administrators. In the previous lab you queried that database using RPM with the -q argument. When you query the RPM database, you can separately specify:

  • Do an operational task on one or more packages (like installing or removing a package), using a select-option
  • What information you want about those packages, using a query-option

Perform the following steps:

(Perform investigations 1 - 3 in your host machine (c6host)

  1. Using information from the man page for rpm, fill in this information:
Option Meaning Select or query option? Example command
-a Select all packages select-option
-l
-i Show the package information.
-f filename
packagename Select just this package select-option

Answer the Investigation 1 observations / table contents in your lab log book.

Investigation 2: How do you install and remove software with RPM?

  1. Use the graphical file manager (Nautilus) to change to the directory on your Installation DVD. Go to the sub-directory called Packages. It should contain a file called: lynx-2.8.6-27.el6.x86_64.rpm
  2. Execute the following command: rpm -i lynx-2.8.6-27.el6.x86_64.rpm
  3. Issue an RPM query to check that lynx is installed. Record this command in your lab log-book.
  4. Issue the following command: rpm -e lynx
  5. Issue an RPM query to verify that lynx is no longer installed. Record this command in your lab log-book.
  6. Issue the following command: rpm -i elinks-0.12.rpm. Did it work? Explain in your lab log-book why this command may not have worked.

Answer the Investigation 2 observations / questions in your lab log book.

Investigation 3: How do you install and remove software with yum?

Note.png
Internet Connection
In order for yum to work you require a connection to the Internet. Establish this connection by using the browser to log into SeneNET
  1. Change to your home directory.
  1. Issue the command: yum install elinks and answer y to the question about installation.
    1. Where did yum get the elinks software?
    2. Why could yum install elinks when rpm couldn't?
  2. Issue an RPM query to verify that elinks is installed. Record this command in your lab log-book.
  3. Issue the command: yum remove elinks
  4. Issue an RPM query to verify that elinks is no longer installed. Record this command in your lab log-book.
  5. Issue this command: yum info cups
  • Based on the result, do you think that cups is a useful package for your system? If not, try removing it.
  1. Unused and unneeded software can present a security risk and ties up disk space needlessly. Find at least 4 other packages (for example: games, sound & video, etc) that you're not using on your system, and remove them. Be careful to ensure that removing those packages does not also remove other software that you do need.

Answer the Investigation 3 observations / questions in your lab log book.

Archiving Files / Compiling Software from Source Code

Archive files are often used to contain source code for software; in this lab you will also be compiling software from a source code archive.

Note.png
Do not Shut-Down VMs Until Instructed
You will be running all 3 VMs eventually when performing this tutorial, Leave all VMs running until you are instructed to shut them down at the end of this lab.

Investigation 1: How do you create an archive file?

Note.png
Use centos3
Perform these steps in the centos3 virtual machine.
  1. Boot up your centos3 VM.
  2. Change your working directory to /usr/share/doc/sudo*
  3. Use the tar (tape archiver) command to create an archive file named /tmp/archive1.tar
    • tar cvf /tmp/archive1.tar .
Important.png
Warning!
Don't miss the . at the end of the tar commands below! It specifies what should go into the archive: the contents of the current directory.
  1. What do the options c, v, and f mean?
  2. Record the archive file size.
  3. Compress the file using gzip:
    • gzip /tmp/archive1.tar
  4. Record the archive file size after compression.
  5. Make sure you're still in /usr/share/doc/sudo* and then create a compressed archive:
    • tar cvzf /tmp/archive2.tgz .
  6. What does the z option do?
  7. Compare the sizes of /tmp/archive1.tar.gz and /tmp/archive2.tgz. Why are they so close in size?

Answer the Investigation 1 observations / questions in your lab log book.

Investigation 2: How do you restore files from an archive?

Note.png
Remain in your centos3 VM
Perform these steps in the centos3 virtual machine.
  1. Create the directory /tmp/extract1
  2. Change to the /tmp/extract1 directory.
  3. Move the file archive1.tar.gz to your current directory.
  4. Unzip the first archive you created:
    • gunzip archive1.tar.gz
  5. Extract the files from the first archive:
    • tar xvf archive1.tar
  6. Are all the files there?
  7. Compare /tmp/extract1/README and /usr/share/doc/sudo*/README. Are they exactly the same? Why?
  8. Create the directory /tmp/extract2
  9. Move the file archive2.tgz to the /tmp/extract2 directory.
  10. Extract the files from the second archive:
    • tar xvzf /tmp/extract2/archive2.tgz
  11. Note that this time a separate gunzip command was not needed. Why?
  12. Repeat the previous command, leaving out the option "z". Does it work? Why?
  13. Compare the README file in this directory with the original file. Are they exactly the same?

Answer the Investigation 2 observations / questions in your lab log book.

Investigation 3: How do you build software from source code?

Now that you know how to create and decompress "zipped tarball archives", we will demonstrate how to install applications from websites containing these types of archives. Although this method is not as "user-friendly" as using the yum or rpm command, this method is useful if the application is NOT contained in regular software repositories...

Note.png
Use centos2
Perform these steps in the centos2 virtual machine.

In order to build software from source code, you must have the appropriate software development tools (such as make and gcc) and libraries (such as GTK) installed. The required tools will vary depending on the computer languages used in the software being built.

  1. Issue the following command to install a basic set of development tools and libraries:
    yum groupinstall "Development Tools" "Development Libraries"
Note.png
Installing Development Libraries
In the future, remember the above procedure whenever installing software from source. Sometimes, you need to install additional tools or libraries in order to compile a particular software package
  1. Go to the directory /tmp
  2. Use the wget command to download the "tar ball" that contains the source code for the NLED text editor. wget is a command-line tool to download files from the web using the http or ftp protocols.
  3. Extract the files. Change to the newly-extracted directory (/tmp/nled-2.52)
  4. Check to see if there is a file named configure. If so, run it; if not, skip this step. (Most but not all source code archives contain this file)
  5. Check to see if there is a file named Makefile or makefile. If so, type the command:
    • make
    • Did the command work? Why? Use the yum command to install the package gcc. What do you think the package gcc does?
  6. Reissue the make command. Where you successful? What does make do?
  7. Issue the command as root: yum list ncurses. What do you see? Issue the command at root: yum search ncurses. What do you observe?
  8. In this case, you need to install the ncurses development libraries as well. Issue the following command as root: yum install ncurses-devel.x86_64. Now issue the command: make
  9. Some software distributed as source code can automatically install itself. Try this command:
    • make install
  10. Most but not all source code archives include the capability of installing themselves this way.
  11. If the command make install does not work (how can you tell? What command did you learn from ULI101 to confirm that this command cannot be run from the command line?), copy the nled program manually:
    • cp nled /usr/local/bin
  12. Test nled to make sure it works.
  13. Why did copying the nled executable to /usr/local/bin allow the nled command to be run by name anywhere in the command prompt?

Answer the Investigation 3 observations / questions in your lab log book.



Completing the lab

Important.png
Time for a new backup!
If you have successfully completed this lab, make a new backup of your virtual machines.

Notes:

  1. rpm command options
  2. yum command options
  3. How to use pvs/vgs/lvs/df/pvcreate/vgextend/lvextend
  4. Answer to this question "What is the license of the nautilus package?"

Arrange evidence for each of these items on your screen, then ask your instructor to review them and sign off on the lab's completion:

  1. elinks application removed on the host (disk pack - main system c6host).
  2. Unnecessary/unused packages have been deleted (list at least 4, and show that they are no longer installed).
  3. Fresh backup of the virtual machines.

Preparing for Quizzes

  1. What is a VG? PV? LV?
  2. What commands are used to determine VG / PV / LV information?
  3. What does yum do that rpm does not?
  4. List the steps to install a package via rpm command.
  5. List the steps to determine detailed information regarding an install package.
  6. List the steps to remove a package via rpm command.
  7. List the steps to install a package using the yum command.
  8. List the steps to remove a package using the yum command.
  9. What is the total size of the "main" VG on your system?
  10. How do you create a LV?
  11. How do you delete an LV?
  12. How would you increase the size of the root filesystem by 50 MB?