- So we have created a partition.
We have created a file system under partition.
Now we are ready to mount it.
By mounting a partition,
you will connect a partition to a directory
and while writing to a directory that contains
a mounted partition, rights are automatically
committed to the mounted device.
We have already seen that earlier
in this course where you have seen how
to mount a USB thumb drive
and for partitions on disc,
the procedure is not fundamentally different.
When a connected device is unmounted
you will, you won't see the files that are written anymore
because they are not accessible through
the directory anymore.
And notice that mounting is also required
for devices like DVD or CD-ROM.
Now how do we manage mounts?
Well, you use mount to mount device
as in mount slash dev slash SDB one and slash MNT.
Slash MNT is defined in the file system hierarchy standard
as generic directory to connect your partitions
for temporary mounts.
If you want to make the mounts permanent
then you should mount them on a different directory.
But MNT is good enough for what I want to demonstrate here.
Now once you are done with your mount,
you use U mount,
U mount will disconnect the mount device
as in U mount slash MNT.
If, while U mounting the message device is busy appears,
You can use LSOF to find
out which processes are keeping the device busy.
And to verify current mounts,
you can use couple of commands,
like mount and LSBLK and DF minus H
and find MNT, let me show you.
So, we have already created these file systems, right?
So I'm just going to use sudo mount dev SDB one
and slash
MNT.
And that doesn't seem to be very problematic.
So,
let me do,
sudo LS slash MNT.
And what do we see?
We see a lost and found directory.
If you create EXT file systems, then you also
you always get a lost and found directory,
that is in case problems on the file systems have occurred
and your operating system tries to fix these problems
automatically.
Now, let me use sudo CP ATC hosts
to slash MNT and repeat this LS command.
And yeah, we have the hosts, the host file,
and now let me get into the directory
and we even can see it without root permissions.
And now I'm using sudo U mount on dev SDB one,
and oh no, I'm getting target is busy.
Why do I get a target is busy?
Well, in case you don't know, you can use LSOF
for list open files,
LSOF is showing all processes
that currently have files open
and these are bash and LSOF
and you know why?
That is because I'm in the directory.
If I'm using CD to get out of there
and I'm using LSOF again,
then you can see nothing is happening
in this directory anymore.
But if there are files open in a directory
that you want to U mount, that is not going to be possible.
So this is how you work with mounts.
Now, the big question is, is this persistent?
Does it come back after the reboot?
I have a disappointing message for you.
And the answer is no, but you can easily make it persistent
by putting it in ETC FSTAB.
I'll tell you about that in the next video.