Technology news and Jobs arrow Information Technology News arrow An Ubuntu guide to taming the Linux kernel
An Ubuntu guide to taming the Linux kernel PDF E-mail
by David M Williams   
Monday, 15 October 2007
When new releases are issued, there’s no need to download the whole source tree again. A command in the top source directory called patch-kernel lets you pull down all the incremental updates required to update the tree on your system. Once again, this command expects the source tree to have a specific structure, so it is important never to move any of the folders around even if you prefer to organise directories differently.

In the top-level folder of the source tree you will find a file named .config. This is the configuration of the default supplied Linux kernel as it was compiled for your distribution. As Ubuntu – and any other Linux distro – must work for the maximum number of people, some configuration items have to be chosen to serve the widest number of people.

You can make performance gains by building a tailor-made kernel specific to your exact hardware, including the type of processor you have. You may make your own .config file, specifying appropriate options, or you may find one under the /configs subdirectory which suits you; if so, copy it to the root of the source tree and name it .config.

That said, it is important to qualify that Ubuntu uses a modular kernel. Years ago, Linux kernels were a single compiled entity which contained all hardware drivers built-in. There were two big problems: if your kernel didn’t include a driver for necessary hardware then it had to be recompiled with the new driver included. Conversely, if the kernel included too many drivers (just in case) then it was needlessly bloated and consumed more resources than it ought. This was true of most UNIX systems prior to Linux, also.

Modularised drivers
The solution to this was to modularise the kernel, so that only those device drivers absolutely needed for the kernel to start up are compiled in; all others are generated as modules which can be optionally loaded into memory once the system has booted, and only if required.

If you choose to rebuild your kernel, you can opt whether drivers are compiled in to the kernel or made modular. This is an example of where you can tweak the kernel to suit your specific needs and application but the actual performance differences you can expect to receive will be hard to measure and generally changes like this are the foray of deeply technical kernel hackers. I personally advocate managing modules for greater flexibility.

Ubuntu helps look after modules with four important commands:
* lsmod lists all the modules presently loaded.
* Insmod attempts to load a specified module. A full path can be provided, or the command will look for the module under the directory /lib/modules.
* rmmod performs the reverse, attempting to unload the specified module from the currently running kernel. We say “attempt” because it’s possible the named module cannot be loaded or unloaded depending on certain circumstances included dependencies.
* depmod creates a list of modules that are dependent on other modules and thus require them to be loaded before they themself can be loaded. This command can be run at any time, but is also run at system startup, sending output to file /lib/modules/*/modules.dep. If you inspect this file, you will see which modules have dependencies and what they are.

With this under our belt, modprobe is a command that provides similar functionality to insmod and rmmod but with the smarts provided by depmod. modprobe will try to load or unload (using the –r flag) modules, but taking dependent modules into account.



 
< Next story in category   Previous story in the category >
iTWire user statistics Visitors last 30 days
Suscribers
904,266
13,751
#1 independent technology news advertise here
  •   *  
  • Search
  • AdvSeach
  • Login
  • Events
  • FreeStuff
Subscribe to our free e-newsletter