Linux Chapter 5
Linux Chapter 5
Hands-On Projects
These projects should be completed in the order given. The hands-on projects
presented in this chapter should take a total of three hours to complete. The
Project 5-1
In this hands-on project, you view and create device files.
Boot your Fedora Linux virtual machine. After your Linux system
1
has loaded, switch to a command-line terminal (tty5) by pressing
Ctrl+Alt+F5. Log in to the terminal using the user name of root
character device file? Why? What are the major and minor
271
Switch to tty6 by pressing Ctrl+Alt+F6 and attempt to log in to the
4
terminal using the user name of root and the password of
successfully?
different for each file? Is the minor number different for each file?
Why?
At the command prompt, type find /dev and press Enter to list all
8
of the filenames under the /dev directory. Are there many files?
compare with what you observed in Step 2? Press q to exit the less
utility when finished.
media.
over this icon to view the mount point directory. Which directory
was your DVD automatically mounted to? Take a few moments to
explore the contents of the DVD within the Files application. When
272
At the command prompt, type cp /etc/hosts /mnt and press Enter.
6
Next, type ls /mnt and press Enter to verify that the /etc/hosts file
directory.
At the command prompt, type mount and press Enter and view
8
the output. Next, type cat /etc/mtab and press Enter. Is the output
shown by these commands more verbose than in Step 7?
At the command prompt, type cd /mnt and press Enter. Next, type
9
ls -F and press Enter. Are the contents of the DVD the same as Step
2?
Enter. Note that you are currently using the /mnt directory, which
prevents unmounting.
At the command prompt, type ls /mnt and press Enter. Is the copy
12
of /etc/hosts available again after the Fedora DVD was unmounted?
Project 5-3
In this hands-on project, you work with standard hard disk partitions. You will
first create a hard disk partition using the fdisk utility. Next, you create an ext4
filesystem on the partition and mount it to the directory tree. Finally, you use
At the command prompt, type lsblk and press Enter. What block
2
device holds the partitions that you created during Fedora
installation? Also note that you have three partitions under this
block device: the first partition is mounted to the /boot directory,
the second partition is used as Linux swap and the third partition
At the fdisk prompt, type p and press Enter to view the partition
4
table on your hard disk. Do the partitions match the output from
Step 2?
273
At the fdisk prompt, type p and press Enter to view the partition
6
table on your hard disk. How many partitions are present? What
type of partition is /dev/sda4?
At the fdisk prompt, type p and press Enter to view the partition
8
table on your hard disk. How many partitions are present? What
type of partition is /dev/sda5?
At the fdisk prompt, type l and press Enter to view the different
9
partition types. What type is used for Linux swap? Which
character would you type at the fdisk prompt to change the type of
partition?
At the fdisk prompt, type w and press Enter to save the changes to
10
the hard disk and exit the fdisk utility.
Next, type the df -hT command and press Enter to verify that the
filesystem was mounted correctly.
274
At the command prompt, type reboot and press Enter. After your
19
Linux system has been loaded, switch to a command-line terminal
(tty5) by pressing Ctrl+Alt+F5 and log in to the terminal using the
user name of root and the password of LINUXrocks!.
At the command prompt, type mount and press Enter. Is your
20
new filesystem mounted? Why?
Project 5-4
In this hands-on project, you create two new partitions using the GNU Parted
utility, and configure the LVM to host an LV using the space within. During this
process, you will learn how to create PVs, VGs, and LVs, as well as add storage
to extend a VG and LV. Finally, you will edit the /etc/fstab file to ensure that
your LV is mounted at boot time.
two values represent the start and end of the remainder of the free
space on your virtual hard disk.
At the parted prompt, type mkpart and press Enter to accept the
4
default of logical drive. Press Enter again to accept the default
partition type (Linux ext2). When prompted for the Start of the
new partition, enter the (A) value you recorded in Step 3 and press
Enter. When prompted for the End of the new partition, enter the
(A) value you recorded in Step 3 plus 1GB and press Enter to
At the parted prompt, type p and press Enter to view the partition
5
table on your hard disk. What type of partition is /dev/sda6? Write
down the End value for your second logical drive (/dev/sda6):
(C).
At the parted prompt, type mkpart and press Enter to accept the
6
default of logical drive. Press Enter again to accept the default
partition type (Linux ext2). When prompted for the Start of the
new partition, enter the (C) value you recorded in Step 5 and press
Enter. When prompted for the End of the new partition, enter the
(C) value you recorded in Step 5 plus 1GB and press Enter to
create another 1GB partition.
At the parted prompt, type quit and press Enter to save the
7
changes to the hard disk and exit the GNU Parted utility.
At the command prompt, type reboot and press Enter to reboot
8
your machine and ensure that the partition table was read into
memory correctly. After your Linux system has been loaded,
275
At the command prompt, type pvcreate /dev/sda6 and press
9
Enter. Next, type pvscan and press Enter to verify the creation of
your PV. Following this, type pvdisplay and press Enter to view
the PE size chosen as well as the total size of the PV.
your vg00 VG. Following this, type vgdisplay and press Enter to
view the PE size chosen as well as the total size of your VG.
At the command prompt, type lsblk and press Enter to note the
18
relationship between your LV and your two PVs (/dev/sda6 and
/dev/sda7).
At the command prompt, type vi /etc/fstab and press Enter. Add
19
the following line to the bottom of the file to ensure that the
newdata LV is mounted at boot time:
276
Save your changes and quit the vi editor.
20
At the command prompt, type reboot and press Enter. After your
21
Linux system has been loaded, switch to a command-line terminal
(tty5) by pressing Ctrl+Alt+F5 and log in to the terminal using the
user name of root and the password of LINUXrocks!.
Project 5-5
In this hands-on project, you view disk usage and check filesystems for errors.
Project 5-6
In this hands-on project, you enable, set, and view disk quotas for the
/newmount filesystem created earlier in Project 5-3.
Switch to a command-line terminal (tty5) by pressing Ctrl+Alt+F5
1
and log in to the terminal using the user name of root and the
password of LINUXrocks!.
277
At the command prompt, type chmod 777 /newmount to give all
2
users the ability to create files within the /newmount directory.
Switch back to tty5 by pressing Ctrl+Alt+F5 and note that you are
6
still logged in as the root user on this terminal.
278
Project 5-7
In this hands-on project, you create a new partition using the cfdisk utility,
format and check an XFS filesystem on that partition, as well as mount the
filesystem using a GUID at boot time.
Select Write to save your changes; type yes and press Enter when
3
prompted to confirm. Next, select Quit to save your changes and
exit the cfdisk utility.
At the command prompt, type blkid and press Enter. Record the
8
UUID of your XFS filesystem (/dev/sda8): .
Discovery Exercises
279
1. Answer the following questions regarding your system using the
commands available.
a. What are the total number of inodes in the root filesystem? How
many are currently utilized? How many are available for use?
software to add a second 8GB hard disk to your virtual machine that
a. For the first partition, use the appropriate commands to add the
available space to the vg00 VG that you created in Project 5-4,
3. Provided that your virtualization software allows for USB device pass-
through, connect a USB flash memory drive to your system. Use the
appropriate commands to locate the device file used by the device,
filesystem for errors. Finally, add a line to /etc/fstab to ensure that the
filesystem can be easily mounted in the future (this line should not
automount the filesystem at boot time).
provides.
6. You have a Linux system that has a 1000GB SSD, which has a 90GB
space. The department manager has made it very clear that this
system must not exhibit any downtime as a result of hard disk errors.
How much hard disk space will you require, and what partitions
would you need to ensure that the system will perform as needed?
Where would these partitions be mounted? What quotas would you
implement? What commands would you need to run and what
7. You have several filesystems on your hard disk that are mounted to