Create a kernel tree and compile the kernel module

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.