Storage

How to troubleshoot hardware when using FreeBSD

Several commands can make hardware troubleshooting much easier when using FreeBSD. Dru Lavigne has your tips.

Few things in life are more frustrating than a computer that refuses to do what you want it to do at a particular moment. Whether you’re trying to convince your operating system to recognize that new piece of hardware, your terminal has just informed you that your kernel has panicked, or you simply can’t find where you saved that important document, you’ve just entered the wonderful world of troubleshooting.

Yes, troubleshooting is a subtle art that demands from its students years of experience, reading libraries full of information, and some psychic ability. Of course, this is not comforting if you have a problem now.

Fortunately, as in any UNIX variant, FreeBSD comes with a plethora of useful utilities and documentation, as well as a mailing list to assist you in pinpointing problems so you can fix them. This article will concentrate on some of the built-in utilities that are available to help you diagnose hardware problems.

Working hardware rarely stops functioning immediately; devices will usually begin generating error messages before they bite the dust. FreeBSD comes with virtual terminals, which are accessed by simultaneously pressing the [Alt] key and one of the function keys. By default, all system messages are logged to the first virtual terminal, or [Alt][F1]. This is a good place to look for error messages, but a lousy place to do your work. It can be very disconcerting to be editing a document in vi and have a system message suddenly appear in the middle of your document.

dmesg
The dmesg command is very useful when troubleshooting hardware. It provides detailed information about which devices were found during boot-up and any error messages. Here is an example dmesg output:
Copyright (c) 1992-1999 FreeBSD Inc.
Copyright (c) 1982, 1986, 1989, 1991, 1993
       The Regents of the University of California. All rights reserved.
FreeBSD 3.4-RELEASE #0: Tue Dec 28 22:18:05 GMT 1999
    jkh@highwing.cdrom.com:/usr/src/sys/compile/GENERIC
Timecounter "i8254"  frequency 1193182 Hz
CPU: Celeron (334.09-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x660  Stepping = 0 Features=0x183f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,
CX8,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR>

real memory  = 67108864 (65536K bytes)
avail memory = 61747200 (60300K bytes)
Bad DMI table checksum!
Preloaded elf kernel "kernel" at 0xc035c000.
Preloaded userconfig_script "/boot/kernel.conf" at 0xc035c09c.
Pentium Pro MTRR support enabled
Probing for devices on PCI bus 0:
chip0: <Intel 82443LX host to PCI bridge> rev 0x03 on pci0.0.0
chip1: <Intel 82443LX PCI-PCI bridge> rev 0x03 on pci0.1.0
chip2: <Intel 82371AB PCI to ISA bridge> rev 0x02 on pci0.7.0
ide_pci0: <Intel PIIX4 Bus-master IDE controller> rev 0x01 on pci0.7.1
chip3: <Intel 82371AB Power management controller> rev 0x02 on pci0.7.3
Probing for devices on PCI bus 1:
vga0: <SiS model 6326 VGA-compatible display device> rev 0x0b on pci1.0.0
Probing for PnP devices:
CSN 1 Vendor ID: CMI0001 [0x0100a90d] Serial 0x01000100 Comp ID: @@@0000 [0x00000000]
Probing for devices on the ISA bus:
sc0 on isa
sc0: VGA color <16 virtual consoles, flags=0x0>
ed0 at 0x300-0x31f irq 5 on isa
ed0: address 00:00:b4:3c:56:40, type NE2000 (16 bit)
atkbdc0 at 0x60-0x6f on motherboard
atkbd0 irq 1 on isa
psm0 not found
sio0 at 0x3f8-0x3ff irq 4 flags 0x10 on isa
sio0: type 16550A
sio1 at 0x2f8-0x2ff irq 3 on isa
sio1: type 16550A
fdc0 at 0x3f0-0x3f7 irq 6 drq 2 on isa
fdc0: FIFO enabled, 8 bytes threshold
fd0: 1.44MB 3.5in
wdc0 at 0x1f0-0x1f7 irq 14 on isa
wdc0: unit 0 (wd0): <WDC AC36400L>
wd0: 6149MB (12594960 sectors), 13328 cyls, 15 heads, 63 S/T, 512 B/S
wdc0: unit 1 (wd1): <FUJITSU MPD3064AT>
wd1: 6187MB (12672450 sectors), 13410 cyls, 15 heads, 63 S/T, 512 B/S
wdc1 at 0x170-0x177 irq 15 on isa
wdc1: unit 0 (atapi): <ATAPI 44X CDROM/VER-3.10>, removable, accel, dma, iordy
acd0: drive speed 0 - 6875KB/sec, 128KB cache
acd0: supported read types: CD-R, CD-RW, CD-DA, packet track
acd0: Audio: play, 255 volume levels
acd0: Mechanism: ejectable tray
acd0: Medium: no/blank disc inside, unlocked
matcdc0 not found at 0x230
ppc0 at 0x378 irq 7 flags 0x40 on isa
ppc0: Generic chipset (ECP/PS2/NIBBLE) in COMPATIBLE mode
ppc0: FIFO with 16/16/16 bytes threshold
lpt0: <generic printer> on ppbus 0
lpt0: Interrupt-driven port
ppi0: <generic parallel i/o> on ppbus 0
plip0: <PLIP network interface> on ppbus 0
vga0 at 0x3b0-0x3df maddr 0xa0000 msize 131072 on isa
npx0 on motherboard
npx0: INT 16 interface
changing root device to wd0s2a

Dmesg’s output is longer than one screen. Press [Scroll Lock] and use the [Page Up] and [Page Down] keys to read dmesg. When you finish, press [Scroll Lock] again to get your command prompt back.

The name of the device appears at the beginning of each line, followed by a full colon and details about that device. For example, ed0 is my NIC, which happens to be NE2000 compatible.

whatis
If you are unsure what a device is, use the whatis command. For example, typing whatis ed on my machine returned the following:
ed(1), -(1) -ed text editor
ed(4) -high performance ethernet device driver
unifdef(1) -remove ifdef’ed lines

Note: Do not include the device number when using the whatis command.

man
To garner additional information about a hardware device, read its associated man page. In the case of an editor, I’d type man 4 ed.

Executing the man ed command provides information about the ed text editor, which may help troubleshooting efforts.

Remember the hardware configuration screen you used when you installed FreeBSD? You can re-enter this screen to resolve IRQ and port conflicts. Reboot your computer; when you see the prompt “Hit [Enter] to boot immediately, or any other key for command prompt,” press any key other than [Enter]. When you receive a prompt, type:
boot –c

At the next prompt, type:
visual

Once you’ve resolved your conflicts, press Q to quit and Y to save your changes. Your computer will continue to boot. Use dmesg to ensure your hardware was recognized.
If you'd like to share your opinion, please post a comment below or send the editor an e-mail.
0 comments