- [Instructor] Hello again, and welcome to
the last video of Section Eight,
"Checking Disks and File Systems for Errors."
In the previous video, we learned
about monitoring disk activity.
In this video, we'll see how to check
disks and file systems for errors.
Data is the most important thing in any computer system.
Naturally, it's important to monitor the consistency
of data stored on physical media.
We'll use the standard tool, fsck,
to check for errors in file systems.
This command should be pre-intalled on all modern distros.
If not, use your package manager to install it.
Let's see how to use fsck with its various options
to check file systems for errors and, optionally, fix them.
To check for errors on a partition or file system,
just parse its path to fsck.
To check all file systems configured in /etc/fs tab,
we can use the following syntax.
This will go through the /etc/fs tab file sequentially,
checking each of the file systems one by one.
The fs tab file basically configures a mapping
between disks and mount points, which
makes it easy to mount file systems.
This also makes it possible to mount
certain file systems during boot.
Instruct fsck to automatically attempt fixing errors.
Instead of interactively asking us whether or not to repair,
we can use this form of fsck ...
to simulate the actions fsck is going to perform.
This will print the information on
what actions will be performed,
which is checking all the file systems.
Fsck is just a front end for
file system-specific fsck programs
written for those file systems.
When we run fsck, it automatically
detects the type of file system,
and runs the appropriate fsck.fs type command,
where fs type is the type of the file system.
For example, if we run fsck on Ext4 file system,
it will end up calling the fsck.ext4 command.
Because of this, you'll find that fsck itself
supports only the common options across
all such file system-specific tools.
To find more detailed options, look at the man pages
for specific commands, such as fsck.ext4.
Further, simulating the actions fsck performs is useful
when there is a suspicion of a file system being corrupt,
and we run fsck to fix it.
It is sometimes important to make sure that fsck
doesn't perform an operation which we don't want.
An example may be that fsck might want
to mark some sectors as bad, but we might want
to try to recover the data from it.
In this case, we can ask fsck to just do a dry run,
and print the actions instead of
actually performing the actions.
Also, in this video we've learned how
to check disks and file systems for errors.
This video concludes the eighth section of this course.
We first learned about monitoring disk usage,
and then we moved on to calculating
the execution time for a command.
After that, we've seen about collecting log information
about logged-in users, boot logs and boot failures.
Then we moved on to listing the top 10
CPU-consuming processes in an hour.
Also, we've seen about
monitoring command outputs with watch.
Then we've learned about logging
access to files and directories.
We then learned about logfile management with logrotate.
Also, we've learned how to log with syslogd.
Then we have seen about monitoring
user logins to find intruders.
Then we learned about remote disk usage health monitor.
We then moved on to finding out
active user hours on a system.
Then we learned how to measure and optimize power usage.
We've also seen how to monitor disk activity.
Finally, we've seen about checking
disks and file systems for errors.
All of the following videos in all the next sections,
we will see about administration calls.