Hello, and welcome to today's video presentation on using the mount command on Oracle Linux
8.
In this video, we will cover using the mount command to attach a file system to a systems
file hierarchy.
So let us get started.
First, clarifications.
The file hierarchy, listed under /, arranges all files accessible in Oracle Linux in one
big tree.
This / location gets referred to as the root of the file system.
The files and directories within a file hierarchy are potentially spread out across many devices
or partitions.
For users to access the different devices or partitions, the mount command serves to
attach the filesystem on these devices to the hierarchy, while umount will detach it.
For this exercise, the Oracle Linux 8 system on Oracle Cloud Infrastructure has an ext4
file system on /dev/sdb1.
These same steps work on physical hardware, where available block storage with a file
system created exists.
Instructions on how to partition or create a file system on a block device is available
in our other videos at www.oracle.com/goto/oraclelinuxlearning under Disk Management.
With an understanding of what the mount command does, now let us get into this demo.
Start by opening a terminal.
Next, create a mount point if one does not already exist.
A mount point is simply a directory created within the file hierarchy and is required
to attach the designated ext4 file system.
For this exercise, use or create the directory /demo.
If the directory does not exist, create the directory by typing sudo mkdir /demo.
The mkdir command requires sudo as a regular user would not have privileges to write to
the root of the file hierarchy.
Next, attach the partition (file system) to the directory by typing sudo mount /dev/sdb1
/demo.
You can explicitly specify the file system type using the -t option as in sudo mount
-t ext4 /dev/sdb1 /demo.
The mount command alternatively allows for the use of the UUID or label to mount the
device.
Type sudo blkid to get the UUID or label information.
Next type sudo mount UUID=" copy in the universally unique identifier of the block device " /demo.
Or type sudo mount LABEL=" the label of the block device " /demo.
If your block device containing a file system does not have a label, it is possible to set
one using the e2label command or the -L option of the tune2fs command.
More details on both of these commands are available in their respective man pages.
When mounting different block devices, there are several options to consider.
For example, when mounting ext3 or ext4 file systems, you can set three different journaling
levels.
Using the -o flag with the mount command:
The data=journal option is the highest level and does the most journaling.
This option writes the journal entries for all the data and metadata changes.
This data gets committed to the journal before being written into the main file system.
That ensures consistency when writing the file and of the filesystem as a whole.
However, this overhead can significantly decrease performance.
The data=ordered option is the default mode.
All data is forced directly out to the main file system before its metadata is committed
to the journal.
The order of operations here is rigid in that; first, metadata is committed to the journal;
second, data gets written to the filesystem.
Only, after this second step, is the associated metadata in the journal flushed out to the
filesystem itself.
This procedure ensures in the event of a crash, the metadata associated with incomplete writes
is still in the journal, and the filesystem can sanitize those incomplete writes while
rolling back the journal.
Thus, in ordered mode, a crash may result in corruption of the actively written file
or files during the crash, but the filesystem itself—and the files not actively written
to—are guaranteed safe.
The data=writeback option is the lowest level and least safe-journaling mode.
Like ordered mode, the method journals the metadata, but not the data.
Further, the writeback option does not preserve data ordering.
Therefore the data can be written into the main file system after its metadata has been
committed to the journal in whatever order makes sense for best performance.
This option can offer significant increases in performance but at the cost of safety.
Writeback mode still offers a guarantee of safety to the file system itself, but files
written to during or before the crash are vulnerable to data loss or corruption.
Beyond attaching a disk or USB flash drive, the mount command allows connecting devices
in read-only mode or accessing ISO images.
By using these additional mount options, accomplish that task by passing the -o flag followed
by a comma-separated string.
Some of those options include:
The auto option allows mounting the file system with the –a option.
The loop option mounts a file and makes it accessible as a block device.
The noauto option does not allow the use of the –a option.
The noexec option does not allow the execution of binary files.
The nouser option does not allow a non-root user to mount and unmount the file system.
The remount option remounts the attached file system.
The ro or rw option attaches the file system for read-only or read/write.
And
The user option allows a non-root user to attach and detach the file system.
To demonstrate these options,
Type sudo mount –o nouser,ro /dev/sdb1 /demo to mount the device as read-only and give
only the root user access to mount and unmount the file system.
To mount an ISO image, type sudo mount -o ro,loop /home/oracle/iso_files/OracleLinux-R8-U2-x86_64-dvd.iso
/media/cdrom
To confirm the ISO image is attached, type ls -l /media.
Note that the ISO image connected successfully, and the permissions on the files are read-only.
With the different file systems attached, type sudo mount to get a listing of all the
connected file systems.
Use the | and grep to limit the output to what you want to see.
The commands df -h and cat /proc/mounts give similar information.
Lastly, remove the file systems mounted by using the umount command.
Type sudo umount /dev/sdb1 or sudo umount /media.
These commands detach the devices using the partition name, the device name, or the mount
point as an argument.
That completes this exercise of attaching a file system on Oracle Linux 8 using the
mount command.
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.