How Redhat 5 and Centos 5 detect hardware at boot


With the introduction of RHEL6 our beloved kudzu was removed from Redhat Enteprise Linux (it’s been gone from Fedora for quite some time). If you’re not familiar with kudzu, RHEL5 and below use it to detect new hardware when a system is bootstraped. All of the functionality that was part of kudzu is now handled by the kernel and udev, though a lot of sites will need to support RHEL 5 systems for years and years to come.

I was curious how kudzu detected new hardware, so I started reading through the kudzu man page and source code. I learned that hardware discovery / removal is actually pretty straight forward. When a box boots kudzu will probe the hardware and compare it against the contents of /etc/sysconfig/hwconf to see if anything was added or removed. Here is the relevant blurb from kudzu(8):

“kudzu detects and configures new and/or changed hardware on a system. When started, kudzu detects the current hardware, and checks it against a database stored in /etc/sysconfig/hwconf, if one exists. It then determines if any hardware has been added or removed from the system. If so, it gives the users the opportunity to configure any added hardware, and unconfigure any removed hard- ware. It then updates the database in /etc/sysconfig/hwconf.”

So when you get a prompt to add or remove hardware at startup, you are seeing kudzu in action. To view the list of hardware that kudzu is able to detect, you can run the kudzu command line utility with the “-p” option:

$ kudzu -p

class: OTHER
bus: PCI
detached: 0
driver: shpchp
desc: "VMware PCI Express Root Port"
vendorId: 15ad
deviceId: 07a0
subVendorId: 0000
subDeviceId: 0000
pciType: 1
pcidom: 0
pcibus: 0
pcidev: 18
pcifn: 7
.....

I’m not exactly sure what led me to dig into this, but it was rather fun. I’m one of those guys who enjoys going to lunch with 10 pages of C source code and a highlighter. Not sure if this makes me a geek, but it’s kinda cool learning while you consume your lunch calories. ;)

This article was posted by Matty on 2011-07-22 17:39:00 -0400 -0400