WEBVTT

1
00:00.000 --> 00:05.040
So friends, now that we know how to format a file system on our devices using

2
00:05.040 --> 00:05.840
Ansible,

3
00:05.840 --> 00:10.400
what we now want to do is to be able to access that data on those file systems.

4
00:10.400 --> 00:15.280
The key point here to do this is to ensure that we actually mount that file

5
00:15.280 --> 00:15.840
system.

6
00:15.840 --> 00:19.700
So with that said, let's talk about some of the key concepts behind file

7
00:19.700 --> 00:20.320
mounting.

8
00:20.320 --> 00:24.960
So one of the cool things about Linux is as you happen to traverse across

9
00:24.960 --> 00:26.400
different directories,

10
00:26.400 --> 00:31.420
you can actually be transparently moving across different devices on the system
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

10
00:26.400 --> 00:31.420
you can actually be transparently moving across different devices on the system

11
00:31.420 --> 00:31.600
.

12
00:31.600 --> 00:36.160
What do I mean when I say that? I'll say for example, we have a disk right here

13
00:36.160 --> 00:36.400
.

14
00:36.400 --> 00:41.280
And let's maybe add a second disk right here. I know I know my artistic skills

15
00:41.280 --> 00:42.240
are not quite so

16
00:42.240 --> 00:46.710
good, but nevertheless, let's imagine these are two hard disks. Okay. So let's

17
00:46.710 --> 00:47.600
imagine that we go

18
00:47.600 --> 00:52.080
into the home directory, you know, just by typing the command cdhome. And let's

19
00:52.080 --> 00:52.880
say for example,

20
00:52.880 --> 00:57.800
we're actually accessing data on this disk right here. Now we don't have to

21
00:57.800 --> 00:58.720
worry about how this

22
00:58.720 --> 01:02.240
disk is actually partitioned, whatever it may be. Let's just look at this at a
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

22
00:58.720 --> 01:02.240
disk is actually partitioned, whatever it may be. Let's just look at this at a

23
01:02.240 --> 01:03.120
high level. We're

24
01:03.120 --> 01:08.030
accessing this particular disk. Now, what if we then type the command, well, I

25
01:08.030 --> 01:08.320
don't know,

26
01:08.320 --> 01:13.520
let's go with cd/bin. Now it is completely plausible that we will still be

27
01:13.520 --> 01:15.200
accessing information on

28
01:15.200 --> 01:19.920
the same disk depending on how the device is configured. However, what might

29
01:19.920 --> 01:21.280
actually happen

30
01:21.280 --> 01:24.560
is well, you just see a change on the command line. You know, you're no longer

31
01:24.560 --> 01:25.280
in the home directory

32
01:25.280 --> 01:30.000
or in the bin directory. You could potentially be accessing an entirely
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

33
01:30.000 --> 01:31.760
different disk completely.

34
01:31.760 --> 01:36.000
Now the way this is actually made possible, it's all down to how these

35
01:36.000 --> 01:38.000
partitions happen to be

36
01:38.000 --> 01:42.470
mounted. Pretty much when you have a partition that has been formatted, you can

37
01:42.470 --> 01:43.840
specify a particular

38
01:43.840 --> 01:48.620
mount point where you want that particular file system to be accessible from.

39
01:48.620 --> 01:49.680
Now realistically,

40
01:49.680 --> 01:55.030
this is what I want to talk about in this particular video. So one of my

41
01:55.030 --> 01:56.400
favorite commands in order

42
01:56.400 --> 02:01.790
to determine whether or not a device happens to be mounted is to use the
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

42
01:56.400 --> 02:01.790
to determine whether or not a device happens to be mounted is to use the

43
02:01.790 --> 02:03.200
command lsblk-f.

44
02:03.200 --> 02:07.370
So what we actually see here is we see the name of the device as well as the

45
02:07.370 --> 02:08.480
file system type.

46
02:08.480 --> 02:12.890
We get information relating to its label as your ID as well as how much of the

47
02:12.890 --> 02:13.520
file system is

48
02:13.520 --> 02:18.040
available and how much of it is actually in use. Now more crucially though,

49
02:18.040 --> 02:18.960
relevant to what we

50
02:18.960 --> 02:23.410
are talking about is on the very right hand side, we have this option here,

51
02:23.410 --> 02:24.800
mount points. This tells

52
02:24.800 --> 02:28.430
us where that particular partition happened to be mounted, i.e. where it

