Removing Unnecessary Drivers

A second procedure that can improve kernel performance is removing unnecessary drivers. Most distributions provide kernels that are configured to boot on as wide a range of hardware as possible. In many cases, this means that drivers are compiled as modules so that the modules can be accessed after the kernel has loaded, without bloating the kernel beyond usability. In other cases, though, creating a kernel that boots on many systems means that the kernel must include drivers that are not needed on your system. For instance, a distribution may include a large number of ATA or SCSI drivers. These drivers consume memory, but most of them go unused on any given system.

Removing unnecessary drivers has a benefit mainly in reducing memory consumption. Once a driver is gone, the kernel becomes a bit slimmer, giving more room in memory for user programs. On modern systems with hundreds of megabytes of RAM, this effect is likely to be modest. Most hardware driver modules' sizes are measured in the tens of kilobytes, so even taken together, a dozen or more drivers won't consume a huge amount of RAM. Removing unnecessary drivers can be a great boon on an older system or on specialized systems such as palmtop computers, which have limited amounts of RAM.

In addition to saving RAM, reducing the kernel's size can help at boot time. A smaller kernel loads more quickly. This effect is tiny if you boot from a hard disk; however, if the kernel is on a floppy disk, the effect can be more substantial. More important, a smaller kernel can fit on a floppy disk. A kernel loaded with all the drivers won't fit in the 1,44MB space of a conventionally formatted 3.5-inch floppy disk. This consideration is most important if you want to create a floppy boot disk for an emergency recovery system, as described in Chapter 17, "Protecting Your System with Backups." Having a bootable kernel on a floppy disk can also come in handy in case you accidentally damage your boot loader installation or if you want to test a new kernel without changing your boot loader configuration.

Tip If you find that you can't create a kernel that's small enough to fit on a conventional floppy, you may be able to create a bootable CD-R disc instead. One way to do this is to create a 2.88MB file and treat it like a floppy disk image. You can then copy the kernel to this file, make it bootable, and use mkisofs's bootable CD option (-b) to create a bootable CD-R using the 2.88MB image file.

To remove unnecessary drivers, you must peruse your configuration to locate them. What is unnecessary, of course, varies from one system to another. For instance, a computer without a SCSI host adapter doesn't need any of the SCSI device drivers. (Such a system might still need SCSI support if you enable SCSI emulation for ATA devices or if you use IEEE-1394 or USB disk devices, which look like SCSI disks to the kernel.) On the other hand, an all-SCSI system needs SCSI disk support and support for the SCSI host adapter, but it doesn't need ATA support at all. A system with both types of devices needs its boot device in the kernel proper, but chances are the other type of device can be compiled as a module. In fact, most Linux drivers can be compiled as modules. These include network drivers, sound card drivers, CD-ROM drivers, floppy disk drivers, most filesystems (whatever you use for the root filesystem being a notable exception), USB drivers, RS-232 serial drivers, parallel port drivers, and more.

On the other hand, you may want to compile some devices into the kernel, despite the fact that the kernel size will increase unnecessarily. Placing a hardware driver in the kernel means that it will almost certainly be detected correctly when the system boots. A misconfigured /etc/modules.conf or other module configuration file can lead to a failure to identify hardware. For this reason, you may want to compile drivers for hardware that's always in use, such as network adapters, into the kernel itself. Placing such drivers in modules saves little or no RAM, and if you don't put too many such drivers in the kernel file proper, it should still fit on a floppy disk. In the end, you'll have to discover your own balance on this point.

0 0

Post a comment