Hello, and welcome to today's video presentation on using the fstab file on Oracle Linux 8.
In this video, we will cover some background information about the fstab file and configure
it within an environment.
So let us get started.
The fstab file, also known as the file systems table file, is a system-level configuration
file located within the Linux file hierarchy at /etc/fstab.
Provided during OS installation by the setup package on Oracle Linux 8, the file contains
the configuration options for all boot-time disk partitions, file systems, and data sources.
During the OS boot routine, each line in the file gets read by the mount command and determines
the overall file system structure.
Maintained by the system administrator, these lines consist of six specific fields, each
separated by one or more spaces or tabs.
The fields, listed in order from left to right, perform the following tasks when attempting
to mount a device.
The first field is the device name.
When entering the device name, the recommendation is to use the UUID or LABEL on modern Linux
systems as the device names could change due to Dynamic Device Management, which will be
briefly covered later.
The next field is the mount point.
This field sets the location within the file hierarchy, where to attach the file system.
Next, follows the file system type and mount options fields.
The first of these entries, the file system type, matches the fs_type of the disk, device,
or partition and includes such examples as ext4, xfs, nfs, cifs, and swap.
While the other field, the mount options, is a comma-separated list of parameters passed
on to the mount command when attaching the device.
When configuring the mount options field for local block devices, it is common to use the
"defaults" setting, which is equivalent to using the mount options rw, suid, dev, exec,
auto, nouser, and async.
Lastly, there are the dump or backup utility field and the fsck order field.
The dump utility field links with an outdated disk backup application that only pertains
to the different extended or ext file system types.
Consequently, most modern Linux systems and administrators disable this feature by setting
this field to 0.
The last field in the line sets the order to check the file systems during boot using
the e2fsck utility.
The values for this field include 0, 1, and 2, where administrators typically set the
root file system to a value of 1 and other file systems to 2.
Using the value of 0 disables the file system check and is the correct setting for the swap
space.
With the basics of the fstab file explained, let us discuss a few more items before starting
the demo.
First, always maintain and modify the fstab file as necessary.
Administrators should especially review potential changes after adding a new hard disk or repartitioning
an existing drive.
Second, in cases where the device attached is hot-swappable, such as flash drives, CD-ROMs,
or DVD-ROMs, udev, also known as Dynamic Device Management, can act as an automounter to handle
these devices and run specific tasks.
The udev functionality replaces the need to add these types of devices into the fstab
file.
As udev is outside the scope of this video, be sure to check out the udev man page for
more details.
Now let us jump into the demo and put the information learned to practical use.
For this demo, the Oracle Linux 8 system used resides on the Oracle Cloud Infrastructure
and has a free ext4 file system on /dev/sdb1.
The steps executed in this video also work with on-premise hardware configured with existing
block storage and file system.
Start by opening a terminal and type sudo vi /etc/fstab.
The first part of the file shows three entries, and each presents the six configuration fields.
Device name, mount point, file system type, mount options, dump utility, and the file
system check order.
Note the file system check field for the root file system set to 0, indicating it is disabled.
The second part of this file has a series of comments, specific to instances on Oracle
Cloud Infrastructure, that indicate key mount options used to mount a block volume.
This information is useful as mounting a free block volume will be the main focus of this
demo.
Now exit out of vi.
Next, get the block device information by typing sudo lsblk -fs -d.
The option -fs is the equivalent of using -o and requesting the output columns NAME,
FSTYPE, LABEL, UUID, and MOUNTPOINT.
The option -d, short for --nodeps, hides holder devices, and other file system structures.
The output displays a list of block devices and all the necessary information when updating
the fstab file, including the device name, fs_type, and UUID.
For this example, we are interested in the sdb1 device.
Now check the tunable parameters of this device by typing sudo tune2fs -l /dev/sdb1.
In the listing, find the value of maximum mount count.
The listing shows a value of -1, which means the e2fsck utility and the kernel both will
disregard the device.
To enable the automatic check of this device after 20 reboots, adjust this setting by typing
sudo tune2fs -c 20 /dev/sdb1.
Before moving on to the next set of commands, disable the automatic fsck check again by
typing sudo tune2fs -c -1 /dev/sdb1.
With the automatic file system check disabled, run the check manually.
Ensure the device is not mounted by typing sudo umount /dev/sdb1.
Then type sudo fsck /dev/sdb1.
When running fsck manually, ensure to provide a device name, UUID, or LABLE.
Failure to provide this information in the command will cause fsck to check all available
devices.
Upon execution, the fsck command calls the e2fsck utility and proceeds to check the file
system.
Resolve any errors from the fsck scan by answering the questions presented accordingly.
To avoid needing to answer the questions, pass the -y option when running the fsck command.
The -y option will automatically respond yes and accept the default to all questions during
the fsck scan.
After running these series of commands and reviewing the output, there is enough information
to safely return and edit the fstab file.
Again, open the file using sudo vi /etc/fstab.
Navigate to the bottom of the file.
Create a new entry for the free device /dev/sdb1.
When creating the entry, use the UUID and file system type gathered from the previously
ran lsblk command.
If you don't have the information, run the lsblk -fs -d command again and then copy and
paste into the proper fields.
Match the mount options for /dev/sdb1 to those shown in the comments section related to Oracle
Cloud Infrastructure block devices.
With the entry created, save the changes and exit vi.
Next, update systemd components about the new file system changes by typing sudo systemctl
daemon-reload.
Executing this command is a recommended step for Linux systems running systemd, such as
Oracle Linux 8.
Lastly, mount the device.
Type sudo mount | grep sdb to demonstrate that the device configured is not mounted.
Next, type sudo mount -a to mount all entries listed in the fstab file.
Now confirm the device is mounted by typing either sudo mount | grep sdb or df -h
With the device mounted, that completes this exercise of configuring and using the fstab
file on Oracle Linux 8.
Thank you for watching this video and enjoy using Oracle Linux 8.
Please check our additional information on Oracle Linux 8 in the Oracle Linux 8 Documentation
or Oracle Linux Learning Library.