In this lesson, you're going to learn
how to troubleshoot hardware issues in a Linux system.
Now it can take some time to troubleshoot and solve
hardware-related issues on Linux.
Even highly experienced system administrators
will sometimes spend hours
working to solve some kind of mysterious
hardware or software discrepancy.
So in this lesson, my goal is not to make you
an absolute expert, but instead I want to help you
identify things quicker and easier
when you're troubleshooting hardware in Linux.
You're going to learn what's causing
your Linux hardware to malfunction
so that way you can get it back up and running
much more quickly.
Now many different things can cause problems
with Linux hardware,
but before you start trying to diagnose them,
it's really smart to learn about the most common issues
and where you're most likely to find them.
Now some of the most common hardware issues
are keyboard mapping issues, communication port issues,
printer issues, memory issues, video issues
and storage adapter issues.
So we'll take a look at those throughout this lesson.
First, let's talk about keyboard mapping issues.
Now certain keyboard keys when they're pressed
may produce an unexpected character on the screen
or no character at all.
This is the most common and overt system
of keyboard mapping issues.
The most likely cause of these issues
is that the system has configured the wrong keyboard layout
or the wrong language to use.
To fix this problem, make sure you can correctly identify
the layout of the physical keyboard.
Not just its overall design type,
but its actual specific regional layout.
Once you've identified the physical layout of your keyboard,
use the command localectl and the word status
to verify the layout that the system is using.
If it's not the same as what you expect,
you want to list the available key maps,
identify the correct one and then set it on your system.
If you're accessing a Linux system remotely,
your remote terminal client may have some options
for addressing keyboard mapping issues too.
SSH clients like PuTTY will enable you
to change the effects
that certain keystrokes have on the environment.
For example, you can configure the backspace character
to move one character to the left
without deleting the character.
This can be helpful in certain applications
that don't handle the default behavior particularly well.
Now another thing we want to talk about
is communication ports like USB
because these can fail to recognize an attached device
or that connection to that device may become unreliable.
Your first step should always be to ensure
the device is correctly slotted into the port
by making sure it has a good physical connection
and the physical cables are not loose or damaged.
Also, make sure the power's being supplied
to the bus adapter.
If these two things don't fix your issue,
then you need to ensure
that any necessary drivers
have been installed and loaded into the kernel,
depending on the type of interface you're going to be using.
Now certain devices,
when they're connected to a serial port, for instance,
will request a consult interface
with the Linux operating system.
Linux will then typically assign a port
to that interface at /dev/ttyS and a number
where the number is the number of the console
and these start out at zero
and then increment by one each time.
Another area we need to consider is printers
and they are a common source of issues.
In many cases, the printer itself will be at fault.
For example, your printer may be out of ink
or may be out of paper.
It may have a paper jam.
It may be misaligned or damaged
or have some kind of broken component.
There's lots of different issues
you can experience with a printer.
For these issues, you want to consult
the printer's help manual and the manufacturer's website.
In other cases though,
you may be able to troubleshoot the issues
from your Linux client or server.
As always, ensure your specific printer
is supported by Linux compatible drivers
and that those drivers have been loaded by the kernel.
If you're trying to connect to your printer over a network,
but you can't, it may be a networking issue
so use network diagnostic tools like ping
to ensure your printer is identifiable on the network
and then it can actually be reached over the network.
If your printer becomes sluggish,
use lpq to check the status of its print jobs
and look at the queue.
If any jobs are too large or there's too many in the queue,
you can use lprm as a command
to stop a job with the job number that you provide.
For example, if I want to remove
job four from the print queue,
I can enter lprm4 and hit enter at the command prompt.
This will help clear up the queue
and then lighten the load on that particular printer.
Now from a software perspective,
we can also have issues with memory leaks.
Now memory can actually leak
when a process fails to free up the allocated memory
when it's no longer needed.
The total available memory in your system then
becomes quickly exhausted as these leaks happen.
This can lead to general performance degradation
or system instability because other software
can no longer access memory that it needs
because we've leaked out this memory.
In these cases, you can use memory monitoring tools
like free to identify where those leaks are happening
and identify the process and then go to something like top
to monitor the process and identify the true problem.
Once you've identified that process, you can then kill it,
freeing up that memory for good.
Now Linux also has ways
of detecting faults during operations.
For example, system logs will record
a machine check exception error message
anytime there's an issue with RAM.
Now if you look through your logs,
you might be able to look for these error messages
by using a command like mcelog.
This will retrieve and print these error messages
for easier analysis.
If the messages contain error-correcting codes
or ECC errors,
this is one of the memory modules
that has probably failed and causing these errors
so you're going to be looking at it as a hardware issue
and not a software issue in this particular case.
Now another thing we want to talk about is video errors.
Common video-related issues include things
like consistent or intermittent black screens,
incorrectly display colors,
multiple monitors not being detected,
sluggish performance in video intensive applications
and other things like this.
Now some these issues can be addressed
by ensuring that monitors and other display devices
are properly connected and compatible
with the system and user software.
When it comes to performance
of video intensive applications though,
you want to make sure you have good graphic card support
and that includes a GPU driver inside of the Linux kernel.
This is often one of the biggest hurdles inside of Linux
and so it's crucial to have the latest drivers
that will work to give you optimal video performance.
Now another hardware problem you might come across
is actually a faulty bus adapter.
If you have a faulty bus adapter,
you might see some possible indications
like poor data transfer speeds,
less total space available than expected,
excessive read or write errors,
inability to read or write at all,
the system can't detect devices anymore
and things like that.
Now the problem here might be the physical HBA itself
or host bust adapter.
Or it might be with the interface
that the HBA is actually connecting to
like a SCSI or SATA device.
The first step is to ensure the host bus adapter
is actually powered on.
Then you need to ensure that the storage device
you're connecting to that HBA
is using the appropriate interface.
And of course you want to ensure that all the devices
are properly slotted and cabled together
and making sure that they're all damage free
and working properly.
Another thing we want to talk about is RAID arrays.
Now we've talked before about mdadm as a command
and this is a command that's used to manage our RAID arrays.
If you use the -F option,
this will activate monitor mode
which enables you to identify missing or failed drives
inside that RAID array.
You can then use some of the command's other modes
to rebuild the array
after you've removed the faulty drive
and put a new one in.
Some other useful options for troubleshooting RAID issues
include using the -f
which is used to mark a specified device as faulty
and prepare it for removal from that array.
You can also use the -r option
which is used to remove the specified device from the array.
If you use the keyword failed,
this will specify that all the devices marked as faulty
should be removed.
If you use --re-add,
this is an option that's used to add a removed device
back into the array for the purposes of recovering data
that's stored on that device.
If you use the -a option,
this is going to be used to add a device
to the array as a hot spare.
If the array is degraded,
it's going to rebuild data on that spare for you.
This behavior only applies to devices
that are unable to be re-added
or were never part of the array to begin with.
Another helpful command we have is lshw.
Now the lshw command is basically the list hardware command.
It's going to list out each detected hardware component
on the system and provide details about each device.
This command pulls information from many different files
in many different locations
for those different device files on the system.
For example, it can pull data from /proc
and then output it in a hierarchical format.
The information that lshw outputs
will include things like your vendors, your product names,
your capacity, your speed
and other attributes of the motherboard
including the CPU, RAM modules, peripheral devices,
storage devices and much more.
You can use lshw or list hardware
to identify whether or not a device
is recognized by the kernel
as well as to review a device's
capabilities and characteristics.
To run this command,
type in lshw and then the options you want
at the command prompt.
The output of the lshw is going to group the devices
into one of several classes.
You can then filter the total result
by specifying a class with a -c option.
For example, if I typed in lshw -c and then network,
I'm only going to see details about network class devices
like network interface cards or a wifi adapter.
To see a list of classes currently in use in your system,
you can enter the command lshw -short, pipe sort-k2
and this will generate a non-detail list of devices
sorted based on the second column which is the class column.
The next command we're going to talk about
is the dmidecode command.
Now this command is going to dump
the system's Desktop Management Interface or DMI
and take that table
and present it in a human readable format.
The DMI table is an industry standard
for tracking information about hardware components.
However, the authors of the dmidecode command
caution us that the information in the DMI tables
is more often than not
inaccurate, incomplete or simply wrong.
Therefore, you don't want to rely on the DMI table
as your sole source of hardware information,
but it can be a useful tool
to act as a second or third source
when you're correlating with others.
To run this command, simply type in dmidecode
and the options at the command prompt.
Another tool we can use
is the Automatic Bug Reporting Tool or ABRT.
This is a utility that's typically used
on Fedora and Red Hat-based systems
and it analyzes and reports
on problems detected during system runtime.
ABRT will be used to collect data
like memory dumps from crashed applications
that'll help system administrators
diagnose and troubleshoot issues.
It can also report on problems of various devices
such as MCE's that typically indicate hardware failures.
ABRT will run as the abrtd daemon
and can be configured using abrt-cli
if you're using the command line
or abrt-gui if you're using the graphical user interface,
depending on your system and your own preferences.
Now you can use both of these utilities
to list problem data, view details about that problem data,
analyze and report on that problem data
and remove unnecessary reports.
Remember, when troubleshooting hardware issues,
the first step is to ensure the hardware devices
are supported by robust drivers
Then ensure the necessary drivers
are installed and loaded into your kernel.
Always ensure the hardware devices
are compatible with the Linux software
that controls it, manages it and interfaces with it.
Verify that the system has the correct keyboard layout
and language set
because this will solve a lot of your problems.
Also, when you're working with network-enabled printers,
make sure it's identifiable on your network.
If you're having a problem with the printer,
you can use the lprm command to be able to stop
large or numerous print jobs from that system.
If you have memory issues,
you can check the mcelog
and that way you can see what errors might exist.
Anytime you're trying to figure out
if your RAM modules are bad or not,
you can use the command line utility memtester.
Also, if you're having problems with your graphics card,
you should check to make sure
you have the latest GPU drivers from your vendor's website.
Always ensure that your storage and peripheral devices
are properly slotted into the correct buses
to make sure they're being recognized by your system
and ensure that the cables are connected properly
and that they're not loose or damaged.
If you want to identify connected hardware,
you can always use the lshw command
which means list hardware.
Also, if you're using dmidecode,
remember, it may produce inaccurate results.
We're even told this by the manufacturers of that tool,
but it still does provide some useful information.
Finally, if you have programs that are crashing a lot,
you should always review your crash data
that's compiled by the ABRT utility
inside of your Linux operating system.
All right, I know we just covered a lot of information
so let me provide a little bit of a summary here.
Remember, Linux hardware troubleshooting
requires a good amount of knowledge
and familiarity with the command line and system messages.
You have learned how to use a wide variety
of tools and utilities in this lesson,
but most importantly, you need to work methodically.
As you understand the different types of hardware issues
and how to address those issues,
always have a standardized process
during your troubleshooting.
Once you've done that
and you've learned the Linux utilities,
you can start troubleshooting much more efficiently.
Hopefully, next time you have something
go wrong with one of your pieces of hardware,
it'll be easier for you to fix
now that you know some of the common tools you can use
to do that.
However, never forget that despite your best efforts,
sometimes you'll never be able to figure out
exactly what that problem is
and you may have to replace
parts or components in the system.
Sometimes it can just be bad hardware
and it's as simple as that
so keep that in mind the next time
you're working on troubleshooting a Linux system.