Difference between revisions of "Debian-kernel"

From Bashlinux
Jump to: navigation, search
(talk)
Line 2: Line 2:
 
= GNU/Debian Kernel setup =
 
= GNU/Debian Kernel setup =
   
== Kernel from Debian repositories ==
+
== How to build the Kernel from Debian repositories ==
   
 
=== Get the sources and setup the environment ===
 
=== Get the sources and setup the environment ===
Line 68: Line 68:
   
   
== Real-Time Vanilla Kernel ==
+
== How to build Real-Time Vanilla Kernel for Debian ==
   
 
=== Get sources and setup environment ===
 
=== Get sources and setup environment ===

Revision as of 05:42, 12 June 2012

GNU/Debian Kernel setup

How to build the Kernel from Debian repositories

Get the sources and setup the environment

  1. Install the proper packages to build the kernel
 apt-get install ncurses-dev fakeroot kernel-package build-essential devscripts
 
  1. Build kernel dependencies
 apt-get build-dep linux-2.6
 
  1. Get Debian kernel sources
 apt-get source linux-2.6
 
  • Note that `deb-src` must be present on `/etc/apt/sources.list` file

Build Debian Kernel

  1. If kernel is patched, check it twice as follows
 make -f debian/rules source-all
 
  • First time must fail
  • If building all kernel related packages, then do as follows. It takes almos 40GB on Hard drive.
 ~/src/linux-2.6-2.6.24~rc6$ debuild -e DEBIAN_KERNEL_JOBS=${NR_CPUS}
 
  • If building an specific architecture, then
 fakeroot make -f debian/rules.gen setup_i386_none_k7
 
  • This will build the packages for AMD K7
  • If there is any change to apply, then go the the `k7` folder and config the kernel
 debian/build/build_i386_none_k7
 make menuconfig
 
  • Build the kernel
 fakeroot make -f debian/rules.gen binary-arch_i386_none_k7 binary-indep DEBIAN_KERNEL_JOBS=${NR_CPUS}
 


Install Debian Kernel

Kernel packages will be created in `/usr/src` folder. Install them as any other deb package

 dpkg -i linux*.deb
 


How to build Real-Time Vanilla Kernel for Debian

Get sources and setup environment

  1. Create `vanilla` folder in `/usr/src` and change directory to such location
 mkdir -p /usr/src/vanilla
 cd !$
 
  1. Download the latest rt patch
http://www.kernel.org/pub/linux/kernel/projects/rt/
  1. Download the matched kernel for the proper patch downloaded in previous step
http://www.kernel.org/pub/linux/kernel/v2.6/
  1. Decompress both, the linux kernel sources and the patch
 tar jxvf *.bz2
 
  1. Patch the kernel
 cd linux-2.6.AA.BB
 patch -p1 <../patch-2.6.AA.BB-rtNN
 
  1. Create a link `linux` which points to the linux kernel sources
 ln -s /usr/src/vanilla/linux-2.6.AA.BB /usr/src/linux
 


Build RT Kernel

  1. Go to the linux source folder
  2. Configure the kernel, if necessary `make menuconfig`
    • Backup the old config file
   cd /usr/src/linux
   cp .config config.yy-mm-dd
   
  • When finish save your changes
  • Build the bzImage
 cd /usr/src/linux
 make
 


Install RT Kernel

  • If only modules are needed, then use `make modules`
  • Install the modules
 make modules_install
 
  1. Install the kernel, usually locate on `arch/MY_ARCH/boot` in kernel sources
 cp arch/MY_ARCH/boot/bzImage /boot/vmlinuz-2.6.AA.BB-rtNN
 
  1. Create initial root filesystem
 cd /usr/src/linux
 update-inintramfs -c -k 2.6.AA-BB-rtNN
 
  1. Add the proper entry to grub in `/boot/grub/menu.lst`
 title		RT kernel 2.6.AA.BB-rtNN
 root		(hd0,0)
 kernel		/boot/vmlinuz-2.6.AA.BB-rtNN root=/dev/hda1 ro
 initrd		/boot/initrd.img-2.6.AA.BB-rtNN
 
  • TIP: if `default` parameter is set to `0` at the beginning of the `menu.lst` file, then try to put this entry at the top of the entries list.