1
00:00:00,000 --> 00:00:14,640
Hey guys and welcome back.

2
00:00:14,640 --> 00:00:20,440
So in this skill right here we're going to be focusing on the Linux file system and we

3
00:00:20,440 --> 00:00:26,199
will focus that tension around the basic operations of the Linux file system.

4
00:00:26,199 --> 00:00:31,519
So the first thing we will talk about is how the Linux file system is actually structured

5
00:00:31,519 --> 00:00:37,079
its basic architecture and then we will talk about being able to mount particular file

6
00:00:37,079 --> 00:00:38,920
systems on our system.

7
00:00:38,920 --> 00:00:43,560
So there are two different ways that we can actually mount our system we can mount it

8
00:00:43,560 --> 00:00:49,280
in a manual way whereby we have to go in via the CLI and type in some particular commands

9
00:00:49,280 --> 00:00:54,480
and specify what it is we are looking to mount and where the mount point should be.

10
00:00:54,479 --> 00:00:59,359
We will cover that within this skill right here but we will also talk about how we can

11
00:00:59,359 --> 00:01:06,879
automatically do this process and also what we're going to cover is dealing with swap

12
00:01:06,879 --> 00:01:10,439
space very very important with the management of our system.

13
00:01:10,439 --> 00:01:14,679
So a lot of cool things to get to within this skill right here the very first thing I want

14
00:01:14,679 --> 00:01:20,319
to talk to you about is that Linux file system how about we roll up our sleeves and get going

15
00:01:20,319 --> 00:01:21,319
then.

16
00:01:22,079 --> 00:01:28,839
When we are talking about a file system what is it we actually mean here this might be

17
00:01:28,839 --> 00:01:33,879
a quite esoteric term if you haven't really dug in and explored it.

18
00:01:33,879 --> 00:01:38,919
Now we have two different branches of file system that we can have the very first one

19
00:01:38,919 --> 00:01:46,319
is a physical file system and the second type happens to be a virtual file system.

20
00:01:46,319 --> 00:01:50,319
So what do we mean when we talk about a physical file system.

21
00:01:50,319 --> 00:01:57,239
Now a physical file system are really just used to store data and organize that data

22
00:01:57,239 --> 00:02:02,839
on a device so that may be something like say for example a RAID device now we actually

23
00:02:02,839 --> 00:02:09,479
haven't really dived into RAID quite just yet but we use RAID as a form of redundancy

24
00:02:09,479 --> 00:02:11,919
within our system administration.

25
00:02:11,919 --> 00:02:17,639
However it doesn't have to be a RAID device it could be a particular partition on a device

26
00:02:17,639 --> 00:02:24,759
and more but when we are talking about a virtual file system how in earth does that actually

27
00:02:24,759 --> 00:02:25,759
differ.

28
00:02:25,759 --> 00:02:30,879
Well really when we are talking about a virtual file system what we are talking about are

29
00:02:30,879 --> 00:02:36,759
what the end users actually interact with when they happen to be using the particular

30
00:02:36,759 --> 00:02:43,519
operating system so that if you happen to go in via the CLI and we do an LS and we go

31
00:02:43,520 --> 00:02:49,640
into a directory and you access a particular file what we are actually doing here is working

32
00:02:49,640 --> 00:02:51,800
with the virtual file system.

33
00:02:51,800 --> 00:02:58,840
Now the reality is the virtual file system itself is actually utilizing physical file

34
00:02:58,840 --> 00:03:04,000
systems so the virtual file system is how we are actually interfacing with the system

35
00:03:04,000 --> 00:03:08,960
but it will be pulling information from real live devices real partitions you know say

36
00:03:08,960 --> 00:03:14,800
for example this could be disc 1 which is a hard disk and then maybe an SSD here as

37
00:03:14,800 --> 00:03:21,879
well we are pulling from these physical file systems and presenting it to the user via

38
00:03:21,879 --> 00:03:26,360
the virtual file system where they can actually interact with this information.

39
00:03:26,360 --> 00:03:32,480
Now here is the thing what we actually do is we ultimately carve up our system and we

40
00:03:32,480 --> 00:03:37,800
carve it up into different partitions so this might be one partition this might be a second

