Hey guys and welcome back.
So in this skill right here we're going to be focusing on the Linux file system and we
will focus that tension around the basic operations of the Linux file system.
So the first thing we will talk about is how the Linux file system is actually structured
its basic architecture and then we will talk about being able to mount particular file
systems on our system.
So there are two different ways that we can actually mount our system we can mount it
in a manual way whereby we have to go in via the CLI and type in some particular commands
and specify what it is we are looking to mount and where the mount point should be.
We will cover that within this skill right here but we will also talk about how we can
automatically do this process and also what we're going to cover is dealing with swap
space very very important with the management of our system.
So a lot of cool things to get to within this skill right here the very first thing I want
to talk to you about is that Linux file system how about we roll up our sleeves and get going
then.
When we are talking about a file system what is it we actually mean here this might be
a quite esoteric term if you haven't really dug in and explored it.
Now we have two different branches of file system that we can have the very first one
is a physical file system and the second type happens to be a virtual file system.
So what do we mean when we talk about a physical file system.
Now a physical file system are really just used to store data and organize that data
on a device so that may be something like say for example a RAID device now we actually
haven't really dived into RAID quite just yet but we use RAID as a form of redundancy
within our system administration.
However it doesn't have to be a RAID device it could be a particular partition on a device
and more but when we are talking about a virtual file system how in earth does that actually
differ.
Well really when we are talking about a virtual file system what we are talking about are
what the end users actually interact with when they happen to be using the particular
operating system so that if you happen to go in via the CLI and we do an LS and we go
into a directory and you access a particular file what we are actually doing here is working
with the virtual file system.
Now the reality is the virtual file system itself is actually utilizing physical file
systems so the virtual file system is how we are actually interfacing with the system
but it will be pulling information from real live devices real partitions you know say
for example this could be disc 1 which is a hard disk and then maybe an SSD here as
well we are pulling from these physical file systems and presenting it to the user via
the virtual file system where they can actually interact with this information.
Now here is the thing what we actually do is we ultimately carve up our system and we
carve it up into different partitions so this might be one partition this might be a second
partition so on and so forth but one thing we have to do is we have to put a file system
onto the partition.
Now we do have some different file systems that we can actually put onto a partition
and we will mention what they are very very shortly but understand right now we have a
disk we can carve it up into partitions and we want to put file systems onto that partition.
Now here is the rub just by simply carving up a disk like so and putting a file system
onto a partition it does not mean the end user can actually access that file system if
we want to be able to access a particular file system we have to mount it and once we actually
mount the file system that will present that file system to the end user so that they can
actually interact with that file system otherwise it just is like I say inaccessible.
Now this is what I am talking about when I am referencing the physical file system and
the virtual file system with respect to Linux we have what we know is a directory tree structure
so if I go to the root directory if I happen to type the command tree we are going to see
a very very massive tree like structure.
This presents way too much information if I just limit the output here just so we only
go to folders down and to enter if I scroll on up you can actually see the relationship
going on at the very top of the tree we have this root directory and within that we have
the bin directory and the boot directory and then the cd rom and you know within these
directories there are files and further directories this is the directory tree we are talking about
so when we want to mount a particular file system we want to mount it somewhere within
this directory tree like structure so you know as we saw there we could have our root
directory right here and then branching off we may have say for example the boot directory
and at the same level we may have you know like to say the dev directory so on so forth.
Now the reality is the way this actually works is that different disks are mounted at different
points in the directory structure so right here in my situation right here at the root
directory we have sda5 so this is the first disk and it's partition number five that
is actually accessible when I go to the root directory however when I switch and go to
the boot directory I'm actually accessing sda1 so I'm accessing the same disk but I'm
actually accessing a completely different partition so think about this okay we have
this disk here disk1 okay but it is partitions so when I'm in the root directory I'm actually
accessing this big portion of the disk this large chunk here okay all this part here however
just by simply typing the command cdboot I move into the boot directory and that is
actually mounted within a different partition so think about what is actually happening
just by me typing the command cd I'm working through the virtual file system but under
the hood I'm actually accessing different partitions or it may even be different disks
entirely however I choose to mount a particular file system it could be from a hard disk and
then I cd into another directory and now suddenly I may be transparently accessing a solid state
drive so this really is what is happening when we are utilizing our virtual file system it allows
us to easily move around transparently so like I say I go into the root directory I do an LS
right now I'm accessing partition five I go into cdboot suddenly I'm now accessing partition
number one but to you as the end user it is presented to you as the virtual file system and
all of this switching around between physical devices happens really without your knowledge
behind the curtain under the hood now if you happen to be using maybe say a windows device you
might notice things are a little bit more explicit you can see here we have clearly delineated disks
c and we could go in and browse through that disk or we could go into disk d which is another
disk entirely and then browse files within that but it's much more explicit when we happen to use
the linux file system you could just be changing directory quickly and be flipping through disks
without ever really knowing about it so one thing I would say is that when we want to mount a
particular file system it is very important that we mount this within a directory within the
directory tree structure and we want that directory to be empty now the reason why is this and it's
not because you can't mount into a directory which does have particular files or further
directories further sub directories should I say it's just that if you happen to mount into a
directory which already has files and folders those files and folders will suddenly become
inaccessible not that they're deleted or anything like that it just means that while the file system
happens to be mounted in that directory you're not going to be able to access anything within that
that existed prior so imagine if you happen to have some important files some critical files
and you mount a file system into that very same directory those critical files you're not going
to be able to touch them until you unmount that file system so really it's not an enforced rule it
just really is something that you want to self impose for your own best practice so think about
this as I say we have the root directory and then we could have you know the boot directory and you
will know that I have a home directory you know cd home and within my home directory I have a folder
under my username called ipv0 and within this directory here if I so chose I could just use
the command mkdir to create a new directory maybe just call this backup and make it an empty directory
and what I could do I could have another disk and mount that disk within this directory right here
so this may be bsdb partition one whereas the root directory that would be sda partition five
and the boot directory is going to be sda partition one so that means if we go to our root
directory we are on the first disk partition five if we go down to our home directory we're still on
disk one partition five same again if we go into the ip0 folder but if we happen to go into this
newly created backup directory suddenly and transparently we would be reading from an
entirely separate disk and the first partition of that disk however if we go back out to ipv0 we
once again are on sda five but if we go into the boot directory we would be on the same disk again
sda one i.e the first disk but we would now be switching to that first partition so I really
really really just want that process to be very very clear because very often people tend to get
a little bit confused when first presented with this information but once you get it you absolutely
get it and it does make sense and stick that is the good news so I did say we would have a word
about the file systems that are in play what type of file system can we actually utilize with respect
to linux now we will actually mention these file systems in a little bit more detail later on
within this very course but I do just want to give you a brief summary so we have the file system
ex t2 this is based on the extended file system the original one ex t but this was an improvement
okay and again we'll talk about what those improvements are a little bit later on within
this course next we had ex t3 again an improvement over its predecessor ex t2 and this allowed a
type of logging feature known as journaling why that is important again we will certainly see that
very very shortly then we have ex t4 this again provided the benefits of ex t3 i.e we still get
journaling but it provides other features very important features such as allowing for much
larger file systems and this one happens to be a very common file system used in modern linux systems
now moving on from the ex t file systems we also have the xfs file system this one is all about
high performance that really was the design goal of this file system and it does live up to its
promise next we have what is called the btrfs this again is all about size and this was designed
to deal with very very large data devices so large large large and like i say we do have even
more file systems to explore later on now i just wanted to mention the different types of file
system because right now in order to demonstrate the mounting and unmounting of our file systems
as we move throughout this very skill what i want to do is to actually add another disk entirely
now you can actually do this on different types of virtual machines vmware if you so choose
i happen to have a virtual box device or a virtual box instance should i say so i'm just going to
add that right now so what i'll do here is i'll just minimize this and i'll open up virtual box
in fact before i do anything what i'm going to do is i'll shut down my machine forgetting the
sudo command that has always type in the passwords okay so that should be shutting down the machine
what i will do is i'll go to my virtual box machine right now and i'm going to click the
settings button okay now if i go to storage and i choose sata what i'm going to do is to click
this icon here add new storage attachment if i click this i'm going to choose a hard disk now
what i'll do here is i'll just click create right now and i'll choose next here i'll make it a
dynamically allocated hard disk i'll just make the size maybe just say i don't know like one gig
or something like that doesn't really matter the size so much and i will create this now what i will
do is i'll scroll on down i will select this option right here vdi we can actually see the size right
here and i will click choose so now i've actually added a second disk so what i will do now is i'll
click okay and then i'll turn back on my machine so i'll click start right here and the machine is
just powering on okay so i'll go in and open up a terminal right here so if i go in to my dev
directory right now and i do an ls in fact let me just grep for sd and remember the grep command
john there we go so what we can now see here is because i've added this second disk i don't just
have sda1 which has these different partitions i have this new one here sdb this is the second
disk i've just added now what i want to do here is i actually want to give this disk a partition
because right now it's just sdb no partitions available now the command i can use to give this
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
a list type in my passwords and we can see here like i say the very first disk right here it has
partitions this one here no partitions at all as of yet so the name is sdb and this is what we're
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
we have to type a particular command now the command i can use is the m command for help so i'll say
m and then enter and if we scroll on down or rather scroll on up we can see these different options
here so if i do l we can actually see the partition types so i can say l here hit enter so the partition
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
if i say n this will allow me to create a new partition so i'll say n right here the type of
partition i want i will have a primary partition i'll say p and hit enter the partition number if
i have the default one that means we will have sdb one the first partition so i'll just say one
and to enter the first sector 2048 leave it at default the last sector again leave at the default
now it is auto detected the type as linux and it's going to be the entire size of the disk 1.2 gig
now if i actually want to keep these changes and write them so that they do take effect what i need
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
so that's exactly what i'll do so now the partition has been created if i do sudo fdisk dash l notice
now we have a little number on the end sdb one we now have a partition and now that we have a
partition we want to give this partition a file system now like i say i'm not going to go into
too much detail in this command right now we'll talk about file systems in more detail but we did
see that we have a file system called ext4 and i'm going to use this command to make a file system
using ext4 so i'll say mkfs.ext4 and then i'll just target the partition so it's in the dev
directory it's going to be sdb which is my new disk and partition number one that is the partition
we want to put this file system onto so if i enter now now we should have a file system here if i do
my fdisk dash l we have a partition we have the type of linux and we are ready to use this partition
with this file system and we can begin practicing the mounting and unmounting of this partition
in different locations within our virtual file system so that was a lot to get to in the opening
of this skill the next thing we're going to be tackling is manually mounting this new partition
or this new file system using the mount command and that's what we're going to be doing in the
very next nuggets i hope it's been informative for you and i'd like to thank you for viewing