1
00:00:00,000 --> 00:00:18,679
Hey guys and welcome back. So in the previous nugget we had discussed the virtual file system

2
00:00:18,679 --> 00:00:23,559
and at the very end of this nugget, or the end of that nugget should I say, what we did

3
00:00:23,559 --> 00:00:28,859
was we added a new disk, we partitioned that disk and we actually formatted it with a particular

4
00:00:28,859 --> 00:00:34,619
file system. Like I say within this nugget right here we're going to be able to use this newly

5
00:00:34,619 --> 00:00:42,140
created partition and begin practicing how we can manually mount and unmount that file system.

6
00:00:42,140 --> 00:00:48,780
So the process that I want to walk you through is going to be related to these commands. Now the

7
00:00:48,780 --> 00:00:54,620
first command I will discuss will be that very first one, the mount command and you can guess

8
00:00:54,699 --> 00:01:00,299
what this one is going to do. What it's going to do is going to mount a file system but it's also

9
00:01:00,299 --> 00:01:06,859
going to show you if you just type the command on its own what file systems are currently mounted.

10
00:01:06,859 --> 00:01:14,140
So it's not just used to make changes i.e. to mount a new file system, this command can also show you

11
00:01:14,140 --> 00:01:20,299
what is already mounted on the system as well as the corresponding mount options. So let me actually

12
00:01:20,619 --> 00:01:25,819
just run this command right now, I'll just say the command mount because on its own it's going to

13
00:01:25,819 --> 00:01:32,299
just simply list the mounted devices. We can see we have a whole bunch of information here. Now let

14
00:01:32,299 --> 00:01:40,780
me just grep for sd, okay in fact let me just grep for sda so I will clear the screen and do sda

15
00:01:40,780 --> 00:01:46,780
just so we get a little smaller output so it's easier to focus in on. Now here is the format

16
00:01:46,780 --> 00:01:54,859
of this output here, we see right here the device in this case here dev sda1 the first partition

17
00:01:54,859 --> 00:02:01,260
disk one or the one at the top sda5. So that is the first piece of the syntax we're going to see,

18
00:02:01,260 --> 00:02:07,500
we're going to see the device and then we're going to see the keywords on okay so it doesn't matter

19
00:02:07,500 --> 00:02:14,539
what we're going to be looking at. The device might change sda1 sda5 but this one here on is going to

20
00:02:14,539 --> 00:02:21,340
remain the same and I just completely obscured that with my bad drawing on okay. Then what we're

21
00:02:21,340 --> 00:02:29,579
going to see is the mount point, this is whereabouts in the virtual file system that this device happens

22
00:02:29,579 --> 00:02:35,899
to be mounted. So if you look at the very top line here and let me just make my pen a little bit

23
00:02:35,899 --> 00:02:41,259
narrower just so I'm not smudging things up so much notice the first value here you see this

24
00:02:41,259 --> 00:02:46,620
it just happens to be that forward slash. Now this might be a little bit obscure to you right now

25
00:02:46,620 --> 00:02:52,859
but it actually just means here this is mounted at this directory here we know that happens to be

26
00:02:52,859 --> 00:02:59,739
the root directory you know if I happen to go onto my command line and I say cd forward slash and I

27
00:02:59,739 --> 00:03:05,659
do an ls this is at the root of the tree so let me just go back and I'll reissue my command and then

28
00:03:05,659 --> 00:03:11,659
we're going to see the keyword type again this is always going to be present so we see it right here

29
00:03:11,659 --> 00:03:16,939
and we also see it right here in the one below and what the type is going to show us it's going to

30
00:03:16,939 --> 00:03:23,579
show us the file system type. Now we did talk about some of the file systems that we can actually see

31
00:03:23,579 --> 00:03:33,019
you mentioned things like ext2 ext3 the top one right here the file system type is ext4 and then

