The kernel version after the installation of Fedora 8 is 2.6.23.1-42. fc8-i686, want to build a kernel tree, in fact, there are several reasons, I heard that many of the release version of the kernel has been specially configured, so some aspects are not suitable for writing Linux modules, etc, it is also good to have more hands-on operations.
The selected kernel version is the same as that of the release version. 2.6.23.1, some of them are recommended to compile a new version, but they are afraid that these tools are not suitable. Therefore, there are fewer estimation errors for similar compilation and release versions.
1. Download linux-2.6.23.1.tar.bz2 and save it in/usr/src/kernel /.
2. Tar-xjvf linux-2.6.23.1.tar.bz2, decompress the kernel file, and enter the Directory
3. Execute make mrproper
4. Start to configure the kernel. I select the default configuration, make defconfig
5. It takes quite a while to compile the kernel make.
6. Make modules
7. Installation module make modules_install
8. Execute make install,
Article Source: feino Network (www.diybl.com): http://www.diybl.com/course/6_system/linux/Linuxjs/200896/139482.html
// Hello. c
# Include <Linux/init. h>
# Include <Linux/module. h>
Module_license ("dual BSD/GPL ");
Static int hello_init (void)
{
Printk (kern_alert "Hello world \ n ");
Return 0;
}
Static void hello_exit (void)
{
Printk (kern_alert "Goodbye, boy \ n ");
}
Module_init (hello_init );
Module_exit (hello_exit );
// Makefile
OBJ-M: = Hello. o
PWD: = $ (shell PWD)
Kver: =$ (shell uname-R)
Kdir: =/lib/modules/$ (kver)/build
ALL:
$ (Make)-C $ (kdir) M = $ (PWD) Modules
Clean:
Rm-f *. O *. Ko *. Mod. C. Hello *
Then, you can run the make command on the terminal to compile the module.
If no kernel tree exists and the above MAKEFILE file is used for compilation, it will not succeed. By default, fedora6 does not have a kernel tree and needs to be re-established.