Due Date and Deliverables ========================= <a name="Due_Date"></a> > **Do not print this assignment on paper!** > > - On paper, you will miss updates, corrections, and hints added to > the online version. > - On paper, you cannot follow any of the hyperlink URLs that lead you > to hints and course notes relevant to answering a question. * **Due Date**: - You should complete your peer review by September 29th, 2017. * **Available online** - Version 1.0 -- 22h00 September 14, 2017 - Version 1.1 -- 11h00 September 19, 2017 - You can use `sudo` to accomplish the tenth script task. - Version 1.2 -- 14h00 September 20, 2017 - Whoops, no you can't. Updated the script requirements to remove `blkid` and `sudo` requirements. - Version 1.21 -- 09h30 September 21, 2017 - Updated script sample output - Version 1.22 -- 14h00 September 22, 2017 - Updated script sample output * **Prerequisites** - [CST8207 GNU/Linux Operating Systems I] - BYOD device - VMware Workstation 12.5 or higher - Read Chapters 2, 3 and 4 in the course textbook - Laboratory notebook - All class notes since the beginning of term. * **Deliverables** 1. Complete your lab book as described in the assignment. * **Evaluation** - Lab books are assessed by your peers. Later in the semester the professor will undertake a more thorough review of each laboratory notebook. 20% of your final grade is based on the results of the professor review of your laboratory notebook. Purpose of this Assignment ========================== 1. Install Linux 2. Learn to use partitioning tools, LVM and RAID. 3. Learn to manage filesystems. Introduction and Overview ========================= This assignment will be completed on your laptop. You will install CentOS 7 64-bit on a VMware virtual machine. After installing CentOS, you will run specific commands at the command line, and evaluate the results in order to answer the questions at the end of this assignment. Chapters 2, 3 and 4 from the textbook, "A Practical Guide to Fedora and Red Hat Enterprise Linux" (7th edition) by Mark G. Sobell, can be used as a guide to how to install and use CentOS 7. Much of the necessary technical information required to complete this assignment is explained there. <a name="requirements"></a> Requirements ------------ This assignment was written for VMware Workstation 12. VMware is available through the "Digital Downloads" link in Blackboard. You will also need a copy of the 64-bit installation DVD for CentOS 7. Obtaining your CentOS 7 64-bit DVD ------------------------------------------- The CentOS 7 64-bit DVD ISO image is distributed by the [CentOS](https://www.centos.org/) website. If you are not at the College, you can download the 64-bit DVD using [BitTorrent](http://isoredirect.centos.org/centos/7/isos/x86_64/) It is also possible to download the [ISO file](http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-DVD-1611.iso). It is also available for download on campus from http://cstech If you find that the ISO you obtain from http://cstech is corrupt, you could try obtaining one from someone else who has already installed successfully. Alternatively, you can download the ISO from the [CentOS](https://www.centos.org/) website. You should [verify the ISO file you download](#Verify_the_Downloaded_ISO). Creating the Virtual Machine ============================ Launch VMWare Workstation 12. When you create your virtual machine, leave all settings at the default unless otherwise specified below. 1. Click *Create a New Virtual Machine*, or click *File* and then click *New Virtual Machine...*. 2. Select *Custom(advanced)*. 3. Make sure that *Virtual machine hardware compatibility* is set to **Workstation 12.0**. 4. Select *I will install the operating system later.* 5. Set the *Guest operating system* and *Version* appropriately. 6. Name your virtual machine "*username* CentOS 7 Linux II", where *username* is your assigned Algonquin College network user name. Change the *Location* parameter if you need to. Click *Next*. 7. Allocate one processor and **two** cores to the virtual machine. This will improve performance. If you have a quad-core processor, you can allocate as many as four cores to the virtual machine. 7. Allocate **2048** of memory to the virtual machine. You can increase the amount of memory you allocate to improve performance, but it will make snapshots slower and larger. Click *Next*. 8. On the *Network Type* screen, select **Use host-only networking**. 10. Use the default settings for all the remaining options. When you reach the "Ready to Create Virtual Machine" dialogue window, click the "Customize Hardware" button. Configuring the virtual optical drive ------------------------------------- From the "Hardware" dialogue box, select *New CD/DVD (IDE)*. In the right half of the dialogue box, select the `Use ISO image file` radio button. Click the `Browse...` button and locate the CentOS 7 64-bit DVD .iso file you downloaded earlier -- see [Requirements](#requirements) . Click the `Close` and then `Finish` buttons. Click `Finish`. Adding hard drives ------------------- We want to use both LVM and RAID for this assignment. We will be using an array of four virtual hard drives to complete this assignment. Click the `Edit virtual machine settings` button. Start by clicking the `Add...`. button in the *Virtual Machine Settings* dialogue box, and use the default settings. Ensure that the disk files are stored in the same directory as your `.vmx` file. After you have added a second hard drive, add two more SCSI drives for a total of four SCSI hard drives. Installing Linux ================ Power the virtual machine on by clicking the `Power on this virtual machine` button. Once the system boots, select the `Test this media & install CentOS 7` option. <!-- - - - - - - - - - - - - - - - - - - - - - The CentOS 7 installer appears to have a bug which causes the screen resolution to be too small. This is a particular problem when setting up a complex partitioning scheme like the one we are using. To get around the bug by forcing the installer to use a higher resolution, follow these instructions: 1. Select the `Test this media & install CentOS 7` option, and press the `Tab` key. 2. You are now viewing the list of kernel directives that will be passed to the Linux kernel at boot. 2. Add a space and then the exact string `vga=791` to the end of the line. You have added a new kernel directive! 3. Press `Enter` to boot from the DVD and launch the installer. - - - - - - - - - - - - - - - - - - - - - --> Your work will be evaluated according to the system requirements below. Make sure you use refer to these requirements while you configure the CentOS installer, which is named Anaconda. System Requirements ------------------- - - - - - - - - - - - - - - - - - - - - - - If you make an error when creating the partitioning scheme, the only way to recover is to start this assignment again. - - - - - - - - - - - - - - - - - - - - - - The virtual machine you will create will have the following properties: 1. Uses hardware defaults for a virtual machine created in VMware Workstation 12, except as specified in the section [Creating the Virtual Machine](#creating-the-virtual-machine). 2. Contains an installation of CentOS 7 64-bit. While installing CentOS 7, ensure that you have checked the following settings: 3. The `Language Support` install setting on the 'Installation Summary' screen is set to *English (United States)*. 4. The `Date & Time` install setting on the 'Installation Summary' screen is set to *America/New_York timezone*. 4. The `Software Selection` install setting on the 'Installation Summary' screen is set to *GNOME Desktop*. Your installation will use the following partitioning scheme: - `swap` Use a size of 4096 MiB. Configure this swap area as a RAID 0 array. - `/boot` Use a size of 1024 MiB. Configure it as a RAID 1 array. Use the `ext2` filesystem. - `/` Use a size of 20 GiB. Leave it configured as a logical volume. Use the `xfs` filesystem. - `/var` Use a size of 8192 MiB. Configure it as a standard partition, _not as a logical volume._ Use the `ext3` filesystem. - `/var/log` Use a size of 2046 MiB. Configure it as a RAID 5 array. Use the `ext3` filesystem. - `/home` Use a size of 15 GiB. Configure this as a logical volume. Use the `ext4` filesystem. Use an LVM group for all logical volumes, except for `swap`, `/boot` and, `/var`, and `/var/log` The LVM group should **not use RAID**. It is not necessary to run LVM on top of RAID for this lab. - - - - - - - - - - - - - - - - - - - - - - If you find you cannot set the size of the `swap` RAID 0 array correctly, try setting the size to 4094 MiB. The size may change to 4096 MiB. - - - - - - - - - - - - - - - - - - - - - - Accounts and Passwords ---------------------- Use strong passwords. **Don't forget your password.** Write down the first three letters of your password on a blank page of your laboratory notebook, followed by `x`es. This prompt will help you remember your password if you forget it. Using password management software such as LastPass or KeePass is recommended. Create a user with your name and College userid. Do not make this user an admin. Once you have set up Linux, try rebooting the virtual machine. - - - - - - - - - - - - - - - - - - - - - - You may receive a prompt which includes the text, "License not accepted". You may have to perform some or all of the following steps: 1. Press "1" to view the license. You may have to do this more than once. 2. Press "2" to accept the license. An "x" should appear to the left of this option once you've accepted it. 3. Press "c" to continue. You may have to do this more than once. - - - - - - - - - - - - - - - - - - - - - - After your virtual machine boots successfully, you should log in, open a terminal window using the GUI menu, and shut down the virtual machine using the `shutdown` command. You may want to boot it again, and then shut it down again, just to make certain it can start and stop successfully. Once you have shut down the VM, **take a snapshot** in VMware, and give your snapshot the name `clean`. *Note that I said **snapshot**, not screenshot.* In the future, you can take snapshots while the virtual machine is running, or while it is shut down. Snapshots taken while the VM is shut down will take much less time, and be much smaller. - - - - - - - - - - - - - - - - - - - - - - - Internet Connectivity ------------------------- **Do not connect your VM to the Internet.** This will cause the /var partition to fill up with updates. Mounted Drives -------------- Try logging in and opening a terminal window using the GUI. **Maximize the size of the terminal window.** First, try typing the `mount` command and examine the output. Can you see the different partitions you configured earlier in the installation? You will also see many virtual filesystems as well that do not correspond to any physical drive. Use a command to confirm that your filesystems have the correct sizes, devices and mountpoints. The output should contain the following lines: /dev/mapper/cl-root 20G 3.3G 17G 17% / /dev/sda6 7.8G 104M 7.3G 2% /var /dev/md126 1008M 135M 344M 29% /boot /dev/md125 2.0G 8.2M 1.9G 1% /var/log /dev/mapper/cl-home 15G 45M 14G 1% /home You can use the `swapon` command to check the swap area. The output should look like this: NAME TYPE SIZE USED PRIO /dev/md127 partition 4G 0B -1 Scripting ========= This assignment requires you to write a script. Properties of this script ------------------------- 4. When you have completed this script, ensure that it is executable, so that it can be executed as `./sysinfo.sh` from the shell command line. 5. Sample output for the script is given, so that you may check your work as you proceed. 6. This script does not require any user input. <!-- 8. Remember to [double quote all variable expansions](http://teaching.idallen.com/cst8207/17w/notes/440_quotes.html#double-quote-all-variable-expansions) to prevent syntax errors and other unwanted problems in your script. --> System Information Script ------------------------- Write a short script which performs the following tasks, in order: 0. Displays your name and student number 1. Displays the current date and time. 2. Displays the name of the account the script is running as. 3. Displays the number of CPU cores. 4. Displays the total amount of RAM in GB. **Hint:** You can use the utility `free` to do this. 2. Displays the absolute pathnames to any hard drives which start with the letters `sd`. 3. Display the current RAID configuration. 5. Display information about any configured swap areas. 4. Display only the header from the output of the `df` command. Then display only lines from `df` that represent physical storage in the `Filesystem` column. Use a human-readable format. 6. Display only lines from `mount` that refer to device files by pathname. Your script should be run using a normal user account. Don't use the `root` user to run your script. Below is sample output that a script like yours might produce. The values in your output may vary, but the format should not. ```` System Summary ============== Written by: Rob Brandon 0123456789 Generated on: Fri Jan 20 10:52:10 EST 2017 Generated by: brandor CPU cores: 2 Total RAM: 1.8G Found drives ------------ /dev/sda /dev/sdb /dev/sdc /dev/sdd RAID Configuration ------------------ md125 : active raid5 sdd3[4] sdc3[2] sdb3[1] sda3[0] md126 : active raid0 sdd1[3] sdb1[1] sda1[0] sdc1[2] md127 : active raid1 sdd2[3] sdb2[1] sdc2[2] sda2[0] Swap areas ---------- NAME TYPE SIZE USED PRIO /dev/md126 partition 4G 0B -1 Disk usage ---------- Filesystem Size Used Avail Use% Mounted on /dev/mapper/cl-root 20G 4.2G 16G 21% / /dev/sda6 7.8G 1.2G 6.3G 16% /var /dev/md126 1008M 136M 821M 15% /boot /dev/mapper/cl-home 15G 94M 14G 1% /home /dev/md125 2.0G 11M 1.8G 1% /var/log Filesystems ----------- /dev/mapper/cl-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota) /dev/sda6 on /var type ext3 (rw,relatime,seclabel,data=ordered) /dev/md127 on /boot type ext2 (rw,relatime,seclabel) /dev/mapper/cl-home on /home type ext4 (rw,relatime,seclabel,data=ordered) /dev/md125 on /var/log type ext3 (rw,relatime,seclabel,stripe=384,data=ordered) ```` Peer Assessment of Laboratory Notebook ====================================== Find a partner who has also finished the first three assignments. Swap laboratory notebooks. Each of you should write your initials in the top-right corner of each of the following pages in your partner's laboratory notebook: * / <!-- 104.7 --> * /dev/* <!-- 101.1 --> * /etc/fstab <!-- 203.1 --> * /proc/* * /usr/bin/* * /usr/bin/mount * /usr/bin/umount * /usr/sbin/* <!-- 203.1 --> <!-- 203.2 --> * /usr/sbin/fdisk <!-- 104.1 --> * /usr/sbin/mkfs Evaluate the script written by your partner according to the ten tasks listed under "System Information Script" in this assignment. Each task is worth one mark. Ask your partner to run their script, and examine the results. Take a look at the source code of your partner's script. Give your partner a grade out of ten for their script. Your partner should be given as many opportunities as they like to rewrite their script in order to get a better grade (within reason). Once your partner has achieved 10/10 for their script, they should record it in their notebook under the title `/home/user/sysinfo.sh` where `user` should be replaced by your partner's username. You should write "10/10" (or the grade you and your partner have agreed on) in the top right corner of the first page of the script in your partner's notebook, and write your initials next to the grade. If you cannot agree on a grade, consult with your lab professor. <!-- References --> [CST8207 GNU/Linux Operating Systems I]: http://teaching.idallen.com/cst8207/17w/ [Remote Login]: http://teaching.idallen.com/cst8207/17w/notes/110_remote_login.html [Course Linux Server]: http://teaching.idallen.com/cst8207/17w/notes/070_course_linux_server.html [Course Linux Server Course Notes]: http://teaching.idallen.com/cst8207/17w/notes/070_course_linux_server.html#copies-of-the-cst8207-course-notes [File Transfer]: http://teaching.idallen.com/cst8207/17w/notes/015_file_transfer.html [Shell I/O Redirection]: http://teaching.idallen.com/cst8207/17w/notes/200_redirection.html [Startup Files]: http://teaching.idallen.com/cst8207/17w/notes/350_startup_files.html [Search Path]: http://teaching.idallen.com/cst8207/17w/notes/400_search_path.html [hard link]: http://teaching.idallen.com/cst8207/17w/notes/455_links_and_inodes.html [Symbolic Link]: http://teaching.idallen.com/cst8207/17w/notes/460_symbolic_links.html [Data Mining]: http://teaching.idallen.com/cst8207/17w/notes/805_data_mining.html [Examples of Pipes]: http://teaching.idallen.com/cst8207/17w/notes/200_redirection.html#examples-of-pipes [shell history]: http://teaching.idallen.com/cst8207/17w/notes/worksheet03.html [Reading eMail]: http://teaching.idallen.com/cst8207/17w/notes/630_crontab_at_job_scheduler.html#reading-email-from-cron-and-at-jobs [Quoting]: http://teaching.idallen.com/cst8207/17w/notes/440_quotes.html [System Log Files]: http://teaching.idallen.com/cst8207/17w/notes/580_system_log_files.html [Finding Files]: http://teaching.idallen.com/cst8207/17w/notes/180_finding_files.html [Subshells]: http://teaching.idallen.com/cst8207/17w/notes/145_subshells.mp4 [Shell Variables]: http://teaching.idallen.com/cst8207/17w/notes/320_shell_variables.html [Links and Inodes]: http://teaching.idallen.com/cst8207/17w/notes/455_links_and_inodes.html [Permissions]: http://teaching.idallen.com/cst8207/14f/notes/500_permissions.html [Processes and Jobs]: http://teaching.idallen.com/cst8207/14f/notes/600_processes_and_jobs.html [Command List]: http://teaching.idallen.com/cst8207/14f/notes/900_unix_command_list.html [Regex Anchor]: http://teaching.idallen.com/cst8207/17w/notes/800_regular_expressions.html#regular-expressions-match-anywhere-in-a-line-anchoring-with-and <!-- Internal links --> [Due Date and Deliverables]:(#due-date-and-deliverables) [Purpose of this Assignment]:(#purpose-of-this-assignment) [Introduction and Overview]:(#introduction-and-overview) [Requirements]:(#requirements) [Obtaining your CentOS 7 64-bit DVD ]:(#obtaining-your-centos-7-64-bit-dvd) [Creating the Virtual Machine]:(#creating-the-virtual-machine) [Configuring the virtual optical drive]:(#configuring-the-virtual-optical-drive) [Adding hard drives]:(#adding-hard-drives) [Installing Linux]:(#installing-linux) [System Requirements]:(#system-requirements) [Accounts and Passwords]:(#accounts-and-passwords) [Internet Connectivity]:(#internet-connectivity) [Mounted Drives]:(#mounted-drives) [Instructor Sign-off]:(#instructor-sign-off) [Questions]:(#questions) [Answer File]:(#answer-file) [Assignment Questions]:(#assignment-questions) [Troubleshooting]:(#troubleshooting) <a name="troubleshooting"></a> Troubleshooting =============== <a name="Verify_the_Downloaded_ISO"></a> Verify the Downloaded ISO ------------------------- When you run through the install process, the DVD image is verified for you. To verify the downloaded CentOS ISO manually, you must check the checksum of the ISO file you have downloaded. 1. Verify that you have the exact ISO file named `CentOS-7-x86_64-DVD-1611` that is `4,277,248` KB (`4.07GB`). 2. To verify the download, you will need some form of checksum program that runs on your local computer that can calculate **sha256** hashes. Unix and Linux machines may have the `sha256sum` command available (the equivalent on OSX is `shasum -a 256`); you don't need to download anything; read the `man` page or just run `sha256sum` (or `shasum -a 256`) followed by the ISO image name and compare the number with this checksum hash: **c455ee948e872ad2194bdddd39045b83634e8613249182b88f549bb2319d97eb** For Windows users, one suggestion to use is [DivHasher](http://soft.mydiv.net/DivHasher.html) 3. If the number you calculate doesn't match the checksum hash above, there is a problem with your download. If the checksums match, your ISO file is not corrupt. Errors ------ You may from time to time receive **SELinux Alerts** in the GUI. These can be disabled by clicking on the "Show" button on the alert, and changing the "Would you like to receive alerts?" setting to "No" in the dialog box that pops up. Network Troubleshooting --------------- The following suggestions may help you to get your network working. 1. If you cannot see a network interface, try adding the following line to your virtual machine's `.vmx` file: ethernet0.virtualDev = "e1000" 2. If you network interface appears to be disconnected and you have made changes to your virtual network settings in the "Virtual Network Editor" in VMware, then the "NAT" setting on your virtual network adapter may not actually be connected to "NAT". Use the "Virtual Network Editor" window in VMware to confirm which of virtual networks you have has NAT enabled. Use the "Custom: Specific virtual network" setting for your "Network Adapter" in the "Virtual Machine Settings" window in VMWare to explicitly select the virtual network you want to connect to (that has NAT). 2. If you are unable to SSH into your virtual machine, the following suggestions might help: 1. Try using the `ping` and `tracert` commands from Windows to confirm network connectivity 2. Use the `systemctl status sshd` command to confirm that SSH is running CentOS Troubleshooting ---------------------- If you are having trouble getting CentOS to boot, or to run stably, you could try some of these suggestions. 1. If you use 'IDE' or 'SATA' interfaces for your virtual hard drives, the order in which the drives are detected at boot will change. This may result in the system failing to boot properly and entering emergency mode. Sometimes this problem can be fixed by rebooting the virtual machine -- to do this, log in as root in emergency mode and then issue the `reboot` command. 2. If this doesn't work, shut down your virtual machine using the `shutdown` command and ensure that all of the drives attached to your virtual machine use a 'SCSI' virtual interface. You will have to delete any drives that use 'IDE' or 'SATA', and recreate them as 'SCSI' hard drives. 3. You can also debug problems in emergency mode by using the `journalctl` command to view log and error messages. Error messages will be highlighted in red. Use the same keys you would use with `less` to navigate the output of `journalctl`. Press `q` to quit `journalctl`. Note that some error messages appear even during a normal boot. Use your judgement to determine which error messages are relevant to the failure of the system to boot. VMware Troubleshooting ---------------------- The most common problem with VMware Workstation since 2008 is when you receive the following error: > This virtual machine appears to be in use. > > If this virtual machine is not in use, press the "Take Ownership" button to obtain ownership of it. Otherwise, press the "Cancel" button > to avoid damaging it. Ideally, you should click the "Take Ownership" button and then everything will work normally for you. If that doesn't work, you can use the following procedure: 1. Close VMware Workstation 2. Delete any `.lck` or `.lock` files and/or folder you see in the directory containing the problematic virtual machine. 3. Run VMware Workstation 4. Start the virtual machine. ----------- The following suggestions for VMware troubleshooting involve making changes to your host computer or the configuration of your virtual machine. 1. Give your virtual machine two gigabytes of RAM. One gigabyte might result in poor performance, especially when the GUI is used. Using more than two gigabytes of RAM might trigger a kernel lockup when you take a snapshot. If you do receive a warning about a kernel lockup, you can safely ignore it. 1. Ensure that the following settings are turned on in your BIOS or UEFI firmware (you may not have all these settings, and some are different names for the same thing): - Intel Virtualization Technology - Intel VT-x - Virtualization Extensions - Vanderpool <!-- unnecessary blank line --> 1. Try uninstalling Microsoft's Hyper-V extension in the "Windows Features" option in the Control Panel. 1. Try increasing the number of processor cores allocated to the virtual machine to two. If you have a quad-core Intel CPU, you might be able to allocate as many as four cores. 2. Try uninstalling and reinstalling VMware. 3. Try an older version of VMware. 4. Don't use VMware. Try [VirtualBox](https://www.virtualbox.org/) instead. 5. Don't use Windows 10. There are [security issues with Windows 10](http://arstechnica.com/information-technology/2015/08/even-when-told-not-to-windows-10-just-cant-stop-talking-to-microsoft/) as well. Use an older version of Windows. 6. Don't use an AMD CPU. Historically, AMD CPUs have not always worked well with VMware Workstation. However there are [security issues with Intel chipsets](http://www.fsf.org/blogs/community/active-management-technology). ------ > Thanks to Ian Allen for some of the material on verifying ISO files