- In this video, I want to explain the concept of mount.
So, there's this thing called the Linux directory structure.
starts with the root directory and below the root directory
you have your directories like boot and home and VAR
and MNT.
And so on.
Now, the Linux directory structure is always the Linux
directory structure.
And it's independent of the devices that you are
using inside the Linux directory structure.
In order to use specific devices,
you will mount the devices and by mounting the devices,
you connect your device to a specific directory structure.
So, if we would have a device with the name, Dev SDA1.
Which is a typical name for the first partition on
a hard drive.
Then you can mount it, connect it to the root directory.
And that means that anything that you write to
files somewhere in the root directory, will be written
to this dev SDA 1 .
If you have a USB thumb drive and you want to
access your USB thumb drive.
You can connect that to the MNT directory.
So, you would've a new device.
Typically that will be slash dev slash SDB one.
So, you mount your SDB one to the MNT directory.
What is the result?
The result is, if your right files to the MNT directory
then really the files end up here on your SDB one device.
And at the moment you, you mount you disconnect your
SDB one device, the files that you've just written
to it are gone, because the mount is no longer there.
Mounts on Linux are pretty important, and you will notice
that Linux is using different partitions.
And these partitions are mounted on different directories.
There are several reasons why you want to do that.
I'll explain it later.
All right.
So, what have you just seen?
Let me summarize. LSBK is a convenient command.
It lists block devices in any mount starts
with a block device that is connected to some directory.
the Mount command is convenient as well.
It lists all the current mounts, but in the Mount command
you will see a lot of output that is unnecessary.
Another way to see what is currently mounted is
DF minus H.
DF minus H, not only shows the mounted devices
but it also includes available disc space.
And finally there is find MNT which is just
a nice representation of the output of the Mount command.
Let me show you how to actually mount a device.
So, in order to do this demo,
I am going to mount USB thumb drive on my, on my laptop.
(computer rustling)
So, here we have my virtualization program kicking in
and I know this is not a course about virtualization
but you probably are using a virtual machine as well.
And then your virtual machine might ask where
you want to connect the device.
Well, I want to connect it to my Centos stream
virtual machine.
And then we can continue on the Centos stream where
I'm using LSBLK and LSBLK is showing me what?
It's showing me nothing.
So, it doesn't work.
So, here in my virtualization software,
I found this option to connect unknown manufacturer
of flash disk.
And that's exactly what we need.
Sometimes the virtualization software requires you to
do something in addition.
And here we can see that the graphical user interface
is automatically reacting.
That's good, but this is not of course about gooey.
So, let me click this away.
And let's analyze.
I'm typing LSBLK and LSBLK right now is showing
that we have dev, a device with the name SDB.
SDB is the name of the second disc device.
Normally SDA is your first disc device.
I will tell you more about devices later
because the name of the device really depends
on the hardware that you are using.
Now, my graphical user interfaces automatically
mounted the device for me, and guess what?
I don't want that.
So, I'm going to use Sudo umount dev SDB.
Mounting from the command line requires sudo privileges.
Next I'm going to use Sudo, Sudo mount dev SDB
and I want to connect it to the slash MNT directory.
So there we go.
I'm connecting it to the slash MNT directory, by the way
because according to the file system handling standard
this is where you should mount all your temporary mounts.
So, if I'm checking the contents of slash MNT,
we can see.
Wow, that's a lot of file.
It's only one file but that doesn't matter.
So, if I would copy ETC pass WD to slash MNT,
I'm using LSMNT again, now we have two files.
But this file, and that's the point I want to make here
is really written to the USB thumb drive.
And we will see that it disappears once we have unmounted
but first, a couple of commands, LSBLK.
I like using LSBLK, because it's a clean
overview that is showing the device and where the
device is mounted.
It's only showing your block devices.
In the past you will be using the Mount command
but the Mount command, nowadays is showing a lot of
administrative mounts as well.
And it's true in the last line, we can see this
dev SDB device but the problem is that you need to
find it between MQ and huge TL, BFS, and trace FS, and
many more Linux internal mounts that you don't care about.
(clicking)
Another command that's convenient is DF minus H.
The DF stands for Disc Free and minus H is given
a human readable format.
Without a human readable format.
It would look like this.
It's showing the size in blocks
and that's not very readable.
Most people prefer the human readable format.
And there we can see not only where the device is mounted
but also size still available on that device.
And finally, there is find MNT.
find MNT is giving you this.
It's a nicely formatted overview of the directories.
So, it's really focusing on the directories and you
will see where in the file system hierarchy.
We have a directory that is mounted to somewhere else.
So, we have boot that is mounted on SDA one.
We have MNT that is mounted on SDB.
We have proc that is mounted on the system device "Proc".
And we have slash which is mounted on dev mapper CS root.
Again, I will tell you more about the storage devices
and how they work later in this course.
But for now, at least, you know how to connect USB thumb
drive.
One more thing remaining.
And that is Sudo umount slash MNT.
Umount is what you need to do to disconnect the device.
If you just pull it out
then you risk losing data that has not yet been synchronized
to the device.
And if you use Umount then you synchronize everything to
the device to make sure that it's really stored on
the device.
Now, I'm using LSMNT.
And as you noticed, I don't see host or pass WD anymore.
That is because the device at this point is disconnected.
That's how you mount devices.