Difference between revisions of "Debian Kernel"

From YobiWiki
Jump to navigation Jump to search
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
==Kernel compilation==
 
==Kernel compilation==
 
* Use make-kpkg to create a real Debian package with your home-made kernel and install this package
 
* Use make-kpkg to create a real Debian package with your home-made kernel and install this package
  +
** Check /etc/kernel.pkg.conf
 
* My method: a simple script /usr/src/make-kernel.sh, to use it enter the right kernel-tree as normal user then ../make-kernel.sh
 
* My method: a simple script /usr/src/make-kernel.sh, to use it enter the right kernel-tree as normal user then ../make-kernel.sh
#!/bin/bash
+
<source lang=bash>
  +
#!/bin/bash
REVISION="3.06.Mercure"
+
REVISION="3.06.Mercure"
APPEND="-d600"
+
APPEND="-d600"
make-kpkg --rootcmd fakeroot clean 2>&1 |tee ../trace.txt
 
make-kpkg --rootcmd fakeroot --us --uc --revision $REVISION --append-to-version $APPEND kernel_image 2>&1 |tee -a ../trace.txt
+
make-kpkg --rootcmd fakeroot clean 2>&1 |tee ../trace.txt
make-kpkg --rootcmd fakeroot modules_clean 2>&1 |tee -a ../trace.txt
+
make-kpkg --rootcmd fakeroot --us --uc --revision $REVISION --append-to-version $APPEND kernel_image 2>&1 |tee -a ../trace.txt
make-kpkg --rootcmd fakeroot --us --uc --revision $REVISION --append-to-version $APPEND modules_image 2>&1 |tee -a ../trace.txt
+
make-kpkg --rootcmd fakeroot modules_clean 2>&1 |tee -a ../trace.txt
 
make-kpkg --rootcmd fakeroot --us --uc --revision $REVISION --append-to-version $APPEND modules_image 2>&1 |tee -a ../trace.txt
  +
</source>
 
* modules is only if there are out of kernel-tree modules to compile (such as ndiswrapped), regular kernel modules are already compiled with make-kpkg kernel_image
 
* modules is only if there are out of kernel-tree modules to compile (such as ndiswrapped), regular kernel modules are already compiled with make-kpkg kernel_image
 
* Remark: I could never get a kernel with initrd booting properly :-(
 
* Remark: I could never get a kernel with initrd booting properly :-(
Line 18: Line 21:
 
To know which version of gcc was used to compile a kernel:
 
To know which version of gcc was used to compile a kernel:
 
cat /proc/version
 
cat /proc/version
  +
 
==Safe remote reboot==
 
==Safe remote reboot==
 
copied from http://www.wains.be/index.php/2008/02/26/remotely-upgrade-your-kernel-without-dreading-a-kernel-panic/
 
copied from http://www.wains.be/index.php/2008/02/26/remotely-upgrade-your-kernel-without-dreading-a-kernel-panic/

Latest revision as of 17:35, 28 March 2008

Kernel compilation

  • Use make-kpkg to create a real Debian package with your home-made kernel and install this package
    • Check /etc/kernel.pkg.conf
  • My method: a simple script /usr/src/make-kernel.sh, to use it enter the right kernel-tree as normal user then ../make-kernel.sh
#!/bin/bash
REVISION="3.06.Mercure"
APPEND="-d600"
make-kpkg --rootcmd fakeroot clean 2>&1 |tee ../trace.txt
make-kpkg --rootcmd fakeroot --us --uc --revision $REVISION --append-to-version $APPEND kernel_image 2>&1 |tee -a ../trace.txt
make-kpkg --rootcmd fakeroot modules_clean 2>&1 |tee -a ../trace.txt
make-kpkg --rootcmd fakeroot --us --uc --revision $REVISION --append-to-version $APPEND modules_image 2>&1 |tee -a ../trace.txt
  • modules is only if there are out of kernel-tree modules to compile (such as ndiswrapped), regular kernel modules are already compiled with make-kpkg kernel_image
  • Remark: I could never get a kernel with initrd booting properly :-(
  • There should be an easier way to build modules, I never tried:
    • Use module-assistant package
    • E.g. to compile fuse: m-a a-i fuse
  • When you install a Debian kernel, of your own or from the feeds, you can always find the .config under /boot/config-<kernel version>

To know which version of gcc was used to compile a kernel:

cat /proc/version

Safe remote reboot

copied from http://www.wains.be/index.php/2008/02/26/remotely-upgrade-your-kernel-without-dreading-a-kernel-panic/

Tested on Debian Etch

If you’re trying to upgrade a kernel remotely, there’s always the risk of losing the machine by a kernel panic when rebooting.

In the following we will tell grub to try to boot the new kernel at least once, if it “kernel panics” the machine will reboot and boot with the working kernel instead.

Edit /boot/grub/menu.lst :

default         saved
timeout         5

# new kernel, not tested
title           Debian GNU/Linux, kernel 2.6.18-6-686
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.18-6-686 root=/dev/sda1 ro panic=5
initrd          /boot/initrd.img-2.6.18-6-686
savedefault 1

# tested and working kernel
title           Debian GNU/Linux, kernel 2.6.18-5-686
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.18-5-686 root=/dev/sda1 ro
initrd          /boot/initrd.img-2.6.18-5-686
savedefault

When you’re done setting grub up, type the following command, it will tell grub to boot the first kernel entry once :

# grub-set-default 0

To recap :

In case of a kernel panic, the system will usually sit and wait forever for someone to physically act on the machine.

There are several ways to tell the system to reboot after 5 seconds when a kernel panic occurs :

in /proc :

# echo "5" > /proc/sys/kernel/panic

in /etc/sysctl.conf :

kernel.panic = 5

in grub config :
“panic=5″ at the end of the kernel line in the kernel entry

“savedefault 1″ in the first kernel entry is telling grub to pick up the second entry on next boot.

When the new kernel is tested and working, you can remove “panic=5″ and “savedefault” lines and set “default 0″ instead of “default saved”.

Keep in mind that 0 for grub means “1st kernel entry”. 1 is the..well, you got it.. “second kernel entry”.
Also, if the system hangs for some reason but doesn’t panic, you’re still stuck deep in the mud.