41
00:03:37,800 --> 00:03:44,840
partition so on and so forth but one thing we have to do is we have to put a file system

42
00:03:44,840 --> 00:03:45,840
onto the partition.

43
00:03:45,840 --> 00:03:51,000
Now we do have some different file systems that we can actually put onto a partition

44
00:03:51,000 --> 00:03:55,800
and we will mention what they are very very shortly but understand right now we have a

45
00:03:55,800 --> 00:04:01,320
disk we can carve it up into partitions and we want to put file systems onto that partition.

46
00:04:01,319 --> 00:04:08,759
Now here is the rub just by simply carving up a disk like so and putting a file system

47
00:04:08,759 --> 00:04:16,000
onto a partition it does not mean the end user can actually access that file system if

48
00:04:16,000 --> 00:04:22,279
we want to be able to access a particular file system we have to mount it and once we actually

49
00:04:22,279 --> 00:04:27,639
mount the file system that will present that file system to the end user so that they can

50
00:04:27,639 --> 00:04:34,519
actually interact with that file system otherwise it just is like I say inaccessible.

51
00:04:34,519 --> 00:04:40,120
Now this is what I am talking about when I am referencing the physical file system and

52
00:04:40,120 --> 00:04:46,879
the virtual file system with respect to Linux we have what we know is a directory tree structure

53
00:04:46,879 --> 00:04:52,279
so if I go to the root directory if I happen to type the command tree we are going to see

54
00:04:52,279 --> 00:04:55,519
a very very massive tree like structure.

55
00:04:55,519 --> 00:05:00,560
This presents way too much information if I just limit the output here just so we only

56
00:05:00,560 --> 00:05:06,879
go to folders down and to enter if I scroll on up you can actually see the relationship

57
00:05:06,879 --> 00:05:12,000
going on at the very top of the tree we have this root directory and within that we have

58
00:05:12,000 --> 00:05:17,039
the bin directory and the boot directory and then the cd rom and you know within these

59
00:05:17,039 --> 00:05:23,159
directories there are files and further directories this is the directory tree we are talking about

60
00:05:23,200 --> 00:05:29,000
so when we want to mount a particular file system we want to mount it somewhere within

61
00:05:29,000 --> 00:05:34,439
this directory tree like structure so you know as we saw there we could have our root

62
00:05:34,439 --> 00:05:41,600
directory right here and then branching off we may have say for example the boot directory

63
00:05:41,600 --> 00:05:47,760
and at the same level we may have you know like to say the dev directory so on so forth.

64
00:05:47,759 --> 00:05:54,480
Now the reality is the way this actually works is that different disks are mounted at different

65
00:05:54,480 --> 00:06:00,159
points in the directory structure so right here in my situation right here at the root

66
00:06:00,159 --> 00:06:08,560
directory we have sda5 so this is the first disk and it's partition number five that

67
00:06:08,560 --> 00:06:15,159
is actually accessible when I go to the root directory however when I switch and go to

68
00:06:15,160 --> 00:06:22,439
the boot directory I'm actually accessing sda1 so I'm accessing the same disk but I'm

69
00:06:22,439 --> 00:06:27,360
actually accessing a completely different partition so think about this okay we have

70
00:06:27,360 --> 00:06:33,680
this disk here disk1 okay but it is partitions so when I'm in the root directory I'm actually

71
00:06:33,680 --> 00:06:39,480
accessing this big portion of the disk this large chunk here okay all this part here however

72
00:06:39,600 --> 00:06:45,000
just by simply typing the command cdboot I move into the boot directory and that is

73
00:06:45,000 --> 00:06:50,840
actually mounted within a different partition so think about what is actually happening

74
00:06:50,840 --> 00:06:56,640
just by me typing the command cd I'm working through the virtual file system but under

75
00:06:56,640 --> 00:07:01,840
the hood I'm actually accessing different partitions or it may even be different disks

76
00:07:01,840 --> 00:07:08,080
entirely however I choose to mount a particular file system it could be from a hard disk and

77
00:07:08,079 --> 00:07:14,599
then I cd into another directory and now suddenly I may be transparently accessing a solid state