32
00:03:33,020 --> 00:03:38,540
after this what we're going to see within the brackets we can see right here these are known

33
00:03:38,540 --> 00:03:44,620
as the mounts options I happen to mention so in this case here we have these different mount options

34
00:03:44,620 --> 00:03:49,580
what it's saying here is that this is read write meaning that when the system is mounted the disk

35
00:03:49,580 --> 00:03:54,620
is going to be readable and writable i.e. you can read from the disk and you can maybe create new

36
00:03:54,620 --> 00:04:00,939
files on this disk because it is writable if there happens to be an error though what is going to

37
00:04:00,939 --> 00:04:08,219
happen is we're going to try to remount this file system but in read only mode now there are a whole

38
00:04:08,219 --> 00:04:12,939
bunch of different mount options it's going to be or rather should I say it's going to take

39
00:04:12,939 --> 00:04:17,019
far too long to cover all of them and you don't have to know all of them in any great depth but

40
00:04:17,019 --> 00:04:21,579
just understand the basic format of what we're seeing here so if we look at the bottom one here

41
00:04:21,579 --> 00:04:28,220
we see the device we see the keyword on we see the mount point so in this case here it's in the

42
00:04:28,220 --> 00:04:34,220
boot directory and within the boot directory it's bootefi to be exact actually so it's not just

43
00:04:34,220 --> 00:04:41,100
boot it's actually in this directory here if we go into this directory we would be accessing sda1

44
00:04:41,100 --> 00:04:47,580
now the type of file system mounted here is one called vfat we didn't actually mention this one

45
00:04:47,580 --> 00:04:51,900
quite just yet again we'll talk about more file systems in a little bit more detail later on

46
00:04:51,899 --> 00:04:58,939
within this course and then just like we saw before within the brackets we have a whole bunch

47
00:04:58,939 --> 00:05:05,659
of different mount options that really is the type of format so even if I actually remove the grip

48
00:05:05,659 --> 00:05:10,859
filter here and just show you the mount look at the format what you see here just take any old one

49
00:05:10,859 --> 00:05:18,459
here we see the device we see the keywords on we see where it is mounted we see the type and in

50
00:05:18,459 --> 00:05:24,299
the brackets we see the mount options this is the same for every piece of output we can see here if

51
00:05:24,299 --> 00:05:29,579
you scroll on up exact same everywhere so that really is the format you can expect when you just

52
00:05:29,579 --> 00:05:35,740
issue the mount command on its own now here is a very important topic that we really must talk

53
00:05:35,740 --> 00:05:42,620
about here so when we actually issue the mount command as we know it's showing us what happens to

54
00:05:42,620 --> 00:05:48,220
be mounted now here is a question how on earth is the mount command getting this information

55
00:05:48,220 --> 00:05:53,819
does it just know it inherently or is it pulling this information from a particular file well the

56
00:05:53,819 --> 00:05:59,420
answer is it is indeed pulling that information because all of that information we're talking about

57
00:05:59,420 --> 00:06:05,019
is stored in a particular location and this is a location we definitely want to be remembering this

58
00:06:05,019 --> 00:06:12,859
is in the etsy directory and the file is called m tab I like to remember this as the table where

59
00:06:12,859 --> 00:06:21,180
everything is mounted m tab now whenever a file system is mounted this file right here is updated

60
00:06:21,180 --> 00:06:28,939
and whenever a file system likewise is unmounted once again this is updated so when we issue this

61
00:06:29,019 --> 00:06:35,339
mount command and we get this output we're really just pulling information from this file which is

62
00:06:35,339 --> 00:06:41,339
very frequently updated or I really shouldn't say frequently updated which is updated as soon as

63
00:06:41,339 --> 00:06:46,459
something is mounted or unmounted so it really just depends how much things have been unmounted

64
00:06:46,459 --> 00:06:53,019
and mounted now let's actually have a look at this particular file so if we go into the etsy

