- So you can manually mount a file system
using the mount command, as we have seen.
But if you manually mount a file system,
it's not persistent.
So your reboot, it's gone.
And that is why you want to make them persistent.
And still, the default way to go is through /etc/fstab.
While booting, the /etc/fstab is processed
to persistently mount these file systems.
But on modern Linux distributions,
/etc/fstab is processed by systemd,
and systemd converts the mount in a systemd mount.
If during the boot procedure,
a file system specified in /etc/fstab
doesn't mount successfully,
typically a troubleshooting prompt is shown
where the error must be fixed manually before you can go on.
In /etc/fstab there are different fields.
The first field is mandatory, what to mount.
That is where you put your device.
Then where to mount,
that's a direction where you are going to mount it.
The filesystem type is going to be your EXT4, your XFS,
or whatever file system it is that you want to use.
These three options are the most important ones.
Because mount options are only used in specific cases,
you might just have defaults for default mount options,
nothing specific.
And the dump option and Fsck option,
these are kind of legacy,
just put them to zero, and that will always work.
Now let's create some persistent mounts in /etc/fstab.
Alright, let me edit /etc/fstab.
And in /etc/fstab,
I'm going to include dev/sdb1.
And this dev/sdb1, I want to mount it on,
let's say mydata.
So this was the EXT4 file system,
and I'm using defaults amount option in zero and zero,
and then we are good.
So I need to make sure that my data exists,
and then I'm going to reboot,
and we are going to check if this all works out well.
Now if the boot procedure is taking a while,
I suggest you press the escape key
so that you can see what is going on.
I can see that it is mounting boot,
it has just mounted boot,
and now it looks as if it is getting stuck.
Let's see what's happening.
Now, there we go.
This is what's happening.
You see what's wrong on the bottom line.
A start job is running for /dev/sdvb1.
Well, I can tell you, I don't have any devices sdvb1.
So this is systemd.
Systemd is giving a timeout on anything that is failing,
and its default timeout is one minute and 30 seconds,
and we just need to wait.
There's nothing that you can do to speed it up.
So now you can see that it has failed,
and it is continuing,
and, well, it is entering emergency mode.
That is because there's an error in /etc/fstab,
and the systemd cannot see
if the error is in a file system,
or if it's just a typo, or anything.
So we need human intervention here.
I'm entering the root password,
and, well, after entering the root password,
I'm in emergency mode.
Well, we already know what's going on.
Lsblk is listing the block devices.
We need sdb1,
and we have sdvb1.
That's an easy fix.
And in many cases where you see problems
that relate to /etc/fstab, it's an easy fix.
You can use control D to get out of there,
and then the default target will be started,
and everything should be booted all right.
(keys clicking)
So now we are back in the root cell,
and I want to verify that everything worked out alright.
Of course you can type the mount command,
but the mount command is a little bit hard to read.
Personally I like lsblk, list block devices,
where we can see that sdb1
is mounted on the partition mydata.
This is a pretty clean overview of what is mounted where.
Now, one advice.
If you just modified your /etc/fstab,
please just use mount -a.
Mount -a is going to try to mount everything
that is not yet mounted.
And if you made any error, mount -a will tell you.
Otherwise, just findmnt.
Findmnt is showing you all the mount points
and the devices that are associated to it.
And findmnt --verify
is what you can use to verify the syntax
of your /etc/fstab.
So use either one of these solutions
to avoid getting into a situation
where you need to do troubleshooting.