78
00:07:14,599 --> 00:07:21,599
drive so this really is what is happening when we are utilizing our virtual file system it allows

79
00:07:21,599 --> 00:07:27,599
us to easily move around transparently so like I say I go into the root directory I do an LS

80
00:07:27,599 --> 00:07:34,879
right now I'm accessing partition five I go into cdboot suddenly I'm now accessing partition

81
00:07:35,040 --> 00:07:42,159
number one but to you as the end user it is presented to you as the virtual file system and

82
00:07:42,159 --> 00:07:47,120
all of this switching around between physical devices happens really without your knowledge

83
00:07:47,120 --> 00:07:52,800
behind the curtain under the hood now if you happen to be using maybe say a windows device you

84
00:07:52,800 --> 00:07:59,279
might notice things are a little bit more explicit you can see here we have clearly delineated disks

85
00:07:59,679 --> 00:08:05,039
c and we could go in and browse through that disk or we could go into disk d which is another

86
00:08:05,039 --> 00:08:10,879
disk entirely and then browse files within that but it's much more explicit when we happen to use

87
00:08:10,879 --> 00:08:16,479
the linux file system you could just be changing directory quickly and be flipping through disks

88
00:08:16,479 --> 00:08:22,799
without ever really knowing about it so one thing I would say is that when we want to mount a

89
00:08:22,879 --> 00:08:29,360
particular file system it is very important that we mount this within a directory within the

90
00:08:29,360 --> 00:08:36,080
directory tree structure and we want that directory to be empty now the reason why is this and it's

91
00:08:36,080 --> 00:08:41,759
not because you can't mount into a directory which does have particular files or further

92
00:08:41,759 --> 00:08:46,960
directories further sub directories should I say it's just that if you happen to mount into a

93
00:08:46,960 --> 00:08:53,920
directory which already has files and folders those files and folders will suddenly become

94
00:08:53,920 --> 00:09:00,080
inaccessible not that they're deleted or anything like that it just means that while the file system

95
00:09:00,080 --> 00:09:05,040
happens to be mounted in that directory you're not going to be able to access anything within that

96
00:09:05,040 --> 00:09:10,480
that existed prior so imagine if you happen to have some important files some critical files

97
00:09:10,480 --> 00:09:15,920
and you mount a file system into that very same directory those critical files you're not going

98
00:09:16,000 --> 00:09:21,919
to be able to touch them until you unmount that file system so really it's not an enforced rule it

99
00:09:21,919 --> 00:09:27,439
just really is something that you want to self impose for your own best practice so think about

100
00:09:27,439 --> 00:09:34,639
this as I say we have the root directory and then we could have you know the boot directory and you

101
00:09:34,639 --> 00:09:41,199
will know that I have a home directory you know cd home and within my home directory I have a folder

102
00:09:41,280 --> 00:09:48,879
under my username called ipv0 and within this directory here if I so chose I could just use

103
00:09:48,879 --> 00:09:55,360
the command mkdir to create a new directory maybe just call this backup and make it an empty directory

104
00:09:55,360 --> 00:10:02,960
and what I could do I could have another disk and mount that disk within this directory right here

105
00:10:02,960 --> 00:10:11,360
so this may be bsdb partition one whereas the root directory that would be sda partition five

106
00:10:11,360 --> 00:10:18,320
and the boot directory is going to be sda partition one so that means if we go to our root

107
00:10:18,320 --> 00:10:24,480
directory we are on the first disk partition five if we go down to our home directory we're still on

108
00:10:24,480 --> 00:10:30,879
disk one partition five same again if we go into the ip0 folder but if we happen to go into this

109
00:10:30,960 --> 00:10:36,159
newly created backup directory suddenly and transparently we would be reading from an

110
00:10:36,159 --> 00:10:42,960
entirely separate disk and the first partition of that disk however if we go back out to ipv0 we

111
00:10:42,960 --> 00:10:49,840
once again are on sda five but if we go into the boot directory we would be on the same disk again

112
00:10:49,840 --> 00:10:56,080
sda one i.e the first disk but we would now be switching to that first partition so I really

113
00:10:56,080 --> 00:11:01,360
really really just want that process to be very very clear because very often people tend to get

