Storage Repair (Demo)

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
21 hours 25 minutes
Difficulty
Intermediate
CEU/CPE
21
Video Transcription
00:00
>> Hey, Cybrarians. Welcome back to
00:00
the Linux Plus course here at Cybrary.
00:00
I'm your instructor, Rob Goelz.
00:00
In today's lesson, we're going to be
00:00
talking about storage repair.
00:00
Upon completion of this lesson,
00:00
you're going to be able to understand how
00:00
failing disk hardware can be identified,
00:00
as well as use the storage repair tools such as fsck,
00:00
smartctl, and partprobe.
00:00
Recall what we've discussed previously.
00:00
We said that there's just a handful
00:00
of issues that we might have
00:00
related to storage and these are
00:00
things like running out of disk space,
00:00
disk latency, or failing hardware.
00:00
We covered the first two, and in this lesson,
00:00
we're going to cover failing hardware,
00:00
as well as filesystem repair.
00:00
Now, if there's a small disk portion
00:00
that's not responding I/O request,
00:00
what happens is the disk controller marks
00:00
that as a bad sector.
00:00
Then the controller firmer
00:00
moves the data from the bad sector
00:00
and it just remaps the sector information
00:00
so that the data stays safe.
00:00
However, if you have multiple
00:00
or accumulating bad sectors,
00:00
that tends to indicate a drive failure.
00:00
Now you can see badblocks or
00:00
sectors with the badblocks command, and
00:00
many drives also provide what is called
00:00
self-monitoring analysis and reporting technology,
00:00
or SMART for short.
00:00
For these types of drives,
00:00
the smartctl utility can
00:00
be used to check on drive health.
00:00
Now, some storage issues are
00:00
not related to hardware failure.
00:00
Occasionally, a filesystem itself is broken,
00:00
maybe it has errors or
00:00
corruption, and so in these situations,
00:00
a filesystem check is
00:00
needed and so we use the filesystem check tool,
00:00
which is actually abbreviated as fsck.
00:00
This can be used to check filesystems.
00:00
Now e2fsck is actually what's used to
00:00
check the ext2, ext3, ext4.
00:00
dosfsck under the hood is what's checking
00:00
DOS and FAT filesystems and
00:00
reiserfsck is used to check ReiserFS filesystems.
00:00
But keep in mind, the fsck tool is
00:00
>> not one size fits all.
00:00
>> It does not check XFS.
00:00
>> If you need to do any repair or checking on XFS,
00:00
use the xfs_repair tool on these filesystems instead.
00:00
Now if you do need to replace
00:00
a drive or rebuild a partition,
00:00
the partprobe command comes in handy.
00:00
The partprobe command can be
00:00
used when the partition table on disk has changed.
00:00
Because what it does is it lets the system reread
00:00
the partition table without
00:00
requiring you to reboot the entire system.
00:00
Let's take a look at these commands
00:00
>> with some demo time.
00:00
>> Here we are in our demo environment.
00:00
The first thing let's go ahead and do
00:00
is add a disk to the system.
00:00
Now I'm using virtual box,
00:00
so you're going to see a little bit
00:00
of the behind the scenes there,
00:00
but what I'm going to do is I'm going to do an ll on
00:00
dev and we can see all of the different devices.
00:00
Let's actually do a grep for sd
00:00
because I know the disk that I'm
00:00
going to add here is going to show up
00:00
as a new type of sd device.
00:00
We can see that right now we just
00:00
have sda and then we have
00:00
the partitions on this sda device.
00:00
Let's go ahead. I'm going to go up
00:00
here to machine Settings.
00:00
What I'm going to do is go to Storage,
00:00
Controller, and I'm going to add an additional disk.
00:00
I'll just specify this disk right
00:00
here, and then we'll hit "Okay".
00:00
Now that I've added the disk,
00:00
what we need to do is run partprobe.
00:00
Remember, we're changing the partition table
00:00
so we need to run partprobe.
00:00
So we're going to run that and I'll type in
00:00
my password so that I can
00:00
temporarily become root and run this command.
00:00
This is fine. Don't worry about dev/sr0,
00:00
we always get that message all the time.
00:00
Now we do an ll dev in grep sd,
00:00
we also see sdb and sdb1.
00:00
We've seen that that device has been added
00:00
and we already have a partition on it, which is fine.
00:00
Now, let's check the device for bad sectors.
00:00
We can do that badblocks command that we mentioned.
00:00
You do sudo badblocks.
00:00
What we're going to do is, we'll do verbose.
00:00
We're going to check dev sdb1, and then we'll specify
00:00
if there are any bad sectors by sending
00:00
it the badsectors.txt.
00:00
We don't see any errors here.
00:00
This isn't actually a physical device, no worries.
00:00
[LAUGHTER] But if there were
00:00
any bad sectors here, we would see them.
00:00
If we found any bad sectors,
00:00
we could run smartctl against this as well.
00:00
What we can do is we going to run sudo smartctl -a.
00:00
We specify dev sdb
00:00
because that's the actual device itself.
00:00
Now this isn't an actual physical device
00:00
so it does air out and close,
00:00
which we can see down here.
00:00
It says exiting because the SMART port is unavailable,
00:00
device lacks SMART capability.
00:00
Not a physical drive so there is no SMART.
00:00
But before that, we get all information
00:00
>> about the system, the Vbox hard disk,
00:00
>> the serial number, firmware version, the capacity,
00:00
8.58 gigs, sector size; all good information.
00:00
Smartctl is helpful even when you're
00:00
not running it on a physical drive.
00:00
Interesting. Let's also run an fsck on dev sdb1.
00:00
Now the thing about fsck you need
00:00
to remember is that you have
00:00
to make sure that this filesystem is unmounted.
00:00
For our example, we can just run them out command
00:00
and we can actually do a grep for sdb.
00:00
We don't see any results that indicate
00:00
that sdb is mounted anywhere on the system.
00:00
That's fine, we can move forward with this.
00:00
But you're always going to want to check that
00:00
before you run an fsck
00:00
because you can't run a filesystem check
00:00
on a mounted filesystem.
00:00
We're asking to check out the partition once,
00:00
>> so we'll do fsck dev sdb1.
00:00
>> I'm sorry, we need to be root to do this.
00:00
Let's run this as sudo.
00:00
We can see that it's clean.
00:00
We see all the files have been identified,
00:00
all the blocks, there are no issues there.
00:00
Now, as I said, if this were a mounted filesystem,
00:00
we'd have to take it offline first,
00:00
but this is just an example of how
00:00
you can use all of these commands.
00:00
With that, we've reached the end of this lesson.
00:00
In this lesson, we covered how a system
00:00
identifies failing disk hardware.
00:00
Then we saw we could use some of
00:00
the storage repair tools like badblocks,
00:00
smartctl, partprobe,
00:00
and fsck during our demo at the end of the lesson.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next