Determining Linux Dependencies

*How to compile the Linux kernel

  1. Backup the present kernel which is in "/boot" for most systems. You can tell where it is by looking at "/etc/lilo.conf" . sometimes lilo.conf will point to a link file. Trace the link file and backup the file being pointed to.
  2. Have an alternate way to boot such as another linux system on your computer or an emergency boot disk that you can access your filesystem from in case your new kernel crashes.
  3. Back up your kernel modules in the directory "/modules". There is probably a directory full of modules so you should be able to back it up using "cp –dpr dir1 dir2" where dir1 is the name of the directory where your modules are and dir2 is where you want to put them.
  4. Go to "/usr/src/linux". There is a "/usr/src/linux/.config" file used to do the compile. It is modified by typing "make config" and the values in it are used to determine defaults while doing the "make config". Back this file up to keep your original settings if you want.
  5. Type "make config" and answer the hundreds of questions asked. On another terminal, open the file "/usr/src/linux/Documentation/Configure.help" to determine what each configuration is. Also you can type "make menuconfig" or from an X session "make xconfig".
  6. Type "make dep"
  7. Type "make clean"
  8. Type "make bzImage" or "make zImage" if the kernel is small.
  9. Type "make modules"
  10. Type "make modules_install"
  11. Copy the file "/usr/src/linux/arch/i386/boot/bzImage" to "/boot/vmlinuz".
  12. Copy the file "System.map" from "/usr/src/linux" to the "/boot" directory. Rename it "System.map=w.x.y" and make sure there is a link file called "System.map" pointing to it. This step will keep you from getting warning messages when you boot. It seems to be a step they forgot to include in the kernel-howto.
    • cp /usr/src/System.map /boot/System.map-2.2.14
    • cd /boot
    • rm System.map
    • ln –s System.map-2.2.14 System.map
  13. Run rdev on the new kernel image to verify the root filesystem device. "rdev /boot/vmlinuz /dev/hda2". Please note that this step may be optional dependent on whether you want to use the boot loader, lilo, to point to the root device.
  14. Make sure the /etc/lilo.conf file is correct (image=/boot/vmlinuz), and run lilo by typing "lilo". If you didn't set the root device in step 12, you will need a line like "root=/dev/hda2" in /etc/lilo.conf in the group of commands for your kernel. This will tell the kernel where your root filesystem is.
  15. If your kernel has a feature supported by a module that is required to boot, you will need to make a RAM disk boot image or your system won't boot.
    • Type "lsmod" and look to see if the "loop" module is loaded. If it is skip the next step.
    • Type "insmod /lib/modules/2.2.14/block/loop.o"
      Use this command if the loopback module is not installed. This assumes you compiled the support into your kernel. In my example, I used kernel version 2.2.14, but your kernel version may have a different number. Substitute the appropriate values.
    • Type "mkinitrd /boot/initrd-2.2.14.img 2.2.14"
      Again, this example is for kernel version 2.2.14. This command will create a RAM image module for your kernel to load into.
    • Add an entry similar to "initrd=/boot/initrd-2.2.14.img" to the "/etc/lilo.conf" file for the stanza that is used to boot this kernel. An example of the stanza follows.
      	image=/boot/vmlinuz
      		label=rhl
      		initrd=/boot/initrd-2.2.14.img
      		read-only
      		root=/dev/hda2
      		
      Read the section about LILO for more information or read the lilo and lilo.conf man pages.
  16. Run lilo by typing "lilo". If you didn't set the root device in step 12, you will need a line like "root=/dev/hda2" in /etc/lilo.conf in the group of commands for your kernel. This will tell the kernel where your root filesystem is.

This step may be necessary if you are using a kernel previous to the 2.2 series. In the directory "/usr/include" may be several link files such as "asm", "linux", and "scsi". These are normally softlinks through "/usr/src/linux". If they are, you can direct the softlink file "usr/src/linux" to your new kernel file which may be in the form "linux-2.2.14". If you don't have the "linux" softlink file and don't want to create it, you will need to remove and redirect the softlink files in "/usr/include" to the proper location of your new kernel source.

How to determine what library a binary needs

Using the "ldd" command, type "ldd /bin/ls" to see the shared libraries used by the "ls" command. Do the same for any other binary you are interested in. This way if a binary (newly created, downloaded, etc) requires a library you can check your "lib" directory to see if it is there. If it is not, you will need to create and install it.

How to tell if a library is a.out or ELF type

Type "file library.so.x", substituting the name of your library for "library.so.x". If ELF is used the loader library "ld-linux.so" is required, and if a.out is used, "ld.so" is required.

How to find Kernel Modules

Modules can be found in "lib/modules/2.2.12-20" for kernel version 2.2.12-20. They are loadable modules ending in "*.o" that are used to support the kernel.

Linux Howtos Contents Page