1 00:00:06,584 --> 00:00:10,320 - In this video, I want to explain the concept of mount. 2 00:00:10,320 --> 00:00:13,230 So, there's this thing called the Linux directory structure. 3 00:00:13,230 --> 00:00:16,290 starts with the root directory and below the root directory 4 00:00:16,290 --> 00:00:21,290 you have your directories like boot and home and VAR 5 00:00:25,920 --> 00:00:27,570 and MNT. 6 00:00:27,570 --> 00:00:28,890 And so on. 7 00:00:28,890 --> 00:00:31,380 Now, the Linux directory structure is always the Linux 8 00:00:31,380 --> 00:00:32,310 directory structure. 9 00:00:32,310 --> 00:00:34,890 And it's independent of the devices that you are 10 00:00:34,890 --> 00:00:38,130 using inside the Linux directory structure. 11 00:00:38,130 --> 00:00:40,440 In order to use specific devices, 12 00:00:40,440 --> 00:00:44,040 you will mount the devices and by mounting the devices, 13 00:00:44,040 --> 00:00:47,370 you connect your device to a specific directory structure. 14 00:00:47,370 --> 00:00:51,570 So, if we would have a device with the name, Dev SDA1. 15 00:00:54,090 --> 00:00:57,060 Which is a typical name for the first partition on 16 00:00:57,060 --> 00:00:58,590 a hard drive. 17 00:00:58,590 --> 00:01:02,550 Then you can mount it, connect it to the root directory. 18 00:01:02,550 --> 00:01:04,890 And that means that anything that you write to 19 00:01:04,890 --> 00:01:08,010 files somewhere in the root directory, will be written 20 00:01:08,010 --> 00:01:09,840 to this dev SDA 1 . 21 00:01:09,840 --> 00:01:12,300 If you have a USB thumb drive and you want to 22 00:01:12,300 --> 00:01:14,130 access your USB thumb drive. 23 00:01:14,130 --> 00:01:17,190 You can connect that to the MNT directory. 24 00:01:17,190 --> 00:01:19,370 So, you would've a new device. 25 00:01:19,370 --> 00:01:22,640 Typically that will be slash dev slash SDB one. 26 00:01:22,640 --> 00:01:26,610 So, you mount your SDB one to the MNT directory. 27 00:01:26,610 --> 00:01:27,630 What is the result? 28 00:01:27,630 --> 00:01:30,870 The result is, if your right files to the MNT directory 29 00:01:30,870 --> 00:01:34,680 then really the files end up here on your SDB one device. 30 00:01:34,680 --> 00:01:38,040 And at the moment you, you mount you disconnect your 31 00:01:38,040 --> 00:01:40,920 SDB one device, the files that you've just written 32 00:01:40,920 --> 00:01:44,970 to it are gone, because the mount is no longer there. 33 00:01:44,970 --> 00:01:48,600 Mounts on Linux are pretty important, and you will notice 34 00:01:48,600 --> 00:01:51,720 that Linux is using different partitions. 35 00:01:51,720 --> 00:01:55,620 And these partitions are mounted on different directories. 36 00:01:55,620 --> 00:01:57,930 There are several reasons why you want to do that. 37 00:01:57,930 --> 00:01:59,193 I'll explain it later. 38 00:02:01,500 --> 00:02:02,520 All right. 39 00:02:02,520 --> 00:02:03,840 So, what have you just seen? 40 00:02:03,840 --> 00:02:08,310 Let me summarize. LSBK is a convenient command. 41 00:02:08,310 --> 00:02:11,610 It lists block devices in any mount starts 42 00:02:11,610 --> 00:02:15,240 with a block device that is connected to some directory. 43 00:02:15,240 --> 00:02:17,640 the Mount command is convenient as well. 44 00:02:17,640 --> 00:02:21,163 It lists all the current mounts, but in the Mount command 45 00:02:21,163 --> 00:02:26,163 you will see a lot of output that is unnecessary. 46 00:02:26,490 --> 00:02:29,280 Another way to see what is currently mounted is 47 00:02:29,280 --> 00:02:30,540 DF minus H. 48 00:02:30,540 --> 00:02:33,780 DF minus H, not only shows the mounted devices 49 00:02:33,780 --> 00:02:36,300 but it also includes available disc space. 50 00:02:36,300 --> 00:02:40,620 And finally there is find MNT which is just 51 00:02:40,620 --> 00:02:44,790 a nice representation of the output of the Mount command. 52 00:02:44,790 --> 00:02:47,373 Let me show you how to actually mount a device. 53 00:02:49,140 --> 00:02:50,730 So, in order to do this demo, 54 00:02:50,730 --> 00:02:54,933 I am going to mount USB thumb drive on my, on my laptop. 55 00:02:55,871 --> 00:02:58,871 (computer rustling) 56 00:03:03,220 --> 00:03:06,870 So, here we have my virtualization program kicking in 57 00:03:06,870 --> 00:03:09,450 and I know this is not a course about virtualization 58 00:03:09,450 --> 00:03:12,090 but you probably are using a virtual machine as well. 59 00:03:12,090 --> 00:03:15,000 And then your virtual machine might ask where 60 00:03:15,000 --> 00:03:16,320 you want to connect the device. 61 00:03:16,320 --> 00:03:18,630 Well, I want to connect it to my Centos stream 62 00:03:18,630 --> 00:03:19,653 virtual machine. 63 00:03:21,570 --> 00:03:24,120 And then we can continue on the Centos stream where 64 00:03:24,120 --> 00:03:27,693 I'm using LSBLK and LSBLK is showing me what? 65 00:03:27,693 --> 00:03:29,610 It's showing me nothing. 66 00:03:29,610 --> 00:03:31,410 So, it doesn't work. 67 00:03:31,410 --> 00:03:33,990 So, here in my virtualization software, 68 00:03:33,990 --> 00:03:37,230 I found this option to connect unknown manufacturer 69 00:03:37,230 --> 00:03:38,520 of flash disk. 70 00:03:38,520 --> 00:03:39,960 And that's exactly what we need. 71 00:03:39,960 --> 00:03:43,140 Sometimes the virtualization software requires you to 72 00:03:43,140 --> 00:03:44,790 do something in addition. 73 00:03:44,790 --> 00:03:47,060 And here we can see that the graphical user interface 74 00:03:47,060 --> 00:03:48,870 is automatically reacting. 75 00:03:48,870 --> 00:03:51,180 That's good, but this is not of course about gooey. 76 00:03:51,180 --> 00:03:52,350 So, let me click this away. 77 00:03:52,350 --> 00:03:53,700 And let's analyze. 78 00:03:53,700 --> 00:03:57,870 I'm typing LSBLK and LSBLK right now is showing 79 00:03:57,870 --> 00:04:00,841 that we have dev, a device with the name SDB. 80 00:04:00,841 --> 00:04:04,590 SDB is the name of the second disc device. 81 00:04:04,590 --> 00:04:07,560 Normally SDA is your first disc device. 82 00:04:07,560 --> 00:04:09,510 I will tell you more about devices later 83 00:04:09,510 --> 00:04:11,533 because the name of the device really depends 84 00:04:11,533 --> 00:04:14,040 on the hardware that you are using. 85 00:04:14,040 --> 00:04:16,773 Now, my graphical user interfaces automatically 86 00:04:16,773 --> 00:04:19,740 mounted the device for me, and guess what? 87 00:04:19,740 --> 00:04:20,760 I don't want that. 88 00:04:20,760 --> 00:04:24,453 So, I'm going to use Sudo umount dev SDB. 89 00:04:25,860 --> 00:04:30,390 Mounting from the command line requires sudo privileges. 90 00:04:30,390 --> 00:04:34,530 Next I'm going to use Sudo, Sudo mount dev SDB 91 00:04:34,530 --> 00:04:37,863 and I want to connect it to the slash MNT directory. 92 00:04:38,730 --> 00:04:39,780 So there we go. 93 00:04:39,780 --> 00:04:42,840 I'm connecting it to the slash MNT directory, by the way 94 00:04:42,840 --> 00:04:45,450 because according to the file system handling standard 95 00:04:45,450 --> 00:04:48,712 this is where you should mount all your temporary mounts. 96 00:04:48,712 --> 00:04:52,200 So, if I'm checking the contents of slash MNT, 97 00:04:52,200 --> 00:04:53,100 we can see. 98 00:04:53,100 --> 00:04:54,540 Wow, that's a lot of file. 99 00:04:54,540 --> 00:04:56,712 It's only one file but that doesn't matter. 100 00:04:56,712 --> 00:05:01,712 So, if I would copy ETC pass WD to slash MNT, 101 00:05:03,960 --> 00:05:07,260 I'm using LSMNT again, now we have two files. 102 00:05:07,260 --> 00:05:09,660 But this file, and that's the point I want to make here 103 00:05:09,660 --> 00:05:12,420 is really written to the USB thumb drive. 104 00:05:12,420 --> 00:05:16,770 And we will see that it disappears once we have unmounted 105 00:05:16,770 --> 00:05:20,430 but first, a couple of commands, LSBLK. 106 00:05:20,430 --> 00:05:23,880 I like using LSBLK, because it's a clean 107 00:05:23,880 --> 00:05:26,152 overview that is showing the device and where the 108 00:05:26,152 --> 00:05:27,720 device is mounted. 109 00:05:27,720 --> 00:05:30,270 It's only showing your block devices. 110 00:05:30,270 --> 00:05:32,820 In the past you will be using the Mount command 111 00:05:32,820 --> 00:05:35,760 but the Mount command, nowadays is showing a lot of 112 00:05:35,760 --> 00:05:38,430 administrative mounts as well. 113 00:05:38,430 --> 00:05:40,530 And it's true in the last line, we can see this 114 00:05:40,530 --> 00:05:43,920 dev SDB device but the problem is that you need to 115 00:05:43,920 --> 00:05:48,180 find it between MQ and huge TL, BFS, and trace FS, and 116 00:05:48,180 --> 00:05:52,635 many more Linux internal mounts that you don't care about. 117 00:05:52,635 --> 00:05:54,180 (clicking) 118 00:05:54,180 --> 00:05:57,267 Another command that's convenient is DF minus H. 119 00:05:57,267 --> 00:06:00,014 The DF stands for Disc Free and minus H is given 120 00:06:00,014 --> 00:06:03,090 a human readable format. 121 00:06:03,090 --> 00:06:04,770 Without a human readable format. 122 00:06:04,770 --> 00:06:06,000 It would look like this. 123 00:06:06,000 --> 00:06:07,530 It's showing the size in blocks 124 00:06:07,530 --> 00:06:08,864 and that's not very readable. 125 00:06:08,864 --> 00:06:12,030 Most people prefer the human readable format. 126 00:06:12,030 --> 00:06:15,345 And there we can see not only where the device is mounted 127 00:06:15,345 --> 00:06:20,100 but also size still available on that device. 128 00:06:20,100 --> 00:06:22,740 And finally, there is find MNT. 129 00:06:22,740 --> 00:06:25,590 find MNT is giving you this. 130 00:06:25,590 --> 00:06:30,360 It's a nicely formatted overview of the directories. 131 00:06:30,360 --> 00:06:33,750 So, it's really focusing on the directories and you 132 00:06:33,750 --> 00:06:36,270 will see where in the file system hierarchy. 133 00:06:36,270 --> 00:06:39,330 We have a directory that is mounted to somewhere else. 134 00:06:39,330 --> 00:06:42,240 So, we have boot that is mounted on SDA one. 135 00:06:42,240 --> 00:06:44,880 We have MNT that is mounted on SDB. 136 00:06:44,880 --> 00:06:48,030 We have proc that is mounted on the system device "Proc". 137 00:06:48,030 --> 00:06:51,810 And we have slash which is mounted on dev mapper CS root. 138 00:06:51,810 --> 00:06:55,050 Again, I will tell you more about the storage devices 139 00:06:55,050 --> 00:06:57,990 and how they work later in this course. 140 00:06:57,990 --> 00:07:01,590 But for now, at least, you know how to connect USB thumb 141 00:07:01,590 --> 00:07:02,423 drive. 142 00:07:02,423 --> 00:07:03,780 One more thing remaining. 143 00:07:03,780 --> 00:07:07,233 And that is Sudo umount slash MNT. 144 00:07:08,358 --> 00:07:12,690 Umount is what you need to do to disconnect the device. 145 00:07:12,690 --> 00:07:15,360 If you just pull it out 146 00:07:15,360 --> 00:07:18,193 then you risk losing data that has not yet been synchronized 147 00:07:18,193 --> 00:07:20,250 to the device. 148 00:07:20,250 --> 00:07:24,313 And if you use Umount then you synchronize everything to 149 00:07:24,313 --> 00:07:26,787 the device to make sure that it's really stored on 150 00:07:26,787 --> 00:07:27,900 the device. 151 00:07:27,900 --> 00:07:30,000 Now, I'm using LSMNT. 152 00:07:30,000 --> 00:07:33,930 And as you noticed, I don't see host or pass WD anymore. 153 00:07:33,930 --> 00:07:37,080 That is because the device at this point is disconnected. 154 00:07:37,080 --> 00:07:38,703 That's how you mount devices.