Difference between revisions of "Lab 3 Warnings / Debrief"
(3 intermediate revisions by the same user not shown) | |||
Line 103: | Line 103: | ||
We will look at a couple methods of installing software: A traditional method ('''compiling source code''') and a more modern method ('''yum install''') | We will look at a couple methods of installing software: A traditional method ('''compiling source code''') and a more modern method ('''yum install''') | ||
− | <u>Install Method #1: Compiling Source Code</u> | + | |
+ | <u>'''Install Method #1: Compiling Source Code'''</u> | ||
This is the original way of installing software in Linux / Unix. | This is the original way of installing software in Linux / Unix. | ||
Line 119: | Line 120: | ||
'''Steps to Compile Source Code''': | '''Steps to Compile Source Code''': | ||
# Obtain compressed file containing source code (usually a "zipped tarball")<br>eg. '''wget [ URL of zipped tarball ]''' | # Obtain compressed file containing source code (usually a "zipped tarball")<br>eg. '''wget [ URL of zipped tarball ]''' | ||
− | |||
# Decompress zipped tarball. For example '''tar xzvf [ filename.tar.gz | filename.tgz ]'''<br> Note: You can compress (create archives) by using the tar command as well.<br>For example: '''tar czvf [ filename.tar.gz ] [ directories or files to archive ]''' | # Decompress zipped tarball. For example '''tar xzvf [ filename.tar.gz | filename.tgz ]'''<br> Note: You can compress (create archives) by using the tar command as well.<br>For example: '''tar czvf [ filename.tar.gz ] [ directories or files to archive ]''' | ||
# Change to directory containing source code. You may need to run a script called '''./config''' (if present) to check for some dependency issues. | # Change to directory containing source code. You may need to run a script called '''./config''' (if present) to check for some dependency issues. | ||
Line 127: | Line 127: | ||
− | <u>Install Method #2: Using the '''yum''' Utility</u> | + | <u>'''Install Method #2: Using the '''yum''' Utility'''</u> |
This is a newer and more preferred method of installing software by command-line on a Redhat / Centos / Fedora Linux distribution. The yum utility is a program which is a <u>'''wrapper'''</u> for the rpm command. A wrapper program simply means a program that uses another utility (in this case, the rpm command). We have used the rpm command to query or determine information regarding installed applications on our Linux systems. When your Linux operating systems were installed, the installation DVD or network media contained rpm files that were installed on the system. Rpm files are simply pre-compiled programs that make it easier to install applications for a Linux system. | This is a newer and more preferred method of installing software by command-line on a Redhat / Centos / Fedora Linux distribution. The yum utility is a program which is a <u>'''wrapper'''</u> for the rpm command. A wrapper program simply means a program that uses another utility (in this case, the rpm command). We have used the rpm command to query or determine information regarding installed applications on our Linux systems. When your Linux operating systems were installed, the installation DVD or network media contained rpm files that were installed on the system. Rpm files are simply pre-compiled programs that make it easier to install applications for a Linux system. | ||
Line 143: | Line 143: | ||
'''Steps to Install using yum Program''': | '''Steps to Install using yum Program''': | ||
− | # | + | # List available repositories that you are connected to using the command: '''yum repolist''' (you can use the yum install command to manually add repositories) |
+ | # To clean-up the repository list (including downloading new applications in added repositories), issue the command: '''yum clean all''' | ||
+ | |||
+ | # To install of remove applications, issue the commands as root: '''yum install packagename''' or '''yum remove packagename''' | ||
+ | # To install applications contained on local media (eg. installation DVD), issue the command: '''yum localinstall [ full_pathname_to_xchat_rpm_file ]''' | ||
+ | # To provide information regarding installed application, issue the command: '''yum info packagename''' or '''rpm -qi packagename''' | ||
+ | |||
Line 152: | Line 158: | ||
* '''FOLLOW THE INSTRUCTIONS CAREFULLY''' in terms of access safe mode, or changing root's password.<br><br> | * '''FOLLOW THE INSTRUCTIONS CAREFULLY''' in terms of access safe mode, or changing root's password.<br><br> | ||
* You need to be root in order to use '''yum''' utility! | * You need to be root in order to use '''yum''' utility! | ||
+ | * Remember to backup your VMs after you have completed lab3! Perhaps you can use that shell script to backup all VMs!<br><br> | ||
− | |||
− | |||
Latest revision as of 06:59, 13 October 2015
Contents
Preparing for Lab 3
Purpose of Lab3
In this lab, you are going to identify potential problems such as not properly compressing VM image files when backing up VMs, or forgetting your root password. You will also learn to conserve hard disk space by learning how to compress and decompress files that are stored on your computer server. In addition, you will learn alternative methods of how to install applications (i.e. programs).
Main Objectives
- Learn to troubleshoot some common problems after installing VMs
- Create and extract archive files (tar and tar.gz)
- Install applications using various methods:
- Download, decompress and archive file from the Internet, then compile source code in order to install an application.
- Use yum utility to install software from local source programs (on DVD drive)
- Use yum utility to install software from repositories (online storage areas)
- Learn how to add repositories (online software storage areas) to install less common applications.
- Demonstrate the use of Bash Shell scripts to automate routine tasks (generate a customized software report)
Rescuing Your System
There are a few "classic problems" that students can encounter with their virtual machines and their host machine after performing lab2. Although all OPS235 students may not encounter these problems, it is good to be aware of what a potential problem may look like, and know how to solve that problem.
A few common problems are:
- I Can't boot into Graphical Mode on my c7host machine
- I Forgot My Regular User Password
- I Forgot My root Password
- I Can't Start My Virtual Machine
- I Can't start my Host machine
Troubleshooting consists of 3 basic elements:
- Asking Questions (eg. what was done recently prior to problem?)
- Eliminating what the problem IS NOT
- Tenacity and patience (ability to focus on finding the cause of the problem)
If you cannot log graphically into your machine (first 3 common problems), there is a trick to boot your system into single-user mode. This mode does not provide networking, graphics, or logging in as other regular users, but can connect to a text-based interface as the root user. This method will only work if a GRUB (Grand Unified Boot-loader) password has not been set, or that you haven't forgotten the GRUB password.
Steps to Boot into "Single-User Mode":
- Boot-up your centos1 VM. when the Grub Boot menu appears, press the letter
e
(for "edit"). - Using your arrow keys, scroll to next screen to linux16 command and type the word
single
as an argument after quiet (see diagram for reference) and then pressctrl-x
to boot. - The system should boot into text-based mode. Enter your root password.
- One thing to look at is partition space usage. Issue the command:
df -h
- If you notice 0% free space in the / partition, then there is a problem. This most likely is caused by not following steps to create a compressed copy of the VM image. If that is the case, locate the large image backup and remove it. Do NOT remove the image in /var/lib/libvirt/images directory!
- You can use the passwd command to reset your regular user password (eg.
passwd regularuserid
). You can press ctrl-c if you wish to abort (i.e. not change password). - To restart in graphical mode, simply enter the command
reboot
.
- Unfortunately, this method does not work if you forgot your root password (To reset your root password, refer to procedure below).
Steps to Reset Root's Password:
- The procedure to reset root's password is different than shown above. Press
e
at the Grub boot menu. - Using your arrow keys, move to linux16 command and replace the argument ro with the argument
rw init=/sysroot/bin/sh
(see diagram for reference) and then pressctrl-x
to boot. - The system should boot into text-based mode without prompting for root's password.
- Issue the command:
chroot /sysroot
- Issue the command:
passwd root
in order to change your root password (press ctrl-c if you wish to abort - i.e. not change password). - To restart in graphical mode, simply enter the command
reboot
.
Catastrophic Boot Problems:
- Not being able to start your c7host due to Kernel Panic or some sort of catastrophic disk failure is not as easy to fix. You might be able to boot from your Centos LIVE DVD, open a terminal and mount the partition via command line and look for possible problems (setup files like /etc/fstab). Lab5 will discuss more about mounting and the /etc/fstab file. The "worst-case scenario" would be to purchase a new hard disk, perform lab1 completely, perform lab2 to install and set-up virtualization software, then restore your VM image and xml file backups (eg. decompressing images, issuing virsh define commands for .xml files). That is why consistently performing backups of ALL of your VMS at the end of each lab is absolutely essential! You have been warned!
Installing Application Software
There are many different methods and utilities for installing application software depending on the type of Linux distribution you have. For example:
- Debian-based Linux distros: apt-get, debi, gdebi, synaptic package manager, Ubuntu Software Center
- Redhat / Centos / Fedora distros: yum, rpm, gnome-packagekit
We will concentrate on the installing applications for the Centos Linux distribution, and focus on command-line application installation utilities (since centos3 VM is text-based only).
We will look at a couple methods of installing software: A traditional method (compiling source code) and a more modern method (yum install)
Install Method #1: Compiling Source Code
This is the original way of installing software in Linux / Unix.
Advantages:
- Although it seems "out-dated", it may be useful with installing very old or "leading edge" software that are not contained in repositories, and cannot be installed using the yum utility.
Limitations:
- Does not automatically resolve "dependency issues". This may require that you first install applications or development libraries before installing the software. This can be cumbersome.
- Cannot use rpm or yum utility to provide information database of installed software.
Steps to Compile Source Code:
- Obtain compressed file containing source code (usually a "zipped tarball")
eg. wget [ URL of zipped tarball ] - Decompress zipped tarball. For example tar xzvf [ filename.tar.gz | filename.tgz ]
Note: You can compress (create archives) by using the tar command as well.
For example: tar czvf [ filename.tar.gz ] [ directories or files to archive ] - Change to directory containing source code. You may need to run a script called ./config (if present) to check for some dependency issues.
- Usually good idea to check for installation instructions in a file called INSTALL and/or README
- Issue the command: make to compile. This will create an executable file in the source-code directory (usually as a file named after the application).
- As root, issue the command: make install to make command available to run from any directory. If the make install command does not work, you can copy the compiled program to /bin, /usr/bin, or /usr/local/bin.
Install Method #2: Using the yum Utility
This is a newer and more preferred method of installing software by command-line on a Redhat / Centos / Fedora Linux distribution. The yum utility is a program which is a wrapper for the rpm command. A wrapper program simply means a program that uses another utility (in this case, the rpm command). We have used the rpm command to query or determine information regarding installed applications on our Linux systems. When your Linux operating systems were installed, the installation DVD or network media contained rpm files that were installed on the system. Rpm files are simply pre-compiled programs that make it easier to install applications for a Linux system.
Advantages:
- yum program can install rpm files on a Linux repository (online Linux distribution database) or from local media
- yum program automatically determines "dependency issues", and has them installed first, then install the intended application
- yum program uses rpm utility which can provide rpm queries to determine install application information
Limitations:
- May not be used for installing very old or "leading edge" software that are not contained in repositories, and cannot be installed using the yum utility.
Steps to Install using yum Program:
- List available repositories that you are connected to using the command: yum repolist (you can use the yum install command to manually add repositories)
- To clean-up the repository list (including downloading new applications in added repositories), issue the command: yum clean all
- To install of remove applications, issue the commands as root: yum install packagename or yum remove packagename
- To install applications contained on local media (eg. installation DVD), issue the command: yum localinstall [ full_pathname_to_xchat_rpm_file ]
- To provide information regarding installed application, issue the command: yum info packagename or rpm -qi packagename
Common Mistakes / Warnings
- FOLLOW THE INSTRUCTIONS CAREFULLY in terms of access safe mode, or changing root's password.
- You need to be root in order to use yum utility!
- Remember to backup your VMs after you have completed lab3! Perhaps you can use that shell script to backup all VMs!
Preparing for Lab Sign-Off
In order to properly complete your lab and move to the next lab, you must have your instructor "sign-off" on your lab
- Each "signed-off" lab (before due date) is worth 1% of your final grade.
- Signing-off on labs help to spot errors that can cause problems with future labs.
- Do you ask the instructor what to check for! Read at the bottom of the lab the requirements, and have all proof available for instructor to view at same time.
- Failing to be prepared and asking instructor what to check when assignment is mark will result in deduct of marks!
- For example, open multiple terminals with command results. If properly set-up ahead of sign-off, the process should only take instructor approx 20 seconds to sign-off your lab.
- If you do not have your lab-logbook, you MUST show your work and your lab log-book to your instructor for sign-off in the next class. This may cause a late penalty if past the required due date.