Okay, in the previous video we created a file system. Now we need to mount it.
So what is the purpose of a mount?
By mounting a partition, it's connected to a directory and while writing to a
directory that contains a mounted permission, writes are automatically committed to the mounted device.
When the connected device is unmounted, you won't see the valves that are written anymore.
Now you should note that mounting is also required for accessing valves on devices like
USB thumb drives or optical drives. We have seen that in an earlier lesson already.
I am going to show you now how we can manually mount devices.
In the next video you will see how devices can be mounted in a persistent way.
To mount a device, you use the mount command. First the
name of the device, then the name of the directory.
In this example you can see mnt, that's a directory that you typically use for
temporary mounts. For persistent mounts, you probably want to give the device its own directory.
If ever you need to disconnect a device, you use umount to disconnect. So
umount mnt. For instance, if while unmounting the message device is busy appears, you
can use LSOF to find out which processes are keeping the device busy.
We have already seen that you can use the mount command to verify current mounts, but that's giving a lot of information.
As an alternative, you can use lsblk or DF h or findmnt, all
of which are showing information about mounted devices. Let me show you.
First, I want to test that the mount is working right.
I'm going to use sudo mount dev nvme0n2p4 on mnt.
Now I can use mount and as I know that it's giving a lot of output, I'm
grabbing for N2 P4 and there we can see that the disk device has been mounted.
And what does that mean? That means that if I go into the mount directory and I use touch
file, then oh boy, I'm getting permission denies. Yeah, of course I need sudo touch file to write the
file and if I want to unmount, then I'm using sudo umount umount and not unmount of mnt.
And oh my goodness, I'm getting target is busy here. It's for obvious reasons I'm in
it. But if I would use sudo lsof on mnt, then we get a list of
all processes that are currently active in the mount. Point to U mount it anyway.
Either you disable all of these processes or you change the current working directory. In this case.
Now if I do my u mount again.
It is successful.
That is how you manually manage mounts from the command line.