Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


lpi2:kernel_kompilieren

Dies ist eine alte Version des Dokuments!


Kernel kompilieren

Debian 7

cd
wget -O - https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.13.2.tar.xz | tar xJ
ln -s ~/linux-3.13.2 /usr/src/linux
grep -c '^processor' /proc/cpuinfo
make -j 8 localmodconfig

oder

make -j 8 localyesconfig
sudo make modules_install install

Doku

Eigenes Kernel-Modul schreiben

Keine Angst, nur ein ganz einfaches „Hello World“ Beispiel …

Debian

cd
aptitude install linux-source-xxx
tar xjf /usr/src/linux-source-xxx
mkdir hello
vi hello.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>

static int hello_init(void)
{
  printk(KERN_ALERT "Hello World!\n");
  return 0;
}

static void hello_exit(void)
{
  printk(KERN_ALERT "Good bye world!\n");
}

module_init(hello_init);
module_exit(hello_exit);


MODULE_LICENSE("GPL");
MODULE_AUTHOR("me");
vi Makefile
obj-m   := hello.o
make -C ../linux-source-2.6.18/ SUBDIRS=$PWD modules
lpi2/kernel_kompilieren.1391975280.txt.gz · Zuletzt geändert: 2014/02/09 19:48 von ingo_wichmann