- Posts: 350
- Thank you received: 0
Hardware Detection
19 years 1 month ago #10331
by jwj
-Jeremy-
Hardware Detection was created by jwj
A few months ago I had to swap out some hardware on my computer, the sound card and the NIC. I am dual booting my computer with XP and Kubuntu. Anyways, as soon as I installed that new hardware, linux doesn't recognize it. I was going to reinstall my linux partitions anyways, but I just want to know for future reference what I can do to have it recognize new hardware? BTW, I've never had a problem with devices like thumb drives, those get recognized no problem.
-Jeremy-
19 years 1 month ago #10345
by nske
Replied by nske on topic Re: Hardware Detection
For any device to be recognized in Linux, the proper driver has to be installed and loaded. The Linux kernel comes with a wide variety of stable drivers that cover most hardware. These drivers -and possibly any others you download seperately- can be chosen to be intergrated into the kernel (and load during bootup) or compiled as modular parts of the kernel, which can be loaded and unloaded on demand at any time. Linux distributions, in order to offer compatibility with every piece of hardware out there without loading everything into memory if not needed, usually have compiled and installed every driver as a module. Those modules should lay into /lib/modules/[VERSION]/kernel path.
Though there are technologies that allow driver modules to be loaded automatically on demand (like hotplug/coldplug and PnP), sometimes it is more safe to load the appropriate modules manually (through the "modprobe" command). Distributions have a startup script somewhere in /etc/init.d or /etc/rc.d for that purpose that loads manually whatever modules defined either on the same script or into some external file like i.e. /etc/modules.conf. Propably, during installation, your distribution detects your hardware and arranges for the appropriate modules to be loaded this way. It is possible that the program for this work is still available somewhere (it should be mentioned in the documentation if so), otherwise you need to detect the appropriate module names for your devices and add them manually (the exact procedure should be documented since it defers a bit from distribution to distribution), or compile the driver built-in into the kernel.
Here's some generic instruction:
1) use lspci -possibly with -v(-v) arguments for more verbose information-. If lspci is not available, you should install "pciutils".
2) locate the chipset information for your devices at the output of lspci.
3) cd to /usr/src/linux which should contain the sources of the linux kernel. If it does not exist or if you prefer to install a more recent version of the kernel (recommended), download the tarball with the sources from www.linux.org and extract them inside the /usr/src directory. Then make a symbolic link (ln -s source target) for /usr/linux-[VERSION] to /usr/linux, removing the old one if exists.
4) Type "make menuconfig" once inside /usr/src/linux. An n-curse based menu should be executed, allowing you to browse the available categorized linux kernel components and mark each one of them as M (module), * (intergrated) or not at all. To get more information on a component, you can select it (with the arrow keys) and press "shift + /" (the "?" character). This will display a good description of that component that will help you understand whether you need it or not, and in most cases the module name.
5) Make sure you have a free half-hour, get a cup of coffee and start browsing the components in the various categories one by one if possible! The "Device Drivers" category is where you will find the drivers for any hardware you have (you'll distinguish the ones you need from the chipset info extracted with lspci). You can choose to compile the important drivers (i.e. your NIC's) as intergrated components (*) to avoid the hussle of module-loading. If you choose to install as modules (M), write down the module name if possible in case you need to load the module manually. Warning: Take extra care to select the driver for your "/" filesystem -i.e. reiserfs, or ext3- (under the filesystems category) and any other drivers for hardware required to mount the "/" partition (like serial ata controllers if you have a SATA hard disk) as *, to avoid the need of ram image on boot.
6) Once you've finished, escape all the categories and select "save and exit". You've just generated your custom kernel configuration file (saved as .config)! now you can just type [code:1]make && make modules_install && cp arch/i386/boot/bzImage /boot/vmlinuz-[VERSION] && cp System.map /boot/System.map-[VERSION][/code:1] to have your new kernel compiled and installed!
7) The only think left is going at the configuration file of your boot loader and inform it about your new kernel image. Here's an example of what you could for LILO and GRUB:
/etc/lilo.conf
/boot/grub/grub.conf
7) reboot and select your new kernel from the menu. The old one should still be available in an other entry, in case something goes wrong.
Though there are technologies that allow driver modules to be loaded automatically on demand (like hotplug/coldplug and PnP), sometimes it is more safe to load the appropriate modules manually (through the "modprobe" command). Distributions have a startup script somewhere in /etc/init.d or /etc/rc.d for that purpose that loads manually whatever modules defined either on the same script or into some external file like i.e. /etc/modules.conf. Propably, during installation, your distribution detects your hardware and arranges for the appropriate modules to be loaded this way. It is possible that the program for this work is still available somewhere (it should be mentioned in the documentation if so), otherwise you need to detect the appropriate module names for your devices and add them manually (the exact procedure should be documented since it defers a bit from distribution to distribution), or compile the driver built-in into the kernel.
Here's some generic instruction:
1) use lspci -possibly with -v(-v) arguments for more verbose information-. If lspci is not available, you should install "pciutils".
2) locate the chipset information for your devices at the output of lspci.
3) cd to /usr/src/linux which should contain the sources of the linux kernel. If it does not exist or if you prefer to install a more recent version of the kernel (recommended), download the tarball with the sources from www.linux.org and extract them inside the /usr/src directory. Then make a symbolic link (ln -s source target) for /usr/linux-[VERSION] to /usr/linux, removing the old one if exists.
4) Type "make menuconfig" once inside /usr/src/linux. An n-curse based menu should be executed, allowing you to browse the available categorized linux kernel components and mark each one of them as M (module), * (intergrated) or not at all. To get more information on a component, you can select it (with the arrow keys) and press "shift + /" (the "?" character). This will display a good description of that component that will help you understand whether you need it or not, and in most cases the module name.
5) Make sure you have a free half-hour, get a cup of coffee and start browsing the components in the various categories one by one if possible! The "Device Drivers" category is where you will find the drivers for any hardware you have (you'll distinguish the ones you need from the chipset info extracted with lspci). You can choose to compile the important drivers (i.e. your NIC's) as intergrated components (*) to avoid the hussle of module-loading. If you choose to install as modules (M), write down the module name if possible in case you need to load the module manually. Warning: Take extra care to select the driver for your "/" filesystem -i.e. reiserfs, or ext3- (under the filesystems category) and any other drivers for hardware required to mount the "/" partition (like serial ata controllers if you have a SATA hard disk) as *, to avoid the need of ram image on boot.
6) Once you've finished, escape all the categories and select "save and exit". You've just generated your custom kernel configuration file (saved as .config)! now you can just type [code:1]make && make modules_install && cp arch/i386/boot/bzImage /boot/vmlinuz-[VERSION] && cp System.map /boot/System.map-[VERSION][/code:1] to have your new kernel compiled and installed!
7) The only think left is going at the configuration file of your boot loader and inform it about your new kernel image. Here's an example of what you could for LILO and GRUB:
/etc/lilo.conf
image=/boot/vmlinuz-[VERSION]
# the file you copied to /boot previously
label=linux-NEW
# the name that will apear at your bootloader menu
read-only
root=/dev/hda2
# the partition mounted in "/"
/boot/grub/grub.conf
title=linux-NEW
# the name that will apear at your bootloader menu
root (hd0,2)
# the partition mounted in "/", starting counting from "0"
kernel /boot/vmlinuz-[VERSION] root=/dev/hda2
# the partition mounted in "/", but this time starting count for "1" instead of "0"
7) reboot and select your new kernel from the menu. The old one should still be available in an other entry, in case something goes wrong.
19 years 1 month ago #10351
by jwj
-Jeremy-
Replied by jwj on topic Re: Hardware Detection
I'll give this all a try this weekend. Thanks for the in-depth explanation.
-Jeremy-
19 years 1 month ago #10652
by jwj
-Jeremy-
Replied by jwj on topic Re: Hardware Detection
Okay, so I got everything working after a lot of trial and error. Turns out to get my NIC to work I just had to switch from eth0 (it was still recognizing my onboard NIC even though it wasn't functioning correctly) to eth1. I wanted to install Ubuntu 5.10, so I just went ahead and did a clean sweep of my partitions and installed it. NIC worked perfectly, of course, but I still wasn't getting sound. I have a Creative Lab Sound Blaster Live! 24 bit card, and it turns out you have to tweak things a bit to get it work. I had to turn off ESD and switch to ALSA. Apparently all the channels are muted in ALSA, so I had to run alsamixer, and bring the volume up. Now everything is working as it should. Thanks for the info, nske, I'll be sure to look back to it in the future if need be.
-Jeremy-
Time to create page: 0.128 seconds