65
00:06:53,019 --> 00:06:59,099
directory and I happen to do an ls you can actually see we have m tab right here let me just do an ls

66
00:06:59,099 --> 00:07:05,659
dash l and scroll on up now you may notice if you have a keen eye the color here is a little bit

67
00:07:05,659 --> 00:07:12,379
different and we actually have an l at the very end here this means that m tab right here is a sim

68
00:07:12,379 --> 00:07:19,579
link it's actually pointing to this particular file right here so if I happen to just say cat m tab

69
00:07:19,659 --> 00:07:25,819
notice this is very close just a slight formatting difference to the output we get with respect to

70
00:07:25,819 --> 00:07:31,579
the mount command okay again if we happen to look at say for example this one right here we see the

71
00:07:31,579 --> 00:07:38,860
device we see the mount point we see the type and we also see the mount options again formatted a

72
00:07:38,860 --> 00:07:44,620
little bit differently we're not going to see the keyword on the keyword type or the brackets around

73
00:07:44,699 --> 00:07:50,060
the mount point but it really is the same information now if we happen to go into the proc

74
00:07:50,060 --> 00:07:57,899
directory and I do an ls dash l we're also going to see this other sim link mounts that also points

75
00:07:57,899 --> 00:08:03,579
to self mounts you see that so we can cat mounts or in fact let me just give it the full name so it's

76
00:08:03,579 --> 00:08:09,500
a little bit more clear so we cat this file we can see our mount information once again so really

77
00:08:09,500 --> 00:08:15,579
for the purposes of the examination we want to be remembering that within it say m tab we can get

78
00:08:15,579 --> 00:08:23,259
mount information as well as from proc forward slash mounts these two locations and we can also get

79
00:08:23,259 --> 00:08:29,819
mount information directly via the mount command now one thing to just be aware of here because

80
00:08:29,819 --> 00:08:34,539
this might be a little bit of a gotcha when you happen to use the mount command you can actually

81
00:08:34,620 --> 00:08:39,899
specify a particular option it's dash n in fact let me just show you here in the man page I say

82
00:08:39,899 --> 00:08:48,939
man mounts figure down to the n flag we can see here we can use dash n or dash dash no m tab what

83
00:08:48,939 --> 00:08:56,620
this means is that we can actually mount something without actually updating it say m tab so just be

84
00:08:56,620 --> 00:09:03,259
aware of this when we happen to use the mount command it is actually possible if someone explicitly

85
00:09:03,340 --> 00:09:09,819
instructs the mount command to do so to not actually update this particular file so just be aware

86
00:09:09,819 --> 00:09:17,100
what we see within this file that is a possibility for it to be outdated and again this might be

87
00:09:17,100 --> 00:09:22,700
when the etsy is a read-only file system that means you actually cannot write within the etsy

88
00:09:22,700 --> 00:09:28,539
directory therefore you cannot update this particular file if you still want to be able to mount

89
00:09:28,539 --> 00:09:34,299
something even though you can't write within this directory you could use this particular flag so

90
00:09:34,299 --> 00:09:41,419
just be aware that that is a possibility now let's get back to the unmounting of a particular file

91
00:09:41,419 --> 00:09:47,339
now one thing I just want to say directly off the bat because this is a point of confusion very often

92
00:09:48,139 --> 00:09:54,620
is that the temptation absolutely is to think to use this command here now when I say this command

93
00:09:54,620 --> 00:10:02,220
I am kind of talking rubbish because this is not a command there is no unmount command the command

94
00:10:02,220 --> 00:10:07,659
is called you mounts and like I say this can so easily trip people up in the examination you might

95
00:10:07,659 --> 00:10:13,659
be presented with the syntax of unmounts just drill this into your head that this is not a command

96
00:10:13,659 --> 00:10:19,580
we want to be using the you mount command the you mount command will unmount something it's just not

