Chinaunix首页 | 论坛 | 博客
  • 博客访问: 937243
  • 博文数量: 173
  • 博客积分: 3436
  • 博客等级: 中校
  • 技术积分: 1886
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-07 09:29
文章分类

全部博文(173)

文章存档

2016年(6)

2015年(10)

2014年(14)

2013年(8)

2012年(36)

2011年(63)

2010年(19)

2009年(17)

分类: LINUX

2014-04-23 13:48:19


1. apt-get install linux-source

cp /usr/src/linux-source-3.2.0.tar.bz2 ~
cd ~
tar -xvf linux-source-3.2.0.tar.bz2

编译之前需要做的事:
cp /boot/ config -  . config
make menuconfig #进去后直接退出,退出时选择保存
make
sudo make modules_install
sudo make install
sudo reboot
uname -r #check if succeed

使用新内核后,通过lsmod无法查看modules 依赖情况。
原因:.config内 CONFIG_MODULE_FORCE_LOAD,CONFIG_MODULE_UNLOAD未使能。
Well caught - you showed the right thing anyway.

 Code:
Symbol: MODULE_UNLOAD [=n]  
tells that
 Code:
modprobe -r
will not work on your system.

 The kernel therefore has no need to keep track of how many users a modules has to prevent you from unloading a module that is in use.
 If you want to see number of users and so on in lsmod, rebuild your kernel with Module Unloading enabled.
 What you have now is not wrong - its a user option.


 Code:
MODULE_FORCE_UNLOAD [=n]
is a good thing. It prevents you from forcefully unloading modules that are in use.
 This can be a very bad thing for the devices using the modules.

使用如下命令编译外部模块:

make –C M=

其中-C表明make要调用下的Makefile,该Makefile就是内核的Makefile,M为该Makefile的参数,指定外部模块源码的路径。当Makefile接收到M参数时,就默认编译外部模块。

例如,当前目录下存放一个外部模块的源码,其编译命令如下:

make –C /lib/modules/`uname -r`/buildM=`pwd`

其中uname –r获取当前运行内核的版本,pwd为当前源码路径,将其展开之后为:

make –C /lib/modules/ 2.6.42.9/buildM=/home/user/hello

其中/lib/modules/ 2.6.42.9/build是指向内核源码目录的符号链接。

编译完成之后,要安装驱动时,调用如下命令:

make –C /lib/modules/`uname -r`/buildM=`pwd` modules_install

编译目标

modules

编译外部模块,默认目标就是modules

modules_install

安装编译成功了的外部模块,默认的安装目录为/lib/modules//extra/,前缀可以同过INSTALL_MOD_PATH指定



第一步:准备工作


然后安装编译内核时需要的工具:

sudo apt-get install build-essential kernel-package libncurses5-dev libqt3-headers

 build-essential  (基本的编程库(gcc, make等)


 kernel-package   (Debian 系统里生成 kernel-image 的一些配置文件和工具)
 libncurses5-dev  (meke menuconfig要调用的)
 libqt3-headers   (make xconfig要调用的)

其他工具在升级过程中可以按提示安装


第二步:下载内核源代码linux-3.2.20.tar.gz
请到官网下载最新版本linux-3.2.20.tar.gz内核
假设下载在home/~目录,然后解压到/usr/src/3.2.20目录里
cd ~
tar xvf linux-3.2.20.tar.gz
解压后会在~生成新文件夹linux-3.2.20


第三步:配置
把正在使用中的内核配置文件/boot/config-3.2.0-23-generic-pae 拷到linux-3.2.20目录下
cp /boot/config-3.2.0-23-generic-pae  ~/linux-3.2.20/.config
执行:
cd ~/linux-2.6.34
make oldconfig  (利用pc机上自带的配置文件,再加上更新)
然后根据实际情况选择每一项的yes/no


第四步:开如编译安装新内核
执行: make mrproper   (清除以前曾经编译过的旧文件,如果你是第一次编译,可不执行)
执行: make     (编译,可以加-j4,如果你CPU是双核心,够牛的话,因为可以提高速度)
然后:sudo make install  
再: make modules  (编译模块)
再:sudo make modules_install  (安装模块

阅读(1283) | 评论(0) | 转发(0) |
0

上一篇:an SITD error with EHCI

下一篇:misc tips

给主人留下些什么吧!~~