114
00:11:01,360 --> 00:11:06,400
a little bit confused when first presented with this information but once you get it you absolutely

115
00:11:06,400 --> 00:11:12,080
get it and it does make sense and stick that is the good news so I did say we would have a word

116
00:11:12,080 --> 00:11:19,360
about the file systems that are in play what type of file system can we actually utilize with respect

117
00:11:19,360 --> 00:11:25,280
to linux now we will actually mention these file systems in a little bit more detail later on

118
00:11:25,279 --> 00:11:31,120
within this very course but I do just want to give you a brief summary so we have the file system

119
00:11:31,120 --> 00:11:39,120
ex t2 this is based on the extended file system the original one ex t but this was an improvement

120
00:11:39,120 --> 00:11:43,839
okay and again we'll talk about what those improvements are a little bit later on within

121
00:11:43,839 --> 00:11:53,039
this course next we had ex t3 again an improvement over its predecessor ex t2 and this allowed a

122
00:11:53,039 --> 00:11:59,439
type of logging feature known as journaling why that is important again we will certainly see that

123
00:11:59,439 --> 00:12:07,519
very very shortly then we have ex t4 this again provided the benefits of ex t3 i.e we still get

124
00:12:07,519 --> 00:12:13,199
journaling but it provides other features very important features such as allowing for much

125
00:12:13,199 --> 00:12:20,959
larger file systems and this one happens to be a very common file system used in modern linux systems

126
00:12:20,960 --> 00:12:30,080
now moving on from the ex t file systems we also have the xfs file system this one is all about

127
00:12:30,080 --> 00:12:36,720
high performance that really was the design goal of this file system and it does live up to its

128
00:12:36,720 --> 00:12:44,560
promise next we have what is called the btrfs this again is all about size and this was designed

129
00:12:44,639 --> 00:12:52,879
to deal with very very large data devices so large large large and like i say we do have even

130
00:12:52,879 --> 00:12:58,159
more file systems to explore later on now i just wanted to mention the different types of file

131
00:12:58,159 --> 00:13:04,239
system because right now in order to demonstrate the mounting and unmounting of our file systems

132
00:13:04,239 --> 00:13:10,719
as we move throughout this very skill what i want to do is to actually add another disk entirely

133
00:13:10,720 --> 00:13:15,920
now you can actually do this on different types of virtual machines vmware if you so choose

134
00:13:15,920 --> 00:13:21,840
i happen to have a virtual box device or a virtual box instance should i say so i'm just going to

135
00:13:21,840 --> 00:13:27,519
add that right now so what i'll do here is i'll just minimize this and i'll open up virtual box

136
00:13:27,519 --> 00:13:32,000
in fact before i do anything what i'm going to do is i'll shut down my machine forgetting the

137
00:13:32,000 --> 00:13:37,519
sudo command that has always type in the passwords okay so that should be shutting down the machine

138
00:13:37,519 --> 00:13:42,639
what i will do is i'll go to my virtual box machine right now and i'm going to click the

139
00:13:42,639 --> 00:13:49,279
settings button okay now if i go to storage and i choose sata what i'm going to do is to click

140
00:13:49,279 --> 00:13:55,600
this icon here add new storage attachment if i click this i'm going to choose a hard disk now

141
00:13:55,600 --> 00:14:01,199
what i'll do here is i'll just click create right now and i'll choose next here i'll make it a

142
00:14:01,199 --> 00:14:07,360
dynamically allocated hard disk i'll just make the size maybe just say i don't know like one gig

143
00:14:07,360 --> 00:14:12,080
or something like that doesn't really matter the size so much and i will create this now what i will

144
00:14:12,080 --> 00:14:18,080
do is i'll scroll on down i will select this option right here vdi we can actually see the size right

145
00:14:18,080 --> 00:14:25,120
here and i will click choose so now i've actually added a second disk so what i will do now is i'll

146
00:14:25,120 --> 00:14:30,720
click okay and then i'll turn back on my machine so i'll click start right here and the machine is

147
00:14:30,720 --> 00:14:37,360
just powering on okay so i'll go in and open up a terminal right here so if i go in to my dev

148
00:14:37,360 --> 00:14:44,480
directory right now and i do an ls in fact let me just grep for sd and remember the grep command