97
00:10:19,580 --> 00:10:25,900
called unmount okay now let's briefly talk about the you mount command now with respect to the you

98
00:10:25,900 --> 00:10:31,500
mount command it is quite easy to use but you do actually have two different ways you can use this

99
00:10:31,500 --> 00:10:38,540
command what you can do is once you have a particular file system mounted you can unmount it by saying

100
00:10:38,540 --> 00:10:45,100
you mount of course and the first option would just be to specify the device you want to unmount

101
00:10:45,100 --> 00:10:52,620
so let's maybe say forward slash dev forward slash sdb one if that happened to be mounted which right

102
00:10:52,620 --> 00:11:00,139
now it is not so we could do this specifying the device or depending on where that device was mounted

103
00:11:00,139 --> 00:11:06,940
let's say it was mounted in a directory called backups within the home ipv0 directory I could

104
00:11:06,940 --> 00:11:15,580
just see you mount and then the directory home ipv0 and then backups the two different ways to

105
00:11:15,580 --> 00:11:21,020
unmount either the device we're trying to unmount or the location of where it is currently mounted

106
00:11:21,020 --> 00:11:27,340
either or will work no problem at all so let's actually see some of this in action then shall we

107
00:11:27,340 --> 00:11:35,100
now how do we actually see what is mounted and where about the mount point is well we actually do have

108
00:11:35,100 --> 00:11:41,420
this very useful command this is one you would want to be remembering this is the lsblk command

109
00:11:41,420 --> 00:11:48,540
this is going to allow it to list our block devices okay now if I happen to use the dash f flag or dash

110
00:11:48,540 --> 00:11:54,300
dash fs this is also going to give us information about the file system so I can press q and what

111
00:11:54,300 --> 00:12:02,139
I can do is I can say lsblk dash f check this out right here this is the output we have so we can see

112
00:12:02,139 --> 00:12:09,100
at the very top we have our first disk sda and we have three different partitions right here on this

113
00:12:09,100 --> 00:12:17,179
we have sda1 the file type or the file system type should I say is vfat we see the unique or rather

114
00:12:17,179 --> 00:12:23,500
the universally unique identifier we can see the size how much is in use as well as very crucially

115
00:12:23,500 --> 00:12:31,100
the mount point like I say if I happen to go into cd boot efi that means transparently we're going

116
00:12:31,100 --> 00:12:37,340
to be accessing the first partition on this disk now we also have sda5 which would be our first

117
00:12:37,340 --> 00:12:46,060
logical partition the file system type is ext4 we can see the uuid right here as well as the

118
00:12:46,060 --> 00:12:52,460
available size how much is in use and notice like I say this is the mount point right here

119
00:12:52,460 --> 00:12:58,860
in fact let me just redraw that with my squinty line this one right here so the roots file system

120
00:12:58,940 --> 00:13:06,060
if we go there we are accessing this partition but notice we have sdb this is the disk I created

121
00:13:06,060 --> 00:13:14,700
and partitioned and happened to format with the as we can see here ext4 file system whereabouts

122
00:13:14,700 --> 00:13:20,860
is this mounted well in fact as we can see here it is not mounted this command right here can give

123
00:13:20,860 --> 00:13:26,300
us that information where something is mounted or not mounted now like I say we could if we want we

124
00:13:26,299 --> 00:13:34,859
could use the mount command and we could grip for sd and try to fish out sdb we can see sda sda1

125
00:13:34,859 --> 00:13:42,379
sda5 but no sdb me myself I happen to find this output a little bit cleaner so now what I want to

126
00:13:42,379 --> 00:13:49,179
do is to actually mount this particular file system so some things we have to actually specify here

127
00:13:49,179 --> 00:13:53,979
so if I just clear the screen and if I go into the mount command I would tell if I could type this

128
00:13:53,980 --> 00:14:00,460
correctly so have a scroll on down and keep on scrolling there's a lot on this page this is an

