1 00:00:07,019 --> 00:00:11,470 Okay, in the previous video we created a file system. Now we need to mount it. 2 00:00:12,490 --> 00:00:14,089 So what is the purpose of a mount? 3 00:00:15,449 --> 00:00:20,449 By mounting a partition, it's connected to a directory and while writing to a 4 00:00:20,449 --> 00:00:25,449 directory that contains a mounted permission, writes are automatically committed to the mounted device. 5 00:00:26,579 --> 00:00:31,519 When the connected device is unmounted, you won't see the valves that are written anymore. 6 00:00:32,600 --> 00:00:38,390 Now you should note that mounting is also required for accessing valves on devices like 7 00:00:38,390 --> 00:00:44,179 USB thumb drives or optical drives. We have seen that in an earlier lesson already. 8 00:00:44,939 --> 00:00:48,030 I am going to show you now how we can manually mount devices. 9 00:00:48,549 --> 00:00:52,859 In the next video you will see how devices can be mounted in a persistent way. 10 00:00:54,719 --> 00:00:58,659 To mount a device, you use the mount command. First the 11 00:00:58,659 --> 00:01:02,599 name of the device, then the name of the directory. 12 00:01:04,700 --> 00:01:10,079 In this example you can see mnt, that's a directory that you typically use for 13 00:01:10,079 --> 00:01:15,459 temporary mounts. For persistent mounts, you probably want to give the device its own directory. 14 00:01:16,760 --> 00:01:22,109 If ever you need to disconnect a device, you use umount to disconnect. So 15 00:01:22,109 --> 00:01:27,459 umount mnt. For instance, if while unmounting the message device is busy appears, you 16 00:01:27,460 --> 00:01:32,810 can use LSOF to find out which processes are keeping the device busy. 17 00:01:33,890 --> 00:01:40,349 We have already seen that you can use the mount command to verify current mounts, but that's giving a lot of information. 18 00:01:41,209 --> 00:01:46,280 As an alternative, you can use lsblk or DF h or findmnt, all 19 00:01:46,280 --> 00:01:51,349 of which are showing information about mounted devices. Let me show you. 20 00:01:52,989 --> 00:01:55,450 First, I want to test that the mount is working right. 21 00:01:55,969 --> 00:02:00,680 I'm going to use sudo mount dev nvme0n2p4 on mnt. 22 00:02:06,650 --> 00:02:12,430 Now I can use mount and as I know that it's giving a lot of output, I'm 23 00:02:12,430 --> 00:02:18,210 grabbing for N2 P4 and there we can see that the disk device has been mounted. 24 00:02:19,280 --> 00:02:26,173 And what does that mean? That means that if I go into the mount directory and I use touch 25 00:02:26,173 --> 00:02:33,066 file, then oh boy, I'm getting permission denies. Yeah, of course I need sudo touch file to write the 26 00:02:33,066 --> 00:02:39,960 file and if I want to unmount, then I'm using sudo umount umount and not unmount of mnt. 27 00:02:40,590 --> 00:02:46,823 And oh my goodness, I'm getting target is busy here. It's for obvious reasons I'm in 28 00:02:46,823 --> 00:02:53,056 it. But if I would use sudo lsof on mnt, then we get a list of 29 00:02:53,056 --> 00:02:59,289 all processes that are currently active in the mount. Point to U mount it anyway. 30 00:02:59,990 --> 00:03:05,669 Either you disable all of these processes or you change the current working directory. In this case. 31 00:03:07,090 --> 00:03:08,669 Now if I do my u mount again. 32 00:03:09,509 --> 00:03:10,569 It is successful. 33 00:03:11,150 --> 00:03:14,580 That is how you manually manage mounts from the command line.