53
02:28.430 --> 02:29.840
happens to be accessible.

54
02:29.840 --> 02:33.980
Check this out right here. Take for example, my XFS file system right here, my
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

54
02:29.840 --> 02:33.980
Check this out right here. Take for example, my XFS file system right here, my

55
02:33.980 --> 02:35.280
main file system.

56
02:35.280 --> 02:39.430
This happened to be mounted in the root directory. Whereas we also happen to

57
02:39.430 --> 02:41.200
have a separate partition,

58
02:41.200 --> 02:46.020
which is again, XFS base, but this is going to be my boot partition and it's

59
02:46.020 --> 02:47.600
actually on a separate

60
02:47.600 --> 02:50.570
partition, you see that. Now this is not the only command we can use to see

61
02:50.570 --> 02:51.280
such information.

62
02:51.280 --> 02:54.520
We can also type the command mount and that is going to give us all the

63
02:54.520 --> 02:55.280
information

64
02:55.280 --> 02:59.080
about these mounted devices. And if I wanted to perhaps be great for a

65
02:59.080 --> 02:59.840
particular piece of

66
02:59.840 --> 03:04.020
information, I could say grep nvm e. Check this out right here, we have two
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

66
02:59.840 --> 03:04.020
information, I could say grep nvm e. Check this out right here, we have two

67
03:04.020 --> 03:05.200
entries. Here is the

68
03:05.200 --> 03:09.120
first one and we can see the device is disc number one. This is partition

69
03:09.120 --> 03:10.240
number two and this is

70
03:10.240 --> 03:15.070
mounted on the boot directory. We can see the type is XFS and then we also have

71
03:15.070 --> 03:15.920
some information

72
03:15.920 --> 03:19.840
about the disk itself. It happens to be read rateable as well as a whole bunch

73
03:19.840 --> 03:21.200
of other information.

74
03:21.200 --> 03:26.200
Similarly, we also have this partition right here, n1p1, this is disc1

75
03:26.200 --> 03:27.280
partition 1,

76
03:27.280 --> 03:32.650
this is mounted on boot efi and it is formatted with a type vfat. Now this
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

76
03:27.280 --> 03:32.650
this is mounted on boot efi and it is formatted with a type vfat. Now this

77
03:32.650 --> 03:33.520
command doesn't just

78
03:33.520 --> 03:37.970
show me what type of mounts we have configured. We can also use this command to

79
03:37.970 --> 03:38.880
actually mount

80
03:38.880 --> 03:43.280
a particular file system. So let me go to one of my devices right here. Let's

81
03:43.280 --> 03:44.640
go into the yellow

82
03:44.640 --> 03:51.040
box right now. If I do an ls blk - if we can see here, we actually have this

83
03:51.040 --> 03:51.920
new disk which I have

84
03:51.920 --> 03:57.090
created the n2 disk. It has been formatted with the ext4 file system, but look

85
03:57.090 --> 03:57.840
at the right hand

86
03:57.840 --> 04:01.460
side, we do not have a mount point. That means we cannot access any data that
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

86
03:57.840 --> 04:01.460
side, we do not have a mount point. That means we cannot access any data that

87
04:01.460 --> 04:02.640
might be potentially

88
04:02.640 --> 04:07.000
written on this particular partition, nor can we actually write any new data to

89
04:07.000 --> 04:08.000
it. So let's say

90
04:08.000 --> 04:12.610
I wanted to actually create a mount point. What I actually want to do is I want

91
04:12.610 --> 04:13.680
to make sure that I

92
04:13.680 --> 04:19.040
have an existing directory that says very, very important. And ideally, we

93
04:19.040 --> 04:20.480
really want that directory

94
04:20.480 --> 04:24.730
to be empty. Now there is a reason for this. Let me show you why. Let's say for

95
04:24.730 --> 04:25.520
example, I happen

96
04:25.520 --> 04:29.200
to create this directory here called, I don't know, let's call this test there.

97
04:29.200 --> 04:30.640
Okay. Now inside of
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

97
04:29.200 --> 04:30.640
Okay. Now inside of

98
04:30.640 --> 04:34.910
tester, if I happen to create a file, let's just call this important dot txt

99
04:34.910 --> 04:35.840
and I just go into

100
04:35.840 --> 04:40.930
insert mode and say this is some really important file. Okay, so let's imagine

101
04:40.930 --> 04:41.920
this is some really

102
04:41.920 --> 04:47.340
important data inside this file. Check this out. If I happen to try to mount a

