November 27, 2014
 
 
RSSRSS feed

New HOWTO: The Linux Kernel HOWTO - page 3

Table of Contents

  • April 2, 2001
  2.  Quick Steps - Kernel Compile

  This section is written by Al Dev

  The latest version of this section is at  
  and click on "Quick Steps to recompile linux kernel". Mirror sites are
  at - , angelfire
  , geocities
  , virtualave
  , bizland ,
  theglobe , spree
  , infoseek
  , bcity
  , 50megs , NBCi
  , Terrashare
  , Fortunecity
  , Freewebsites
  , Tripod
  .  These sites have lots of
  linux goodies and tips.

  A copy of the above web-site is reproduced here -

  Kernel re-compile is required in order to make the kernel very lean
  and which will result in FASTER operating system . It is also required
  to support any new devices.  Note:  Below 'bash#' denotes the bash
  prompt, you should type the commands that appear after the 'bash#'
  prompt. Below are commands tested on Redhat Linux, but it should work
  for other distributions with very minor changes.


  1. Login in as 'root' throughout all these steps. Mount Redhat linux
     cdrom and install the linux kernel source rpm

     ___________________________________________________________________
     bash$ su - root
     bash# cd /mnt/cdrom/RedHat/RPMS
     bash# rpm -i    kernel-headers*.rpm
     bash# rpm -i    kernel-sources*.rpm
     bash# rpm -i dev86*.rpm
     bash# rpm -i bin86*.rpm
     ___________________________________________________________________


  (The bin86*.rpm and 'as86' is required only for OLDER Linux systems
  like redhat 5.x.  Get Intel assembler 'as86' command from dev86*.rpm
  on cdrom or from  ,
   ).



  2. Start X-windows with 'startx'.

     ___________________________________________________________________
     bash# man startx
     bash# startx
     bash# cd /usr/src/linux
     bash# make xconfig
     ___________________________________________________________________


  The "make xconfig" brings up a user friendly GUI interface! DO NOT use
  'make config' which is a command-line option ( use this only if you
  CANNOT bring up X-window). You can load the configuration file from
  /usr/src/linux/.config (dot config file).



  3. Enable the Loadable kernel modules support!  With this option you
     can load/unload the device drivers dynamically on running linux
     system on the fly.  See these man pages

     ___________________________________________________________________
     bash# man lsmod
     bash# man insmod
     bash# man rmmod
     bash# man depmod
     ___________________________________________________________________


  4. Save and Exit "make xconfig".  All the options which you selected
     is now saved into configuration file at /usr/src/linux/.config (dot
     config file).  And now, do -

     ___________________________________________________________________
     bash# make dep
     bash# make clean
     ___________________________________________________________________



  5. Read the following file (to gain some knowledge about kernel
     building. Tip: Use the color editor gvim
      for better
     readability.

     ___________________________________________________________________
     bash# gvim -R   /usr/src/linux/arch/i386/config.in
     bash# man less
     bash# less   /usr/src/linux/arch/i386/config.in
     Type 'h' for help and to navigate press i, j, k, l, h or arrow, page up/down keys.
     ___________________________________________________________________



  6. Now, give the make command -

     ___________________________________________________________________
             bash# cd /usr/src/linux
             bash# man nohup
             bash# nohup make bzImage &
             bash# tail -f nohup.out     (.... to monitor the progress)
     This will put the kernel in /usr/src/linux/arch/i386/boot/bzImage
             bash# man tail
     ___________________________________________________________________



  7. After bzImage is successful, copy the kernel image to /boot
     directory.  You must copy the new kernel image to /boot directory,
     otherwise the new kernel may not boot.  And then read the manual
     page on lilo (see also  ) and see the ``sample lilo.conf'' file.  Always
     give a date extension to the filename as below:

     ___________________________________________________________________
     bash# cp /usr/src/linux/arch/i386/boot/bzImage     /boot/bzImage.myker.26mar2001
     bash# man lilo
     bash# man lilo.conf
     And edit /etc/lilo.conf file and put these lines -
             image=/boot/bzImage.myker.26mar2001
             label=myker
             root=/dev/hda1
             read-only
     You can check device name for 'root=' with the command -
             bash# df   /boot
     ___________________________________________________________________



  8. Now give

     ___________________________________________________________________
     bash# lilo
     bash# lilo -q
     ___________________________________________________________________


  You must re-run lilo even if entry 'myker' exists, everytime you cre�
  ate a new bzImage.



  9. Reboot the machine and at lilo press tab key and type 'myker' If it
     boots then you did a good job! Otherwise at lilo select your old
     kernel, boot and re-try all over again. Your old kernel is still
     INTACT and SAFE at say /boot/vmlinuz-2.0.34-0.6



  10.
     Loadable Modules: Check for insmod command which is extensively
     used for loading the modules.

     ___________________________________________________________________
     bash# man insmod
     bash# insmod
     bash# rpm -i /mnt/cdrom/Redhat/RPMS/modutils*.rpm
     ___________________________________________________________________



  The step given below may not be required but is needed only for emer�
  gencies where your /lib/modules files are damaged. If you already have
  the /lib/modules directory and in case you want replace them use the
  --force to replace the package and select appropriate cpu architec�
  ture.

  For new versions of linux redhat linux 6.0 and later, the kernel mod�
  ules are included with kernel-2.2*.rpm. Install the loadable modules
  and the kernel with

  ______________________________________________________________________
          This will list the already installed package.
  bash# rpm -qa | grep -i kernel

  bash# rpm -U --force  /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i686.rpm
  (or)
  bash# rpm -U --force  /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i586.rpm
  (or)
  bash# rpm -U --force  /mnt/cdrom/Redhat/RPMS/kernel-2.2.14-5.0.i386.rpm
  ______________________________________________________________________



  This is only for old versions of redhat linux 5.2 and before.  Boot
  new kernel and install the loadable modules from RedHat Linux "con�
  trib" cdrom

  ______________________________________________________________________
  bash# rpm -i /mnt/cdrom/contrib/kernel-modules*.rpm
  ....(For old linux systems which do not have insmod pre-installed)
  ______________________________________________________________________



  11.
     This step is required ONLY if you had downloaded a new version of
     linux kernel source.  Loadable module are located in /lib/modules.

     ___________________________________________________________________
     bash# cd /usr/src/linux
     bash# make modules
     bash# make modules_install
     ___________________________________________________________________



  12.
     If your new kernel 'myker' boots and works properly, you can create
     the boot disk. Insert a blank floppy into floppy drive and -

     ___________________________________________________________________
     bash# cd /usr/src/linux
     bash# make bzdisk
     See also mkbootdisk -
     bash# rpm -i mkbootdisk*.rpm
     bash# man mkbootdisk
     ___________________________________________________________________



  2.1.  Troublshoot Common Mistakes

  The following mistake is commited very frequently by new users.

  If your new kernel does not boot and you get -

  ______________________________________________________________________
  Warning: unable to open an initial console
  Kernel panic: no init found. Try passing init= option to kernel
  ______________________________________________________________________


  The problem is that you did not set the "root=" parameter properly in
  the /etc/lilo.conf. In my case, I used root=/dev/hda1 which is having
  the root partition "/". You must properly point the root device in
  your lilo.conf, it can be like /dev/hdb2 or /dev/hda7.

  The kernel looks for the init command which is located in /sbin/init.
  And /sbin directory lives on the root partition.  For details see -

  ______________________________________________________________________
  bash# man init
  ______________________________________________________________________



  2.2.  Sample lilo.conf

  Given below is a sample /etc/lilo.conf file. You should follow the
  naming conventions like ker2217 (for kernel 2.2.17), ker2214 (for
  kernel 2.2.14).  You can have many kernel images on the same /boot
  system.  On my machine I have something like:



  ______________________________________________________________________
  boot=/dev/hda
  map=/boot/map
  install=/boot/boot.b
  prompt
  timeout=50
  default=firewall

  image=/boot/vmlinuz-2.2.14-5.0
          label=ker2214
          read-only
          root=/dev/hda9

  image=/boot/vmlinuz-2.2.17-14
          label=ker2217
          read-only
          root=/dev/hda9

  #image=/usr/src/linux/arch/i386/boot/bzImage
  #       label=myker
  #       root=/dev/hda7
  #       read-only

  image=/boot/bzImage.myker.11feb2001
          label=myker11feb
          root=/dev/hda9
          read-only

  image=/boot/bzImage.myker.01jan2001
          label=myker01jan
          root=/dev/hda9
          read-only

  image=/boot/bzImage.myker-firewall.16mar2001
          label=firewall
          root=/dev/hda9
          read-only
  ______________________________________________________________________


	
	
	
		
	
	
			
		
		
		
		
	
	


		
Sitemap | Contact Us