Linux Hardware Repair - A+ Class

MaxLinuxPenguin.jpg

Contents

Introduction

Diagnosing and repairing PC and servers requires the intelligent use of many tools. There is no single piece of testing software that is perfect or suits every situation.

Often many hardware issues, data salvage operations and system troubleshooting steps can be performed using Linux. This adds some very powerful tools to your technician arsenal.

The focus of this lab is to give you a general orientation to Linux as it can be used by hardware technicians. You might be surprised how easy it is to use some of these tools and how powerful they can be.

Linux can assist with troubleshooting:

1) Hardware / driver issues
2) Hard Drive problems
3) Data recovery
4) Networking issues
5) Boot block corruption 
6) Stress testing
7) Windows Password Cracking
8) Partition Resizing (GParted)
9) Remote connections RDP / SSH

Linux for Hardware Analysis

To get information about your hardware environment you can use:

#lspci

To show a list of devices recognized. This is great for finding out information like the exact NIC, etc.

#dmidecode | less

Will provide a wealth of information. You can use the GUI version too Hardware Info Polling You can find out BIOS information, memory type / speed, how many memory slots, etc.

#dmesg

Will show you all the boot messages. Great for reviewing what happened during boot time, what was recognized, etc.


Drive Testing:

Linux provides fantastic tools for analyzing hard drives. The intelligent interpretation of the data available using these tools can go far in determining the drive fitness or in data recovery.

S.M.A.R.T

This section is just an intro to SMART, there is a more extensive page on this subject at SMART Drive Diagnostics

smartctl is part of the smartmontools package for most linux distributions. If not already installed, you should easily be able to install it with the package manager for that distro:

apt-get install sysmontools
for Debain / Ubuntu
yum install sysmontools
for Red Hat based systems

Using smartclt is very easy:

smartctl -a /dev/hda 

(Or /dev/sda for SATA drives)

samrtctl -s on /dev/sda

Will activate SMART if it is currently disabled on the drive, bypassing BIOS.

This gives you a significant amount of data to analyse. Note that different values are evaluated differently. Increasing numbers for some attributes (reallocated sectors, CRC errors, etc) are bad while increasing numbers for others (read error rate) are actually good. And excellent reference for analysing these attributes is at Wikipedia:

http://en.wikipedia.org/wiki/S.M.A.R.T

Pay particular attention to the reallocated sectors, pending sector count, and the total number of smart errors, ATA Error Count.


HD Parameters

Show and set drive parameters and perfrom read / write tests with this great tool.

hdparm -? 
List help and options
hdparm /dev/sda (or /hda for PATA drives)
hdparm -I /dev/sda
hdparm -i /dev/sda
hdparm -tT /dev/sda
Time read and write speeds and show results

A fantastic site with tons of information on hdparm is the Gentoo Wiki:

http://gentoo-wiki.com/HOWTO_Use_hdparm_to_improve_IDE_device_performance#bonnie.2B.2B

There is also a tool for SCSI, SATA and SAS drives called sdparm which uses different options.

An addition tool called seeker is available from the below site. It must be compiled, but is very easy to do so.

http://www.linuxinsight.com/how_fast_is_your_disk.html

wget http://www.linuxinsight.com/files/seeker.c
gcc -O2 seeker.c -o seeker

Data Recovery

Often a failing drive will no longer boot to the OS. Or the OS is too corrupted to boot and needs reinstalled. There are several options for data recovery using Linux tools.

1) Just boot to a Live CD. If the amount of data to be recovered is relatively small you can simply plug in a USB stick or external hard drive and recover the data onto it - never even removing the drive from the system. NOTE: USB 2.0 / Firewire drives are best for this.

2) If the drive is physically / mechanically failing and won't boot it may be salvagable with dd or ddrescue. This allows you to clone the defective drive onto a new target drive. This is often more successful than utilities such as Ghost which do not handle drive errors well, etc. The basic use if very simple:

dd if=/dev/sda of=/dev/sdb

Would copy drive sda to sdb. ddrescue gives other options sepcificaly for drive recovery operations.

You can also use dd_rescue which offers some additional tools and gives an update on its status which dd does not:

dd_rescue /dev/sda /dev/sdb

Windows Password Resetting

You can use Ubuntu and other Linux tools to reset / erase a Windows password. This does not always work on 2003 RC2, etc.

Always ensure the person you are granting access to is authorized!

Windows Password Cracking

Networking Tools

mtr destination.ip.address

Great tool for analysing a route. Combination or ping and traceroute together. If not installed it may be part of a package such as iputils.

iptraf

Provides detailed analysis of ip traffic on the computer. More suited for analyzing traffic on a server with multiple connections to it.

mii-tool

Gives current link status. By using the -F option you can specify the speed an duplex of the link. Usefull for quickly troubleshooting what the line is actually set to despite what the corporate networking guys tell you it is.

ifconfig

Use by itself or specify the network adapter such as: ifconfig eth0 This is similar to ipconfig in windows. You can bring the interface up and down with: ifconfig eth0 up


Restarting Networking

You may need to restart the networking service in order for changes to take effect. This is usually done with a command such as:

service network restart

or by running the script that controls networking in that distribuiton. For example:

/etc/init.d/network restart


Boot Block Corruption

It is inevitable that boot block corruption sometimes occurs. Windows and Linux can be easily repaired and made bootable again. If you install Linux and can no longer boot Windows because Grub becomes corrupted don't fear. If windows won't boot because the MBR is corrupted, it can be fixed. A great tool for this is Super Grub, available at:

http://www.supergrubdisk.org/

This is a menu drive bootable CD to assit in MBR repairs and system recovery.

Rescue / Live CD distributions

http://www.knopper.net/knoppix/index-en.html Knoppix - the classic live environment Linux CD

http://www.ubuntu.com/ Taking the world by storm - Ubuntu. This is both an install and a live CD

http://fedoraproject.org/ Red Hat's Fedora Project. Live CDs for latest version available here.

http://www.remote-exploit.org/backtrack.html Live CD focusing on network analysis and pen testing


Repair Tools

http://www.supergrubdisk.org/ Super Grub - repair boot issues for Linux and Windows

http://www.sysresccd.org/Main_Page Built in ntfs support and a variety of recovery tools

http://www.stresslinux.org/ System stress testing

Looking for something?

Use the form below to search the wiki:

 

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!