149
00:14:44,480 --> 00:14:50,080
john there we go so what we can now see here is because i've added this second disk i don't just

150
00:14:50,080 --> 00:14:58,000
have sda1 which has these different partitions i have this new one here sdb this is the second

151
00:14:58,000 --> 00:15:03,759
disk i've just added now what i want to do here is i actually want to give this disk a partition

152
00:15:03,759 --> 00:15:10,159
because right now it's just sdb no partitions available now the command i can use to give this

153
00:15:10,159 --> 00:15:17,200
disk a partition is fdisk so what i will do here is i'll just say sudo fdisk and i'll do dash l for

154
00:15:17,200 --> 00:15:23,759
a list type in my passwords and we can see here like i say the very first disk right here it has

155
00:15:23,759 --> 00:15:31,279
partitions this one here no partitions at all as of yet so the name is sdb and this is what we're

156
00:15:31,279 --> 00:15:38,879
going to use we're going to say sudo fdisk and i'll say dev sdb so if i hit enter here notice it says

157
00:15:38,879 --> 00:15:44,879
we have to type a particular command now the command i can use is the m command for help so i'll say

158
00:15:44,879 --> 00:15:50,319
m and then enter and if we scroll on down or rather scroll on up we can see these different options

159
00:15:50,320 --> 00:15:56,720
here so if i do l we can actually see the partition types so i can say l here hit enter so the partition

160
00:15:56,720 --> 00:16:02,480
type i would like would be 83 which would be for linux so what i'll do is i'll say m for help again

161
00:16:02,480 --> 00:16:08,960
if i say n this will allow me to create a new partition so i'll say n right here the type of

162
00:16:08,960 --> 00:16:14,960
partition i want i will have a primary partition i'll say p and hit enter the partition number if

163
00:16:15,040 --> 00:16:20,639
i have the default one that means we will have sdb one the first partition so i'll just say one

164
00:16:20,639 --> 00:16:26,960
and to enter the first sector 2048 leave it at default the last sector again leave at the default

165
00:16:26,960 --> 00:16:33,840
now it is auto detected the type as linux and it's going to be the entire size of the disk 1.2 gig

166
00:16:33,840 --> 00:16:38,960
now if i actually want to keep these changes and write them so that they do take effect what i need

167
00:16:38,960 --> 00:16:44,720
to do is to say w because as we see here this is going to allow us to write the table to disk and exit

168
00:16:44,720 --> 00:16:51,759
so that's exactly what i'll do so now the partition has been created if i do sudo fdisk dash l notice

169
00:16:51,759 --> 00:16:57,279
now we have a little number on the end sdb one we now have a partition and now that we have a

170
00:16:57,279 --> 00:17:02,960
partition we want to give this partition a file system now like i say i'm not going to go into

171
00:17:02,960 --> 00:17:08,240
too much detail in this command right now we'll talk about file systems in more detail but we did

172
00:17:08,319 --> 00:17:15,120
see that we have a file system called ext4 and i'm going to use this command to make a file system

173
00:17:15,120 --> 00:17:22,880
using ext4 so i'll say mkfs.ext4 and then i'll just target the partition so it's in the dev

174
00:17:22,880 --> 00:17:29,200
directory it's going to be sdb which is my new disk and partition number one that is the partition

175
00:17:29,200 --> 00:17:36,240
we want to put this file system onto so if i enter now now we should have a file system here if i do

176
00:17:36,240 --> 00:17:45,440
my fdisk dash l we have a partition we have the type of linux and we are ready to use this partition

177
00:17:45,440 --> 00:17:51,440
with this file system and we can begin practicing the mounting and unmounting of this partition

178
00:17:51,440 --> 00:17:57,039
in different locations within our virtual file system so that was a lot to get to in the opening

179
00:17:57,039 --> 00:18:02,640
of this skill the next thing we're going to be tackling is manually mounting this new partition

180
00:18:02,640 --> 00:18:06,560
or this new file system using the mount command and that's what we're going to be doing in the

181
00:18:06,560 --> 00:18:18,560
very next nuggets i hope it's been informative for you and i'd like to thank you for viewing

