Chapter 8. Tips and Tricks

Table of Contents

Why recompile the kernel at all?
To prepare
Using "config"
Creating dependencies and re-compiling the kernel
Edit LILO config file
General Information on hard disk partitions
Generic Unix filesystem properties
Generic Unix filesystem enhancements
Free Blocks bitmap
Block Groups
Datablock pre-allocation
Why use filesystems?
Filesystem support inside the kernel
A logical division
Attaching a filesystem (mount)
Filesystems other than Linux filesystems and some utilities
A filesystem Structure
The Virtual Filesystem
The Ext2 and Ext3 Filesystems
File System Checking
Performing a filesystem check
Lost+found directory
The proc filesystem
The System Logger - syslogd
How does syslogd work
Why use a log file to record happenings on systems?
Let's look at the .conf file
Setting up the loghost
Inter-Process Communication

Why recompile the kernel at all?

Swapping space and paging space is the same thing, they are also known in the Linux environment as "virtual memory".

This would then allow processes to have more memory if required by moving the contents of an piece of memory to disk that is not being used at that time.

No part of the Linux kernel can be moved out of memory, and this adds an interesting perspective to our topic, as every bit of memory that is used by the kernel cannot be used by anything else on the system.

So as an example, let's say that you have installed the operating system and that you have not changed any of the defaults from that time, if you look harder you would also see that you have hardware support built into the kernel that you are not using at that time, for example a SCSI hard disk device driver BUT you are not using that type of hard disk at all.

There are many device drivers compiled into the kernel and most of them you will never use. By tuning this down we can improve performance fairly substantially. This is not hard to do so do not be discouraged, performance tuning can come at you from many angles in such a powerful operating system.

To prepare

  1. You will need a list of hardware devices that you do have on your system. Refer to the list that you compiled prior to the installation in the system administration course.

  2. The Linux source needs to be loaded on your system, use the main site or use one of the mirror sites as mentioned in the front of this course. If you have purchased Linux it is part of the CopyRight that you have access to the source code (remember to keep the source in /usr/src/linux).

  3. Load and unzip patches if applicable and remove any unneccessary files created in the installation of the patches. (see the section called “DETOUR:”)


It is a good idea to make a backup of the file prior to your changing it.

#  cd  /usr/src

#  make a backup of the file called "linux" - you can zip it as well if want.

When you download the source unpack it into the /usr/src directory.

Then you may also have to apply the relevant kernel patches as follows:

#  gunzip -c patch?.gz | patch -s -p1

Apply the patches in order.

  1. The -s argument to patch tells patch to work silently, and only complain about errors.

  2. The -p1 tells patch that we are in the /usr/src/linux directory, so that it knows how to find files, and puts new files in the right place.

  3. The -s flag is optional; the -p1 argument is mandatory.

Find unnecessary files using the following command:

#  find /usr/src/linux -name '*.orig' -o -name '*~' -exec rm -f {} ; 

#  find /usr/src/linux -name '*.rej' -print 

That will list any files for which there were "rejected "; patches that could not be fitted into the source correctly. If you find any of these files, start from the beginning again.

Using "config"

#  cd  /usr/src/linux

#  make config

There will now be lots of questions to answer about your system, hardware and software wise.

Please make sure that you are well prepared!

If you were to say that you do not have a SCSI drive and you do have one, it will not be recognised, if you say that you have one and you do not then you are going to waste memory resources.

Make a copy of the kernel file that you have been using in case you have a problem later on, then you can still boot with the original kernel and get the system up at least.

#  mv  /zImage  /zImage.old

You should also have your Boot Floppy (see system administration course).

In an article in a Linux news publication a while ago I saw the following questions as being pointed out as most useful or likely:

&quot;&apos;Kernel math emulation&apos; CONFIG_MATH_EMULATION <!-- riaancheck --> 

If you don't have a math co-processor, you should answer this question YES. Those who do have a math co-processor should answer NO.

A kernel with math-emulation compiled in it will still use the processor if one is present. The math-emulation simply won't get used in that instance. This will result however in a somewhat larger kernel and a waste of memory.

In connection with hard disk support it was pointed out that this one causes confusion:

&apos;XT harddisk support&apos; CONFIG_BLK_DEV_XD

NO. This really doesn't have to do with hard disks -- it has to do with your controller card. AT controller cards are 16-bit cards supported by the standard hard disk driver. XT controller cards are 8-bit cards that are rare in 386 machines.

&apos;TCP/IP networking&apos; CONFIG_INET 