129
00:14:00,460 --> 00:14:06,139
important flag we want to use the t flag or the dash dash types and then we specify the file system

130
00:14:06,139 --> 00:14:15,180
type so we know from the lsblk command the file system type for this particular device is ext4

131
00:14:15,180 --> 00:14:20,620
we want to be using that information with the t flag so what I will do here and we want to be using

132
00:14:20,620 --> 00:14:25,899
super user privileges by the way is you want to say subtle mounts and then the dash t flag and then

133
00:14:25,899 --> 00:14:33,820
say ext4 that is the file system type now what we want to do is to specify what device do we want

134
00:14:33,820 --> 00:14:41,259
to mount I will say dev and it's going to be sdb1 and now what I want to do is to give it a mount

135
00:14:41,259 --> 00:14:47,100
point whereabouts do I want to mount this particular device so what I'm going to do right now just

136
00:14:47,100 --> 00:14:51,659
by before I issue this command as I will go in to say for example in fact let me just check where

137
00:14:51,659 --> 00:14:56,940
I am I'm in the home directory here home ipv0 I will make a directory called backups since I've been

138
00:14:56,940 --> 00:15:04,060
using that in all of my examples I'll go into this and we can see this is an empty directory so I see

139
00:15:04,060 --> 00:15:12,300
the go back out I will say subtle mounts dash t ext4 the device is dev sdb1 and the location where

140
00:15:12,299 --> 00:15:20,139
I want to mount this is going to be in home ipv0 and then the backups directory that I've just

141
00:15:20,139 --> 00:15:26,459
created if I hit enter now I'm going to have to type in my super user password and it seems

142
00:15:26,459 --> 00:15:35,179
everything is a okay nothing really major has happened but if I do my ls blk command dash f notice

143
00:15:35,179 --> 00:15:41,419
we have some different outputs here we have information relating to sdb1 we can see the size

144
00:15:41,500 --> 00:15:47,179
which is available which is one gig how much has been used nothing has been used but more importantly

145
00:15:47,179 --> 00:15:54,459
whereabouts this is mounted we are in or rather mounted in home ipv0 backups like I say right now

146
00:15:55,019 --> 00:16:02,459
I am currently on sda5 because I'm working within the root directory if I go in to home ipv0 and then

147
00:16:02,459 --> 00:16:10,139
into the backups directory and I happen to create a file called file dot txt I do an ls what I've

148
00:16:10,139 --> 00:16:17,259
actually done is I have ultimately written a file on a different disk on disk 2 partition 1

149
00:16:17,259 --> 00:16:23,740
you see that and if I go back out I'm now no longer on that disk transparent it doesn't affect our

150
00:16:23,740 --> 00:16:30,220
experience as the system administrator and like I say if we happen to use the mount command now

151
00:16:30,220 --> 00:16:36,860
we can see at the very bottom here that indeed mounted we have sdb1 we see the mount points

152
00:16:36,860 --> 00:16:43,580
we see the type and in brackets we see the mount options similarly if we happen to go into xam tab

153
00:16:43,580 --> 00:16:49,899
within this one right here same information this is also being updated so like I say if we want to

154
00:16:49,899 --> 00:16:56,460
unmount this so there is no longer an action we can say sudo you mount in fact let me just show you

155
00:16:56,460 --> 00:17:01,820
this output one more time remember we have two options we can unmount this by giving the name

156
00:17:01,820 --> 00:17:06,860
of the device which would be sdb1 or we can specify the location of where it is mounted

157
00:17:06,860 --> 00:17:16,220
the mount point so I can say sudo you mount dev sdb1 hit enter and notice if I do an lsblk-f

158
00:17:16,220 --> 00:17:22,460
this is suddenly unmounted and again if I happen to just arrow up I will remount this one more time

159
00:17:22,460 --> 00:17:30,460
do an lsblk-f we have mounted it once again alternatively as opposed to specifying the actual