103
04:47.340 --> 04:48.960
particular file system,

104
04:48.960 --> 04:53.370
so I say pseudo mount, I will say dash t to specify the type of the file system

105
04:53.370 --> 04:53.920
. And in fact,

106
04:53.920 --> 04:58.320
let me just double check if I don't LSB okay dash f we can see we have an ext4

107
04:58.320 --> 04:58.880
based file

108
04:58.880 --> 05:03.890
system for this particular device right here, the n2. If I say pseudo mount
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

108
04:58.880 --> 05:03.890
system for this particular device right here, the n2. If I say pseudo mount

109
05:03.890 --> 05:06.400
dash t ext4, and then I

110
05:06.400 --> 05:12.550
target the actual device which is nvme 0n2. And I specify that I want to mount

111
05:12.550 --> 05:14.000
it in the test

112
05:14.000 --> 05:19.600
directory. If I enter, I type in my super user password. And now if I do an LS,

113
05:19.600 --> 05:20.800
if I go into the

114
05:20.800 --> 05:26.070
tester directory and list it, what do you notice? Do you see that the important

115
05:26.070 --> 05:26.800
text file is

116
05:26.800 --> 05:31.310
suddenly inaccessible? So pretty much when we mount into a directory that
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

116
05:26.800 --> 05:31.310
suddenly inaccessible? So pretty much when we mount into a directory that

117
05:31.310 --> 05:33.040
already has a file in it,

118
05:33.040 --> 05:36.610
the existing contents within that directory are going to be inaccessible. But

119
05:36.610 --> 05:37.840
if I do an LSBLK

120
05:37.840 --> 05:43.200
dash, if we do see indeed that this particular file system has been mounted in

121
05:43.200 --> 05:44.480
this particular

122
05:44.480 --> 05:47.920
directory structure. Now if I want to unmount that, I can say pseudo you mount

123
05:47.920 --> 05:49.120
and then specify the

124
05:49.120 --> 05:52.960
name of the mount point of ISO wish, which is in my case here tester. So I'll

125
05:52.960 --> 05:54.400
just hit enter. Now

126
05:54.400 --> 05:58.790
we are unmounted if I list the information once again, now we are no longer

127
05:58.790 --> 06:00.240
mounted. Now notice if
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

127
05:58.790 --> 06:00.240
mounted. Now notice if

128
06:00.240 --> 06:04.110
I try to mount and a directory which is not already created, let's just see a

129
06:04.110 --> 06:07.120
targeted device nvme 0n2

130
06:07.120 --> 06:10.230
once again. And let's maybe say I wanted to mount it and in all the directory,

131
06:10.230 --> 06:11.200
let's call this

132
06:11.200 --> 06:15.130
test.dirtu, which doesn't actually exist. If I hit enter, it just says here

133
06:15.130 --> 06:15.840
that the mount

134
06:15.840 --> 06:20.240
point does not exist. So make sure that it does exist. And ideally, like I say,

135
06:20.240 --> 06:20.880
if I just create

136
06:20.880 --> 06:25.770
it and I make sure it's empty, if I now try to remount to an LSBLK dash, if I

137
06:25.770 --> 06:26.960
have mounted in

138
06:26.960 --> 06:30.870
this particular directory and if I so wish now what I can do, I can go into t
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

138
06:26.960 --> 06:30.870
this particular directory and if I so wish now what I can do, I can go into t

139
06:30.870 --> 06:32.400
ester to the vim

140
06:32.400 --> 06:39.320
file 1.txt, going to insert mode and just say now I can write data to this. So

141
06:39.320 --> 06:39.920
if I just write

142
06:39.920 --> 06:44.460
and quit, if I can't file check this out right here, we have successfully

143
06:44.460 --> 06:46.480
written to the partition

144
06:46.480 --> 06:51.160
which has been formatted with the ext4 file system because the data is now

145
06:51.160 --> 06:52.240
accessible via

146
06:52.240 --> 06:56.120
its mount point right here. So this is the process that we want to be able to

147
06:56.120 --> 06:57.840
automate using Ansible.

148
06:57.840 --> 07:01.590
So how about we check out one of the modules that we can use in order to
WEBVTT
X-TIMESTAMP-MAP=LOCAL:00:00:00.000,MPEGTS:900000

148
06:57.840 --> 07:01.590
So how about we check out one of the modules that we can use in order to

149
07:01.590 --> 07:03.600
perform this particular task.
