Build a kernel tree in Ubuntu 12.04 LTS

Source: Internet
Author: User

Ubuntu 12.04 LTS sets up the kernel tree. Its system is ubuntu 12.04 LTS. The specific steps are as follows: (1) Check the kernel version of the system. The command is uname-r, output Information: ** 3.8.0-29-generic ** indicates that the kernel version is 3.8.0. (2) In the directory/usr/src directory issued the current file: ** linux-headers-3.8.0-29 linux-headers-3.8.0-29-generic ** from the file name can be seen that the two directories only have the header file of the Code. (3) test whether the helloworld module can be dynamically loaded only with header files (for the generation method, refer to linux device driver development). (4) hello. c file content: # include <linux/init. h> # include <linux/module. h> MODULE_LICENSE ("Dual BSD/GPL"); static int hello_init (void) {printk (KERN_EMERG "Hello world \ n"); return 0;} static int hello_exit (void) {printk (KERN_EMERG "Goodbye, hello world! \ N "); return 0;} module_init (hello_init); module_exit (hello_exit); Makefile file content: ifneq ($ (KERNELRELEASE),) obj-m: = hello. o else KDIR: =/lib/modules/3.8.0-29-generic/build all: make-C $ (KDIR) M = $ (PWD) modules clean: rm-f *. ko *. o *. mod *. mod. c * sysmvers endif (5) Run: sudo insmod hello. ko sudo rmmod hello. ko terminal does not respond, but the output information is found in/var/log/syslog: The module has been successfully loaded by the kernel.

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.