YES if you plan to have your system interactive on the net. This includes SLIP and PPP connections. Answer NO if you aren't going to connect to the net right now; you can always compile another kernel later.

&apos;System V IPC&apos; CONFIG_SYSVIPC : 

This isn't used for many things, but doesn't use much memory. YES is recommended.

&apos;Use -m486 flag for 486-specific optimizations&apos; CONFIG_M486 : 

If you have an i386 system, answer NO. Otherwise you should select YES. This uses a little bit of memory. Adding this flag will not slow a 386 down, other than using extra memory, but will speed up a 486 quite a bit. There are a series of questions, which have to do with different types of SCSI drivers and interfaces. If you have a SCSI controller, then you would want to enable the drivers via the configuration process. For those who don't have a SCSI controller, select NO, and move on to the next step in the configuration.

Network device support mainly has to do with selecting the proper Ethernet device or other network connection. PPP and SLIP are used to connect to TCP/IP networks over the serial port; PLIP is used to connect TCP/IP networks over the parallel port, and the rest are ethernet controllers. Do not select drivers of devices you do not have. This can sometimes cause conflict later when you are booting.

Another important section in the kernel configuration process has to do with the different filesystems. There is an advantage to compiling the kernel to have only the filesystems you need. There are several different filesystems supported by Linux:

&apos;Standard (minix) fs support&apos; CONFIG_MINIX_FS :

This is the original Linux filesystem. It is considered to be one of the more stable filesystems, and is still widely used. You probably want this unless you are really desperate for space or will really never use it.

&apos;Extended fs support&apos; CONFIG_EXT_FS :

Only select this if you still have filesystems from the 'old days' that will use this precursor of the second extended filesystem. This filesystem is slow and no longer actively maintained. It is there only for backwards compatibility. NO.

&apos;Second extended fs support&apos; CONFIG_EXT2_FS :

The ext2 filesystem is the most 'full-featured' of the filesystems. It is a super rewrite of the original extended filesystem, with improved speed as well. This is by far the most popular filesystem. A filesystem debugging package is available for this filesystem that can help you recover from fairly bad filesystem crashes. YES.

&apos;msdos fs support&apos; CONFIG_MSDOS_FS :

This filesystem allows for access to the FAT filesystem used by MS-DOS. It is a great advantage for those who need to access floppies or hard disk partitions that use that filesystem. In addition, if you use the UMSDOS filesystem (usually because you installed Linux on an MSDOS partition), you need to include MSDOS filesystem support.

&apos;/proc filesystem support&apos; CONFIG_PROC_FS :

The PROC filesystem does not touch your disk. It is used by the kernel to provide data kept within the kernel itself to system programs that need that information. Many standard utilities will not function without this filesystem. YES.

&apos;NFS filesystem support&apos; CONFIG_NFS_FS :

The NFS filesystem is necessary for those who have a physical network and need to mount NFS filesystems from other computers. If you are on a TCP/IP network, you probably want this option.

&apos;Kernel profiling support&apos; CONFIG_PROFILE :

This is used only by seasoned kernel hackers. You don't need this if you need to read this article...

&apos;Selection (cut and paste for virtual consoles)&apos; :

If you want to be able to use your mouse in any of your VC's, then you would select YES. Note that this requires a separate selection program to work. Your mouse will be inactive without this program. This has nothing to do with X-windows.

The last section of the configuration process that needs insight has to do with sound card options. If you want sound card support, then you would definitely select YES.

Full driver? NO

Select NO because configure the kernel to handle only a particular sound card.

Disable? NO. 

It seemed strange that the driver question would come before a question about disabling the sound drivers altogether. Nonetheless, you should select NO, and answer the questions that follow accordingly, depending on what hardware you have."

Creating dependencies and re-compiling the kernel

Using the depend command from with the /usr/src/linux directory will create the dependencies that you have now set up.

#  cd /usr/src/linux

#  make depend

# make zImage

make zImage -- creates a compressed image which also saves memory.

Edit LILO config file

You need to edit the configuration file for LILO in order that you will boot with the new kernel. (This is assuming that you are using LILO as your preferred boot loader program.)

#  vi  /etc/lilo/config


#  vi  /etc/lilo.conf
boot = /dev/had
#This is the path to the NEW kernel image to be booted
image = /zImage
label = linux 

#This is the path to the OLD kernel image to be booted
#if the other should fail to boot
image = /zImage.old
label = linux.old 

Now when you boot you will see that it uses by default the new kernel that you just loaded.