# list device drivers and check kernel config

## Vieri

Hi,

I've experienced more than once that a gentoo live cd / install cd can detect all my hard disks and devices by correctly loading whatever kernel module is necessary but when I compile a new kernel on my hard disk and boot from it, it sometimes doesn't load all the necessary modules because they weren't selected at compile time. 

I would like to automate (or semi-automate) the activation of certain kernel source code config options such as device drivers (hard disks, network cards, etc.).

Is there a simple way to get the necessary device information when booting from a live cd or installation cd and from that, try to determine which kernel CONFIG_* options (only those related to device drivers) will be necessary to enable when running, say, "menuconfig"?  I don't really need to fully automate it; I just need some kind of script warning me right before launching the kernel source configurator from within the live installation cd that I should "enable JMICRON" or whatever. I realize that CONFIG_* option names can change through kernel versions so I don't expect the script to say "enable CONFIG_BLK_DEV_JMICRON" but just "enable JMICRON" (and I'd manually search the right options within menuconfig).

I could list the kernel modules via lsmod but:

1) how do I easily associate a module name with a kernel option name?

2) I won't see the drivers that are "built-in" within the kernel.

The code:

```

# lspci -k | grep "Kernel modules:"

```

is fine for pci devices (eg. netowrk cards) but may not cover everything. Also, I'm still not sure if it's possible to relate the module names to the kernel CONFIG option names.

Thanks,

Vieri

----------

## BillWho

Vieri,

I'm not sure if this is what you're looking for, but I'll throw it out here anyway

http://kmuto.jp/debian/hcl/

It might help   :Wink: 

----------

## Vieri

Thanks.

Here's what I'm using now. From live installation cd:

# emerge *-sources (kernel sources)

# emerge lshw

# cd /usr/src/linux

# lshw -quiet | grep "driver="

For each driver name, do the following (replace 'sata_nv' with whatever):

# find -type f -name Makefile | xargs grep "CONFIG_.* sata_nv.o$"

./drivers/ata/Makefile:obj-$(CONFIG_SATA_NV)            += sata_nv.o

Extract CONFIG_SATA_NV or whatever config option shows up.

Anyone have a better, cleaner way?

----------

## Vieri

Actually, I think it's better to use:

# lspci -k | grep "Kernel modules:" | cut -d ':' -f 2 | uniq

instead of 'lshw'.

----------

## cach0rr0

a dozen ways of skinning the same cat

```

# lspci -k |grep 'Kernel modules' |awk '{print $NF}' |sort -u

```

though if i have a functional browser when im doing an install, even if i know my hardware, i keep the kmuto HCL page open for reference and easy alt-tabbing

----------

