Now let's look at how to adjust file system and mount options.
We saw how the lsblk command gives us a nice overview of what is mounted where
it's short and to the point. But sometimes we also want the details, details like
what file system is mounted here and what are the mount options for this file system?
Of course, first, we'll need to understand what the mount options are,
but we'll get to that in a few seconds.
First,
let's look at another command that shows everything that's mounted on this system.
Find MNT.
We can spot our slash DEV slash B db one partition
with the XFS file system mounted in the my backups directory.
This command will output many lines usually double of what we can see here.
We've truncated output in this example so that it will fit our screen
now, it can look very messy and hard to read,
especially if we don't need all this information.
Find
out shows all mount points including some virtual stuff.
For example, proc is a virtual file system mounted in the slash proc directory.
This file system does not exist on some storage device somewhere.
It's only in the computer's memory.
In our situation, we don't need to see all this virtual stuff.
So we can tell find mount to only show us real file systems.
For example, we can say show only XFS and EXT four file systems that are mounted
to do that. We use the slash T command-line option.
For example, proc is a virtual file system located in the slash proc directory.
This file system does not exist on some storage
device somewhere only in the computer's random access memory.
In our situation,
we don't need to see all this virtual stuff so we
can tell fine mount to only show us real file systems.
For example, we can say show us only XFS and EXT four file systems that are mounted
to do that. We use the slash T type command-line option.
Now that looks much cleaner and it's easier to read.
An important note to make is that find mount
only shows us file systems that are currently mounted,
those that exist on some partition somewhere but are
not yet mounted won't show up in this output.
Note the options column here.
This is where find mount shows us the mount options. What are mount options?
It will be easier to understand if we look at the effects of these.
For example, we see slash DEV slash V db. One is mounted with an option called RW.
That means we can read and write to this file system.
We see that it's true since we can create a new file on it.
But what if we would use an option called RO instead of RW
that would make the file system read only.
We can mount a file system with specific options with
the dash O switch passed to the mount command.
For example, we can run a command like this.
And let's check our mounted file systems again,
we'll run fine mount
T with our file types
and we can see our mount option was applied
and now we can also test it. Let's try to create a file
as expected.
This action is denied since our file system is mounted in read only mode.
So we can draw the general conclusion that mount options
in a way,
tell the file system how to behave and
what rules it should follow while it's mounted.
Let's unmount
this
sometimes options like noexec and no S UI D are used to improve
security on the file systems that should not have programs on them.
For example,
these are used on Android phones in the storage area that should contain photos,
videos and similar data.
Now,
if we plug the phone into an infected computer and
a virus would try to replicate on the system,
it would have no effect.
The virus would only be able to write infected files but they'd
be saved on a noexec and no S UI D mountpoint.
That way they cannot execute or do any harm.
They're just a bunch of files sitting there doing nothing
to mount our file system.
With these options, we run the command you see on the screen,
these options should be separated only by commas without any spaces between them.
And once again, we can confirm our options were applied.
Now, let's say we want to write to this file system. We should change the RO
mount option to RW
if we try this,
it wouldn't work. Mount complains that this is already mounted,
but we can tell it to remount
the file system with the new options with a command like this.
Basically, we just threw remount in there as yet another mount option.
Now the options we used up until this point are called file system independent.
That's because they can be used on almost any file system.
Most of these mount options are described in the
manual of the mount command when you type in man
mount.
But other options are file system specific.
Some options only work on XFS, others only on EXT four and so on.
To see file system specific mount options.
We need to consult the manual of that file system.
For example, man XFS,
we can scroll down and reach the mount
options section where we can see these described.
For example, let's say we want to use the Alex size option described here.
Well, first unmount
dev VDB one since it's already mounted in our scenario
and it's not recommended to use mount dash
O remount.
In this case, with file system independent options, it's ok.
But with file system dependent options,
these might not be applied if the file system is already mounted.
So here's how we would use the Alex size option and set it to 32 kilobytes.
And remember to see file system specific mount options for ext four,
just type in man ext four.
Now up to this point, we mounted our file systems manually,
but let's remember that these can also be mounted automatically at boot time.
How do we apply mount options there?
Let's open up Etsy F
tab.
Remember how in a previous lesson,
we said we'll use the default mount options on this line.
Now, if we want to use custom options such as RO and noexec
that we explored earlier, we can rewrite the line like this.
If we save the file and reboot,
we can see our mount options were automatically applied at boot time.