Debian编译内核源码
2013-05-16 22:31
489 查看
安装内核源码
apt-cache search kernel-source
uname -r
内核源文件:
apt-get install linux-tree-xxxx
apt-get install linux-source-xxxx
内核头文件:
apt-get install linux-headers-xxxx
内核编译程序:
apt-get install linux-kbuild-xxxx
内核镜像做成deb的工具
apt-get install kernel-package
制做initrd镜像
apt-get install initrd-tools
编译内核:
Debian kernel-image文件的名字格式如下:
kernel-image-(kernel-version)(--append-to-version)_(--revision)_(architecture).deb
如果我们使用了--append-to-version,我们就不需要担心apt-get会试着更新我们的内核了
安装内核:
kernel-tree-x.x.x (或2.6.12以后是linux-tree-x.x.x)
这个包依赖两个包:kernel-source-x.x.x 和 kernel-patch-debian-x.x.x
这两个包就分别是源代码和debian的补丁。
编写内核模块
编写了一个内核模块程序,源代码如下:
/* hello.c */
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
static int hello_init(void)
{
printk(KERN_ALERT "Hello, linux kernel module\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, I've created a linux kernel module sucessfully\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
你需要这此源程序编写一个makefile,内容如下:
#Makefile for hello.c file
#
KERNEL_DIR:=/usr/src/linux
obj-m:=hello.o
default:
$(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules
clean:
$(RM) .*.cmd *.mod.c *.o *.ko -r .tmp
KERNEL_DIR是指内核源代码头文件所在目录的上一级目录,通常就是指内核源代码目录。
编写好makefile后就可以输入make命令生成hello.ko内核模块了,然后你可以用:
insmode hello.ko
命令来加入内核模块,然后用:
rmmod hello
来删除内核模块。
删除旧的内核
1. 对着/boot/grub/menu.lst里的内容删去你不要的。最后再把/boot/grub/menu.lst里相应的项目删掉。 包括
/lib/modules/2.6.24-xxxx
/boot/vmlinuz-2.6.24-xxxx
/boot/initrd-2.6.24-xxxx
/boot/System.map-2.6.24-xxxx
2. dpkg --get-selections | grep linux 查看自己系统安装了多少内核
sudo apt-get remove linux-image-2.6.24-XXX
sudo apt-get remove linux-headers-2.6.24-XXX
阅读(1632) | 评论(0) | 转发(0) |
0
上一篇:转:GAS 的AT&T的语法规则
下一篇:一篇气死了99名老师的中学生作文
相关热门文章
Linux内核源码分析--内核启动...
37600 ティファニー ネックレ...
Linux内核源码分析--内核启动...
epoll的优点
使用LSM实现自己的访问控制...
linux 常见服务端口
什么是shell
linux socket的bug??
linux的线程是否受到了保护?...
一个适用于windows和linux的抓...
shell将变量当命令执行问题【...
深入理解Linux网络技术内幕-设...
高性能网络I/O框架-netmap源码...
深入理解Linux网络技术内幕-...
Linux下bin文件的安装
给主人留下些什么吧!~~
评论热议
apt-cache search kernel-source
uname -r
内核源文件:
apt-get install linux-tree-xxxx
apt-get install linux-source-xxxx
内核头文件:
apt-get install linux-headers-xxxx
内核编译程序:
apt-get install linux-kbuild-xxxx
内核镜像做成deb的工具
apt-get install kernel-package
制做initrd镜像
apt-get install initrd-tools
编译内核:
make-kpkg --initrd --revision=custom.1.0 kernel_image
Debian kernel-image文件的名字格式如下:
kernel-image-(kernel-version)(--append-to-version)_(--revision)_(architecture).deb
如果我们使用了--append-to-version,我们就不需要担心apt-get会试着更新我们的内核了
安装内核:
dpkg -i ../linux-image-2.6.18-subarchitecture_custom.1.0_s390.deb
kernel-tree-x.x.x (或2.6.12以后是linux-tree-x.x.x)
这个包依赖两个包:kernel-source-x.x.x 和 kernel-patch-debian-x.x.x
这两个包就分别是源代码和debian的补丁。
编写内核模块
编写了一个内核模块程序,源代码如下:
/* hello.c */
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
static int hello_init(void)
{
printk(KERN_ALERT "Hello, linux kernel module\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, I've created a linux kernel module sucessfully\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
你需要这此源程序编写一个makefile,内容如下:
#Makefile for hello.c file
#
KERNEL_DIR:=/usr/src/linux
obj-m:=hello.o
default:
$(MAKE) -C $(KERNEL_DIR) SUBDIRS=$(PWD) modules
clean:
$(RM) .*.cmd *.mod.c *.o *.ko -r .tmp
KERNEL_DIR是指内核源代码头文件所在目录的上一级目录,通常就是指内核源代码目录。
编写好makefile后就可以输入make命令生成hello.ko内核模块了,然后你可以用:
insmode hello.ko
命令来加入内核模块,然后用:
rmmod hello
来删除内核模块。
删除旧的内核
1. 对着/boot/grub/menu.lst里的内容删去你不要的。最后再把/boot/grub/menu.lst里相应的项目删掉。 包括
/lib/modules/2.6.24-xxxx
/boot/vmlinuz-2.6.24-xxxx
/boot/initrd-2.6.24-xxxx
/boot/System.map-2.6.24-xxxx
2. dpkg --get-selections | grep linux 查看自己系统安装了多少内核
sudo apt-get remove linux-image-2.6.24-XXX
sudo apt-get remove linux-headers-2.6.24-XXX
阅读(1632) | 评论(0) | 转发(0) |
0
上一篇:转:GAS 的AT&T的语法规则
下一篇:一篇气死了99名老师的中学生作文
相关热门文章
Linux内核源码分析--内核启动...
37600 ティファニー ネックレ...
Linux内核源码分析--内核启动...
epoll的优点
使用LSM实现自己的访问控制...
linux 常见服务端口
什么是shell
linux socket的bug??
linux的线程是否受到了保护?...
一个适用于windows和linux的抓...
shell将变量当命令执行问题【...
深入理解Linux网络技术内幕-设...
高性能网络I/O框架-netmap源码...
深入理解Linux网络技术内幕-...
Linux下bin文件的安装
给主人留下些什么吧!~~
评论热议
相关文章推荐
- 编译Debian内核源码
- debian下配置dynamic printk以及重新编译内核
- 编译Debian 2.6.15.6 内核
- 在Debian上安装完整的内核源码
- Debian编译内核教程
- Debian 下编译内核过程
- linux 驱动 指定下载的内核源码树编译
- ubuntu 16.04内核源码编译
- android-4.0源码编译及内核编译(android-gldfish-2.6.29)
- centos获取内核源码,编译内核,编译内核模块
- 最新最全网络首发安卓4.0源码及内核下载编译教程(图文详解)
- debian6编译内核(linux2.6.34)步骤(适合初学者)
- android内核源码编译个人方法和错误记录
- 在MAC系统中编译ANDROID源码与模拟器内核GoldFish
- Debian编译升级内核(could not load /lib/modules/2.6.28/modules.dep问题)
- debian下源码编译安装apache
- 编译Android goldfish内核源码
- debian_squeeze编译内核
- Debian 总结 安装 和使用 内核编译(三)
- Android系统篇之----编写简单的驱动程序并且将其编译到内核源码中