In this lesson,
we're going to talk about mounting file systems.
After formatting partitions
and logical volumes with file systems,
we need to make those accessible for users.
So we are going to make these file systems available for users
by mounting them into the operating system.
Now, before an operating system can read from
or write to a disk, the file system
on one of those disk partitions has to be mounted.
Since a file system is really just a big array of bytes
typically stored on a partition,
you need to get access to the file system by mounting it.
Now a mount point is an access point
where information is going to be stored on a local
or remote storage device.
That mount point is typically going to be an empty directory
on which a file system is going to be loaded or mounted
to make that file system accessible to users.
The mount command is what we're going to use
to load a file system to a specified directory
so it can be accessible to users and applications.
To do this, we have to specify the device to mount to,
as well as the desired mount point.
The proper way to use the mount command is to type mount,
the options you want to use,
the device name you want to use,
and the mount point you want to use.
You can also specify various mount options
for a file system.
These options are typically included in the fstab file
rather than as a command line argument.
Option auto, for example, is used to specify
that the device has to be mounted automatically.
Noauto is going to be used to specify
that the device should not be mounted automatically.
Nouser is going to be used to specify
that only the root user can mount a device or file system.
And user is used to specify
that all users can mount a device or file system.
Exec is going to allow binaries in a file system
to be executed,
whereas noexec is going to be used to prevent binaries
in a file system from being executed.
Ro is going to be used to mount a file system as read only,
whereas rw is used to mount that file system
as a read or write partition.
Sync is going to be used to specify
that input and output operations
in the file system should be done synchronously.
Async, on the other hand, is going to be used to specify
that the input and output operations
in that file system can be done asynchronously.
I know I just mentioned a lot of options there,
and one of the things I mentioned
was a binary being executed.
Now you may not know what a binary is,
so let me cover that real quick.
A binary is source code that has been compiled
into an executable program
or otherwise assembled
so it can be readable by the computer system.
In addition to this,
binaries can also be things like pictures,
word-processing files, or spreadsheet files,
essentially anything that is not
a standard text readable file.
Now after you're done using the file system,
you may choose to unmount that file system.
And this means it'll be disassociated
from the directory by unloading or unmounting it
so it's no longer going to be used.
To do this, we're going to use the umount command.
The umount command stands for unmount.
In order to unmount a file system,
it has to not be in use currently.
That means that you can't have any files
from that file system currently open in some application
like a word-processing program
or a spreadsheet or something like that.
The proper way to use the umount command is to enter umount,
the options, and the mount point.
There's also some common options for you umount,
things like -f, which will force a file system
to be unmounted despite any detected issues.
Be very careful using this one.
There's another option known as -l.
This is used to perform a lazy unmount,
in which the file system is detached from the hierarchy,
but references to that file system are not cleaned up
until the file system is no longer being used.
We can also use -R, which recursively unmount
the specified directory's mount points.
We can also use -t and the file system type
if we want to unmount only the file system types
that are specified like all FAT partitions
or all Ext2 partitions.
We can also use -O with some mount options
to unmount only the file systems that are mattered
with the specified options inside the /etc/fstab file.
Or we can type -fake to test the unmounting procedure
without actually unmounting the file system.
Remember, mounting of the file system occurs
during the startup process normally,
and it's managed by the /etc/fstab configuration file.
An easy way to remember this is that,
fstab stands for file system table.
And it's a list of all the file systems
that need to be mounted,
their designated mount points,
and any other options that might be needed
for specific file systems.
Another method of mounting a file system is to use
the systemd or system daemon.
The systemd.mount can be used to create a new mount unit
to mount this file system.
To set this up, you need to create a text file located
in the /etc/systemd/system directory
and name it as something.mount.
For example, here, I'm going to create
a text file called /etc/systemd/system
/var-lib-docker.mount.
And this is going to be used to mount a specific disk
and its UUID to the /var/lib/docker directory
as a mount point.
I've done this using the btrfs file system
and the default options.
To enable this, I'm going to use systemctl
and enter systemctl enable var-lib-docker.mount
at my Command Prompt.
When I reboot my system,
this new mount point is going to be created,
and the disk is going to be mounted to it.
The final thing I want to discuss
in this lesson concerning file systems is the concept
of FUSE, which is the Filesystem in USErspace.
FUSE is a software interface in Linux systems
that lets non-privileged users create their own file systems
without editing the underlying kernel code.
FUSE was originally developed and designed
as a virtual file system
that allows you to specify how read, write,
and stat requests can be made to a file system,
as well as how to mount this new file system you'd create.
FUSE is commonly used to create virtual file systems
that are detached from the underlying physical media
or drives themself.
And this allows them to act as sort of a translation
between different file system types as needed.
For example, if you need to be able to read
or write to an NTFS-based volume
but your system doesn't support it natively,
you could write a translation program using the Filesystem
in USErspace to provide you with this capability.
Other common uses of FUSE is to allow
a local Linux operating system to interact
with cloud-based file storage systems
like Amazon's S3 Buckets or Microsoft Azure Blobs.
As you can guess, FUSE is really useful
to be able to read and write
to all sorts of different file systems
that you can then mount easily
inside of your Linux operating system.