Hey guys and welcome back.
So in this skill right here we have a lot of really cool things to cover.
What we're going to be looking at are some of the tools that we're going to be using
to configure and repair EXT based file systems.
Now as you recall we did mention that we have these different types of file systems.
We can have EXT2 which is really rarely used nowadays except for sometimes USB drives may
still utilize EXT2 but that was since replaced with EXT3 and then later by EXT4.
Now this family of file system the EXT family is obviously very widely used so it is important
for us to be able to understand the tools that we can use to like I say configure and
repair these file systems.
Now we did also mention very briefly in the last skill that we have other file systems
too.
Now one of those file systems was XFS.
Now XFS was designed for high performance and it was used as an alternative to the EXT
style file system.
So likewise it does make sense therefore that we do have different tools to manage and repair
XFS based file systems so we certainly will want to be looking at that and those tools
within this skill as well.
Now some other things we're going to have to discuss are looking at removable media.
This would be things such as CD ROMs and USBs that type of thing.
And then we're also going to mention something relating to SMART.
Now this is not to be confused with your smartphone or your smartwatch.
Smart in this context is a little bit different but certainly within this skill we're going
to be looking at that too.
And then we will be having a look at something called AutoFS a super cool and efficient tool
that you can use with respect to mounting your file systems.
So what we are learning within this skill is going to be building upon what we've learned
in the previous skill, taking that information and going a little deeper and a little broader.
So let's first begin by talking about the EXT file system then that's where we'll start
from.
So let's begin then.
Now if you do not recall from the previous skill what I happened to do is I went and
added a new disk to my virtual machine.
That means when I run my LSBLK-F option we can see I also have this new disk.
Disk, disk B here you see that, SDB.
And what I did was I created a partition, in this case partition 1.
I made it a primary partition and then I formatted it with a file system.
This time an EXT4 file system, so an EXT based file system indeed.
Now right now you may recall that this partition right here is not mounted.
We do not have a mount point.
So depending on if you happen to be following along from the previous skill directly and
you have also followed this procedure whereby you have another disk, you have a new partition.
If you happen to have that partition mounted, i.e. in your output you have a mount point
here, then what you would want to do would be to unmount that particular partition.
In my case as you can see here it is not mounted.
Again I could check this with my mount command and get it for SDB.
Notice we do not have any output the way we do for SDA.
So mine is definitely unmounted.
Now with that said, what I want to do is to run a command we saw within the previous skill.
That is the FSCK command, otherwise colloquially known as the FISC command.
If you do not recall what the FSCK command does, or FISC if you prefer, this is going
to allow you to check and repair a Linux file system.
So I will use the FISC command with my super user privileges.
I will say dash Y to answer yes to any prompts, i.e. if FISC finds a problem I want FISC to
go ahead and address and repair that issue.
And I will target the partition on my second disk right here.
So I will do this right here.
We can see here that this is clean, we have no issues at all.
Now we know that this partition happens to be an EXT based file system.
We saw this from the output of our LSBLK EXT4.
Now one thing I want you to notice is what the FISC command is actually doing here.
To check this out, what I want to do is I want to locate where the FISC command is actually
coming from.
So what I will see here is which FSCK and we can see this is actually located at user
Sbin FISC.
So what I want to do here is I actually want to list everything within the Sbin directory
here with respect to FISC.
So what I can say is list my Sbin directory.
Now if I enter, this is going to give me a ton of information far too much.
So what I will do is I will grep for FISCK.
Now what I want you to see here are all these different types of options.
We have FISCK EXT2 for example or EXT4 or FAT for file allocation table.
All of these different file systems.
Now here is what is actually happening when we run this FISC command.
And this is not just some random trivia I'm telling you, this is something you really
want to be remembering for the purposes of the examination.
This command here FISC is ultimately acting as a front end.
Because when we actually invoke this command, what is going to happen is under the hood,
FISC is ultimately going to query what type of file system it is running against.
So when I say FISC against dev, SDB1, what FISC is actually doing, it's querying and
saying hey, what type of file system is this and it looks it up and it gets the information
back that this is an EXT4 file system.
And then because it has assessed this information, it's actually going to call one of these commands
particularly.
So if it finds it is an EXT4 file system, it will actually use this little program right
here.
And what we're getting here is a high degree of abstraction.
Now this is very, very useful because us as the user, we don't have to concern ourselves
with what type of file system we are using.
We can just run the FISC command, let the tool figure out these specifics and everything
works almost automatically.
Okay, but understand here that these different options are all the different types of file
systems that can ultimately be repaired by FISC.
But if I try to manually invoke one of these programs against the wrong file system type,
what's what will happen?
So I can grab MSDOS for example right here.
So I'll say it's sudo FISC.MSDOS and then I will target my EXT4 based file system,
so SDB1.
And if I hit enter, it's saying the logical sector size is zero.
So this particular program is looking for a formatting style which does not exist on
EXT4.
So it just simply is not going to be able to inspect nor repair this file system.
But I can if I so choose explicitly call that particular program.
So I can actually say EXT4, which would be the correct file system and to enter and we
get the same effect.
But really just to remember, we do not have to do such a thing.
We can just call FISC and FISC will automatically figure this out.
Really important concept to be remembering.
So I can say sudo FISC against devsda5 which is mounted.
Notice here it's saying this is mounted cannot continue aborting.
But this begs the question, we have this root file system mounted right here, which is utilizing
this disk with this particular file system.
How in earth would we be able to scan this then and be able to leverage the ability of
FISC to repair this EXT4 based file system if there was indeed a problem to solve.
So this is a little bit of a problem.
Our system ultimately requires that the root file system be mounted and we can't scan this
particular file system because it is mounted.
Well the answer actually lies in something we talked about in the previous skill and
that is in the SAFS tab file.
So let me just quickly show you that one once again.
So go into, in fact let me just say nano with super user privileges and also FSTAB and to
enter.
Now you may recall we talked about these different columns here.
We have the file system, the mount points, the type, the options, then the dump value
and then the pass value.
Now I kind of skipped over dump and pass but I definitely don't want to skip over pass
in this portion right here.
So what pass is ultimately going to do is going to allow us to invoke FISC.
So really this value here on the right hand side, this is the priority value.
So this value here will mean that indeed the root file system will be scanned by FISC.
The thing is it will be scanned upon a reboot before it actually has been mounted when it
is going to mount it.
So to speak it will run this FISC command.
Now one thing to note here is that this does not mean, and I mentioned this in the previous
skill, this absolutely does not mean that every time the file system is booted the root
file system is going to be scanned.
Nope.
The number here is simply the priority and if it does have a number that is not zero
then it is going to be scanned by FISC.
However if I happen to change this value and I change it to be zero this would mean that
the root file system would never ever ever be scanned by FISC upon reboot.
But for now I will leave it at one because I do want it to be checked by FISC.
Now this actually begs the question if this number does not denote how frequent the check
is going to happen how do we actually make such a decision, how do we actually control
how often FISC is going to check that root file system?
Well the answer lies in the command called tune to FS and this is another tool that we
can use with respect to our EXT based file systems.
So let me show you how this works.
So let's have a look at tune to FS then and see how this can help us with respect to our
EXT based file systems.
I will say man tune to FS and we can see here this is going to allow us to adjust file system
parameters on EXT 2, 3 and 4 based file systems.
So notice this is a tool for the EXT family of file systems.
You're not going to be able to use this on something like say XFS.
So what I'm going to do here is I'm going to list my current settings.
What I shall do is I will say tune to FS-L and I am forgetting a very important point.
I actually have to give as an argument the file system whose settings I want to list.
So in this case here I will just use devsdb1 and if I hit enter I am forgetting super
user privileges.
Clearly I am still asleep so we'll try again.
Type in my password of course.
Hit enter and there we go a little bit better.
Okay so if we scroll on up to the top here we can see a whole bunch of information.
You can see things such as the volume name for this particular file system as of right
now there is no volume name set.
So if I wanted to tune these settings say for example the file system name I could actually
do this directly via tune to FS.
The way I can do this is by using the dash capital L flag.
I can say sudo tune to FS dash capital L and then I'll give the name of the label that
assign to this particular file system so I'll just call it my label because as we know I
am completely devoid of all creativity so keep this simple and then I'll specify what
it is I want to target.
I want to target sdb1 so if I hit enter now that will now be tuned if I arrow up and list
my new settings.
If I scroll on up a little bit here we go.
At the very top now the settings have been tuned such that the volume name is now my
label.
Now with respect to what we can see here with the tune to FS outputs we have a lot of settings
and that means we can change and tune a lot of these settings.
One setting which is very important to what we just talked about with respect to Fisk
is going to be our interval value.
Let me show you what that is if I scroll on down.
We can see here that the check interval is the value none.
So what I'm going to do is I'm going to actually first change this value and then I'll explain
what we've actually done.
So the way I can actually change this interval is by using the dash I flag.
Okay think of I for interval so I'll say sudo tune to FS dash I and I'll give it a particular
value.
Now if I happen to say the value 7 this is going to correspond to 7 days and then I'll
give the actual targets file system which will be sdb1.
If I hit enter that will now be changed and notice here it says 604800 seconds.
What this actually means is that I've given the value 7 days it's translated it into seconds
this is how many seconds that is and if I list everything once again we scroll on up.
We can see the check interval is now at one week but what exactly are we talking about
with respect to this check interval.
Well this is exactly what we talked about when we were speaking about the pass option
within FS tab.
So open this FS tab here we have the priority value one just meaning that FISC is going
to be run against this file system.
Now remember I said this didn't actually dictate when or how often this would happen.
We would do it another way this is what we're doing right now.
What we're saying here is that after one week we want to be running the FISC utility against
this particular file system.
Now right now this will actually not take effect FISC will not check sdb1 because sdb1 is not
defined within FISC.
So what I could do here is I could add a particular option I could say dev sdb1 and let me just
mount this in my documents folder say for example it's ext4.
I'll give it the defaults and I'll say zero and I'll put the pass value to the priority
two and just before I save this what I should actually do is give the fill path so that
should be home ipv0 documents so I'll save here and exit and I will now run the mount-a
command which will invoke FS tab.
So now if I say lsblk-f this file system is now mounted here and because it is now an
FS tab it will survive multiple reboots.
So just like the problem we had with our root directory how could we run FISC against this
because now it's going to be mounted every time we have the computer turned on but like
we saw with our tune2fs now configured after a week has elapsed the next reboot that happens
tune2fs will run against sdb1 before it actually is mounted when the system is beginning to
boot up.
Another important point to note here is that we have a maximum mount count of minus one
what this means is that the maximum mount count is not in effect now just like with
the other options tune2fs is going to allow us to modify this particular value I can do
so with the dash c flag and now I can specify the maximum mount count so in this case I
will change it to five and then specify the disk I want to target so sdb1 and then target
the particular partition sdb1 if I hit enter we have now changed the maximum mount count
to five I can then list everything once again instead we no longer have negative one we
have the mount count of five and right now the mount count is one so check this out if
I happen to unmount stave sdb1 again with the sudo command and then I mount it once
again watch what happens if I list my options one more time notice here the mount count
has incremented to the value two and again if I unmounted and mounted and listed again
the mount count increments once again now what we have done here is we have set a maximum
value of five and then once we go beyond five what is going to happen is fisk again is going
to be invoked meaning that once we have breached that limit of five the next boot that particular
file system and sdb1 is going to be checked by fisk again because we have that pass value
configured within it's a fs tab hopefully these pieces are beginning to come together
so you can see how everything relates to one another now the thing is you might be wondering
is that we may have a potential contradiction we have fisk being invoked after one week
apparently as well as after five reboots so when is it going to take effect after a week
or after five reboots the reality is both are still in play and the answer is whatever
one comes first meaning that even if I have no more reboots or no more mounts and unmounts
should I say more accurately then even if we don't breach this five value once the week
has elapsed the next reboots fisk is going to be invoked now conversely if I happen to
breach this value before the week has elapsed say for example I unmounts and mount a few
more times within this very day even though a week has not elapsed fisk will still be
invoked and in fact if I just unmounts, mounts, unmounts and mounts and one more time so I
have breached this value I list my values notice the mount count has actually exceeded
the maximum count but fisk has not yet run because like I say the system is still up
the disks are still mounted but what's going to happen is that upon the next reboots whenever
this particular file system SDB1 is going to be mounted before that actually happens
fisk is going to run so indeed if I happen to just say reboot and reboot the system as
my machine begins to load up before the process is complete fisk is going to be ran against
SDB1 we can actually see file system checks in progress at the bottom of the screen here
this is fisk actually operating against SDB1 because we did breach that maximum mount count
and now I am back in the system we do an LSBLK-F SDB1 has been mounted but in the meantime
during the boot this file system was checked by fisk for any potential errors as we can see here
the tune to FS command really is very very important to understand how it interacts with
the configurations within the xcfs tab file is very very important indeed now we do have a
couple more tools that we want to be looking at with respect to the ext based file systems now
what are those tools well that's what we're going to be talking about in the very next nuggets I
hope this has been informative for you and I'd like to thank you for viewing