160
00:17:30,460 --> 00:17:37,420
device I can just say sudo you mount and give the mount points to home ipv0 and backups if I

161
00:17:37,420 --> 00:17:43,980
hit enter same type of deal I can do an lsblk suddenly we have unmounted that file system

162
00:17:43,980 --> 00:17:49,180
so one thing you'll notice is that what I did is I specified the name of the device as well as where

163
00:17:49,180 --> 00:17:56,220
I want to mount it what I can also do is just specify the uuid so if I actually just copy this

164
00:17:56,220 --> 00:18:02,940
value right here as opposed to saying dev sdb1 so I just copy this what I will do is I'll mount it

165
00:18:02,940 --> 00:18:10,620
using its uuid so I'll say sudo mounts and now I won't have to specify the file system type using

166
00:18:10,620 --> 00:18:18,380
that dash t flag I can just say dash uppercase u paste in the uuid and then specify whereabouts I

167
00:18:18,380 --> 00:18:25,980
want to mount this so I can say home ipv0 and then once again in the backups directory if I hit

168
00:18:25,980 --> 00:18:32,779
enter that should now be mounted I'll do an lsblk dash f and we can see successfully just by using

169
00:18:32,779 --> 00:18:40,140
the uuid I did not have to specify the file system type or the device the uuid will pull that information

170
00:18:40,140 --> 00:18:45,740
in automatically now one thing I just want to demonstrate I'll just unmount this device no

171
00:18:45,740 --> 00:18:51,500
longer mounted if I happen to create a new directory let's just call this new dir and I cd into here

172
00:18:51,579 --> 00:18:56,859
and what I'll do is I'll create some files in here I'll just say nano my importance file dot

173
00:18:56,859 --> 00:19:05,019
dxd and just say this is some super important and vital information guess I'll save you okay so

174
00:19:05,019 --> 00:19:10,940
within this directory right here we have this very important file now what would happen if I try to

175
00:19:10,940 --> 00:19:19,339
mount a file system into this directory so if I try to mounts I'll say dash t ext4 and I'll mount

176
00:19:19,339 --> 00:19:28,059
sdb1 and the location is going to be in home ipv0 and into this directory which is not empty notice

177
00:19:28,059 --> 00:19:35,339
if I do an lsblk dash f it does mount successfully but watch what happens if I go into this directory

178
00:19:35,339 --> 00:19:43,339
I do an ls where is this important file it's actually gone if I go into my super user and I go

179
00:19:43,339 --> 00:19:49,019
into lost and found nothing in here either so that important file with that really really important

180
00:19:49,019 --> 00:19:54,059
information is no longer accessible to me now really the crucial point I want to show you

181
00:19:54,059 --> 00:20:01,180
is going to lead us into our next video notice we have our file system mounted in this mount

182
00:20:01,180 --> 00:20:07,579
point right here what would happen if I reboot the system so now I've lost my connection my virtual

183
00:20:07,579 --> 00:20:13,180
machine is rebooting just give it a moment okay so I've logged back in I'm now going to check my

184
00:20:13,180 --> 00:20:20,620
mount points once again do an lsblk dash f and look at this you'll notice if you're following along

185
00:20:20,620 --> 00:20:27,740
you should have the exact same issue suddenly just by rebooting the system the changes we made

186
00:20:27,740 --> 00:20:35,259
i.e the mounting of this particular partition right here it is no longer mounted that means

187
00:20:35,259 --> 00:20:40,539
that the changes are not persistent and this is one of the gotchas that you have to be aware of

188
00:20:40,539 --> 00:20:45,099
when just using the mount command on its own so how on earth are we going to solve this problem

189
00:20:45,099 --> 00:20:49,740
so that we can make these changes persistent well that's what we're going to be talking about in the

190
00:20:49,740 --> 00:20:56,460
very next nuggets I hope this has been informative for you and I'd like to thank you for viewing

