Due Date and Deliverables ========================= > **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**: - Lab books are assessed by your peers and reviewed by your lab professor. The first lab book assessment will take place in a few weeks. * **Available online** - Version 1.0 -- 11h00 September 11, 2017 - Version 1.1 -- 9h00 September 13, 2017 - Version 1.11 -- 9h00 September 13, 2017 - Added information related to KDE freeze on boot - Version 1.21 -- 9h35 September 13, 2017 - `lspci` is located in `/usr/sbin`, not `/usr/bin` - `mkfs` is located in `/usr/sbin`, not `/usr/bin` - Version 1.3 -- 14h30 September 15, 2017 - Explicitly stated that you should create a `/usr/bin/*` page for `lsusb` and other commands. * **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 * **Deliverables** 1. Complete your lab book as described in the assignment. * **Evaluation** - Lab books are assessed by your peers and reviewed by your lab professor. The first lab book assessment will take place in a few weeks. Purpose of this Assignment ========================== 1. Learn about the KDE GUI. 2. Learn about device files in the `/dev` directory. 3. Learn about hardware diagnostic tools like `lspci`, `lsusb`, and `lsmod`. 4. Learn about partitioning and formatting drives. 4. Learn about mounting and unmounting drives. 5. Learn about the `/proc`, `/sys` and `/dev` filesystems. 6. Learn about testing system hardware Introduction and Overview ========================= This assignment will be completed on your laptop. You will create a virtual machine which will run a CentOS 7 64-bit live DVD. A live DVD is a complete bootable computer installation including operating system which runs in a computer's memory, rather than loading from a hard disk drive; the DVD itself is read-only. **When you reboot the virtual machine, you will lose any work you have done.** If you need to, you can pause or suspend the virtual machine instead. After starting CentOS using a VM and a live DVD, you will run specific commands at the command line. You will evaluate the results and take notes in your lab book. Lab Book -------- All CST8177 students are required to purchase a *Filofax A5 Notebook* or *Blueline MiracleBind 9.25"x7.25" Notebook*. The bookstore on campus sells at least twenty different colours and styles of the Filofax notebook for $14.99, and two colours of the Blueline notebook for $11.99. This notebook will be your laboratory notebook for this course. Bring your laboratory notebook (or "lab book") to every lab class. Your lab book will act as a cumulative record of your lab work. It also documents your learning over time, and acts as a reference for the lab midterm and lab exam. You must organize your lab book exactly as specified in the assignments. Each lab asks you to document specific files and commands. Additional examples, drawings and notes you want to write down may be included as long as the specified organizational structure of the lab book is adhered to. Always record any **new** commands that you learn. Your lab book acts as an organizational tool and memory aid, as well as a tool for assessment and feedback. You may be asked to record your interpretation, description, calculation, explanation, or prediction of results as part of each lab assignment. Your lab book will be assessed by peer review several times during the semester, and by your lab professor at the end of the semester. When you learn about a new file or command, you should always record in your lab book the absolute pathname and purpose of the file or command. In addition, you should record the syntax, description, and common arguments and options of important commands as indicated in these assignments. Be sure to use a different colour when you write the absolute pathnames. When recording commands, you should use standard syntax. Arguments/options are enclosed in square brackets to indicate that they are optional. Arguments and options which are mutually exclusive are separated by a vertical bar. Make sure to include detailed descriptions of the command and the arguments/options you are documenting. It is not necessary to document every possible argument or option for each command, but you are expected to document arguments and options used during a lab. Your lab notebook is a form of [grimoire](http://www.linux2.ca/grimoire.html). For marking purposes you will need to keep it clean and tidy for me. Legible handwriting is expected. Any diagrams must be clear. You should organize the lab book in alphabetical order by title, using the absolute pathnames for page titles. Use wildcards as needed (see below). Alphabetical order of the pages is all that is required. The contents of individual pages do not need to be in alphabetical order. Make sure to title every page. Grading ------- Your lab book will be assessed by your peers. Your lab book and peer assessments will be reviewed by your lab professor. Further details will come in the next assignment. Completed lab books are worth 20% of your final grade at the end of the semester. Requirements ------------ You will need a lab book. 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 LiveKDE DVD for CentOS 7. Obtaining your CentOS 7 64-bit LiveKDE DVD ------------------------------------------- CentOS is distributed by the [CentOS Project](https://www.centos.org/). Download the **CentOS 7 64-bit LiveKDE DVD** .iso file. Get it on-campus at [http://cstech](http://cstech), or off-campus using [BitTorrent](http://mirror.csclub.uwaterloo.ca/centos/7.3.1611/isos/x86_64/CentOS-7-x86_64-LiveKDE-1611.torrent) or [direct download](http://isoredirect.centos.org/centos/7/isos/x86_64/CentOS-7-x86_64-LiveKDE-1611.iso). You could also try obtaining a copy from someone else who has already installed successfully. 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 "CST8177 17W *username* LiveKDE", 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 **4096** MB of memory to the virtual machine. 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 ------------------------------------- 1. From the "Hardware" dialogue box, select *New CD/DVD (IDE)*. 2. In the right half of the dialogue box, select the `User ISO image file` radio button. Click the `Browse...` button and locate the CentOS 7 LiveKDE 64-bit DVD .iso file you downloaded earlier. 3. Click the `Close` and then `Finish` buttons. 4. Click `Finish`. Running Linux ============= Power the virtual machine on by clicking the `Power on this virtual machine` button. > If KDE freezes up with only a hard drive icon on the screen, double-click on > the hard drive icon. This should prompt KDE to continue. The cause of the problem described above is unknown, but is likely related to the error below. > You may receive an error which reads:<br\><br\> > > > *"Unable to save bookmarks in /home/liveuser/.local/share/user-places.xbel. > Reported error was: Insufficient permissions in target directory. This error > message will only be shown once. The cause of the error needs to be fixed as > quickly as possible, which is most likely a full hard drive."*<br\><br\> > > > You can safely ignore this error and click **OK**. Once the Live DVD boots up, answer the initial questions and try using KDE. Figure out how to open a terminal window. Filesystem ---------- Now that we have access to a command prompt, let us take a look at the filesystem. > **Title the first page of your lab book with the title "/"**. We will use this first page to document all of the top-level directories in the filesystem. > Use the `ls` command to produce a long listing of the contents of root directory. Write down the absolute path of each of the top-level directories, as well as the targets of any symbolic links, along with a description of what it's for. So, for example, you should document `/usr/bin` not `/bin`. Use a different colour to write the absolute pathname. Descriptions should be brief; two or three lines only. Use a second page if you need to, and title it **"/ (2)"**. System Hardware --------------- Now, let us examine the hardware environment. First, try typing the `lspci` command and examine the output. This command lists all devices on the PCI bus. There is a lot of useful information here. Experiment with the level of verbosity of this command, by using the `-v` switch. > **Title the next page of your lab book with the title "/usr/sbin/*"**. We will use this page to document simple commands. The first command you should document is `lspci`. Record the absolute path of the command (again, in a different colour) along with a two or three line brief description. Note that you can use the `whereis` command to learn the absolute pathname of commands. Don't forget to mention the `-v` option! Additional commands in `/usr/sbin` that you learn about during this assignment should also be documented on this page, including `whereis` if you've never used it before. Try running the `lsusb` command to display all the hardware devices on the USB bus. As USB devices are added or removed, the output of the `lsusb` command will change. > **Title the next page of your lab book with the title "/usr/bin/*"**. Document `lsusb` on this page, just as you did with the `lspci` command on the `/usr/sbin/*` page, along with any other commands you learn in this assignment which are stored in `\usr\bin\*` . Run the `lsmod` command. This command lists kernel modules currently loaded into memory. Hardware device drivers often take the form of optional kernel modules. Although some hardware support is compiled into the kernel, kernel modules to support most hardware are only loaded into memory if the hardware is actually present. Examine the contents of the `/dev` directory. This directory contains device files. A device file is a special kind of file which represents a hardware device. Nothing in the `/dev` directory is actually stored on a hard drive anywhere. Instead the contents of the directory provide resource handles for programs to access system hardware. Locate the device file which represents the hard drive (not currently in use). This file will be named `/dev/sda`. The `sd` part of the name indicates that this is a SCSI or SATA drive. The `a` portion of the name indicates that this drive is the first drive. > **Title the next page of your lab book using the title `/dev/*`. Document `/dev/sd*`. Describe the naming convention used for SCSI or SATA drives using your own words.** Be sure to document any new files, directories or commands that you learn during the rest of the assignment. Partitioning a Drive -------------------- Before a hard drive can be used, it must be divided into partitions. Each partition is allocated a certain amount of the total available space on the drive. It is recommended to create filesystems on partitions. Information on hard drive partitions is stored in a special area of a hard drive called a partition table. You need root privileges to make changes to a partition table. You can use the `sudo` command to run another command with root privileges. For example, if you run the command `whoami` the system will respond: `liveuser`. But if you run the command `sudo whoami`, the system will respond: `root`. Combine the `sudo` and `fdisk` commands with the `/dev/sda` device filename to construct a command that will let you edit the partition table with `fdisk`. Run your command. > **Title the next page of your lab book using the title `/usr/sbin/fdisk`.** The `fdisk` command is complex enough that it will require its own page. Record any examples, command sequences or other information that you think is important about `fdisk` on this page. Don't forget to keep your lab book organized in alphabetical order. Once you are running `fdisk`, use the `m` key to get help on the various operations you can perform. You can also open a second terminal window and type `man fdisk` to learn more about how the partitioner works. Use the `p` key to display information about the drive. Note the sector size. Use `fdisk` to perform the following tasks, in order: - Create a new, empty DOS partition table - Add a new primary partition of type Linux which is the first (#1) partition on the drive and uses up all the available space on the drive. - Write the partition table to disk and exit. Note that it is not possible to create a partition that starts at any sector number less than 2048. Partitions show up in Linux as device files with the same name as the parent hard drive, with a number affixed. For example, after creating a new partition on `/dev/sda`, there should be a new partition named `/dev/sda1`. <a name="creating-a-filesystem"></a>Creating a filesystem --------------------- You must create a filesystem in a partition before you can store files on a hard drive. The `mkfs` utility is used to create file systems. > **Title the next page of your lab book using the title `/usr/sbin/mkfs`.** You can read the man page for `mkfs` to see a list of the different file systems it can make and the syntax it uses. Format the new partition you created using the `ext2` file system. Record relevant examples, command sequences, options and so on in your lab book. **Check your work.** It's very important that your partition and drive be configured correctly. Enter this command to check your drive: `sudo file -s /dev/sda` You should see output like this: [liveuser@localhost ~]$ sudo file -s /dev/sda /dev/sda: x86 boot sector; partition 1: ID=0x83, starthead 32, startsector 2048, 41940992 sectors, extended partition table (last)\011, code offset 0x0 Note that the drive `/dev/sda` has a DOS (x86) partition table that contains a single partition. Now, enter this command to check your partition and filesystem: `sudo file -s /dev/sda1` [liveuser@localhost ~]$ sudo file -s /dev/sda1 /dev/sda1: Linux rev 1.0 ext2 filesystem data, UUID=8af77399-8e59-4571-987f-8df862e4034c (large files) Note that the partition `/dev/sda1` contains an ext2 filesystem. The `UUID` and `starthead` values might not match the example above. You can also use the `blkid` command to determine the UUID of a partition directory. Try this on `/dev/sda1`. Use the command `blockdev` to determine the blocksize of the filesystem on `/dev/sda1`. Note that this is the size of filesystem blocks; one filesystem block might span several sectors (or "physical blocks") on the actual storage device. Ask yourself -- how many disk sectors are contained in one block in the filesystem? Mounting a filesystem --------------------- A file system must be attached to the file tree before it can be used. A directory must be assigned as a 'mountpoint'. This directory becomes the root of the file system on the drive when it is mounted. Any files or directories located inside the mount point before a drive is mounted are hidden after it is mounted. Create a new directory in the `/mnt` directory. This will be your mountpoint. You will need root permissions to perform this and many other tasks. Use `sudo` for this. Mount the `ext2` filesystem you created earlier at this mountpoint using the `mount` command. If you mount the drive successfully, you will find your mountpoint now contains a directory called `lost+found`. Any file fragments recovered during filesystem integrity checks on the `ext2` filesystem are stored here. Create an empty file in mountpoint, which is now the root directory of the `ext2` filesystem. Give this empty file a different name from the one you gave to the mountpoint. Make sure you are not currently in the mountpoint or any of its subdirectories. If you are, the drive will be considered to be in use and you will not be able to unmount it. Try unmounting the drive using the `umount` command. Once you succeed, your mountpoint will revert back to being a normal, and empty, directory. Mount the drive again and note that the `lost+found` directory and your file have reappeared inside the mountpoint. All drives are mounted and unmounted from the filesystem in this way, including the root filesystem, which is mounted on `/`. Monitoring filesystems ---------------------- The `df` command displays the amount of free disk space on each mounted drive. Try it! The `du` command displays the amount of disk space used by files and directories. Try this command too. Halting the system ------------------ Since you have root access, you can halt the server. Use the `shutdown` command to turn off the server. It's important to shut down the server to ensure that all drives are safely unmounted. A sudden reset or loss of power could result in data loss. Turn the server back on. Once you have logged in, check your mountpoint. It no longer exists. Note that the device `/dev/sda1` still exists, however. The root filesystem resets at boot because a live CD only **appears** to be read-write; in fact, any changes you make to it are lost at boot. Create a new mountpoint with a new name. Mount the `/dev/sda1` device there. You should now be able to list the name of the file you created on this filesystem earlier. Mounting at boot ---------------- Whether a drive is mounted at boot or not depends on the configuration of the `/etc/fstab` file. As part of the boot process, any drives configured in the `/etc/fstab` file are mounted at boot. Display the contents of the `/etc/fstab` file. Here you can see the name of the device which contains the filesystem mounted on the root directory, as well as the filesystem type and any options passed to `mount` when this filesystem was mounted. Some drives might use a UUID instead of a pathname. > **Title the next page of your lab book using the title `/etc/fstab`.** Record the meaning of each of the six columns of the `/etc/fstab` file. Virtual filesystems ------------------- Virtual filesystems are listed in the `/etc/fstab` file, and are displayed along with other filesystems as part of the output of the `mount` command. These are filesystems which are dynamically generated at runtime and do not reside on any drive. Take a look through the `/sys` and `/proc` directories before proceeding to the next step. System information ------------------ > **Title the next page of your lab book with the title "/proc"**. Anything useful you find in `/proc` can be documented on this page. One useful file which resides in `/proc` is `/proc/cpuinfo`. This virtual file contains detailed information on system processors. Testing the CPU(s) ------------------ <!-- > Take a snapshot of your virtual machine before proceeding! --> When new physical systems are put together, it's common to test the components in a burn-in test. By running components at maximum capacity, they can be tested to confirm that they will not fail immediately. You can test the CPU by using the command `sum /dev/zero`. This has the effect of pushing CPU utilisation to 100%. Because it is a single-thread process, it affects only one core. Try running the command `sum /dev/zero` as the user `liveuser`. Use the `KSysGuard` GUI utility in KDE to monitor CPU utilization in the `System Load` tab. Notice that only one of your CPU cores is at 100% usage. It's possible that if you have other processes running, that the second core will also reach 100%, but there will be one core which goes to 100% and stays there. <!-- References --> [CST8207 GNU/Linux Operating Systems I]: http://teaching.idallen.com/cst8207/16f/ Troubleshooting =============== <a name="Verify_the_Downloaded_ISO"> Verify the Downloaded ISO ------------------------- To verify the downloaded CentOS ISO, 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-LiveKDE-1611` that is `1,732,608` KB (`1.65GB`). 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: **b584dd3cf2e287756aa6f6ec0f287500470b7e588b605211981b3b9ad09abac9** 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. 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). Network Troubleshooting --------------- The following suggestions may help you to get your network working. THIS IS NOT REQUIRED FOR THIS LAB. 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 ------ > Thanks to Ian Allen for some of the material on verifying ISO files.