Linux设备驱动(0)——构建内核源码树

1.寻找相关内核

apt-cache search linux-source
linux-source - Linux kernel source with Ubuntu patches
linux-source-2.6.32 - Linux kernel source for version 2.6.32 with Ubuntu patches

2.下载内核

sudo apt-get install linux-source-2.6.32
3.下载完成,可以看到内核源码:/usr/src/linux-source-2.6.32.tar.bz2

4.解压源码:

cd /usr/src/
sudo tar -xjvf linux-source-2.6.32.tar.bz2

5.进入内核目录,配置,编译:

sudo make oldconfig //从目录运行的系统中生成一份.config
sudo make bzImage
sudo make modules
sudo make modules_install
sudo make install

6.这时,在/boot/目录中:

$ ls /boot/ -l
total 21216
-rw-r--r-- 1 root root  646334 2011-07-08 09:00 abi-2.6.32-33-generic
-rw-r--r-- 1 root root  110252 2015-03-02 21:57 config-2.6.32.11+drm33.2
-rw-r--r-- 1 root root  110578 2011-07-08 09:00 config-2.6.32-33-generic
drwxr-xr-x 3 root root    4096 2015-02-02 12:50 grub
-rw-r--r-- 1 root root 8369062 2015-01-28 23:32 initrd.img-2.6.32-33-generic
-rw-r--r-- 1 root root  160280 2010-03-23 17:40 memtest86+.bin
-rw-r--r-- 1 root root 2099740 2015-03-02 21:57 System.map-2.6.32.11+drm33.2
-rw-r--r-- 1 root root 2156784 2011-07-08 09:00 System.map-2.6.32-33-generic
-rw-r--r-- 1 root root    1336 2011-07-08 09:03 vmcoreinfo-2.6.32-33-generic
-rw-r--r-- 1 root root 4000160 2015-03-02 21:57 vmlinuz-2.6.32.11+drm33.2
-rw-r--r-- 1 root root 4050464 2011-07-08 17:00 vmlinuz-2.6.32-33-generic<span style="font-family:Arial, Helvetica, sans-serif;"><span style="white-space: normal;">
</span></span>

在/lib/modules/目录中:

$ ls /lib/modules/
2.6.32.11+drm33.2  2.6.32-33-generic

7.制作initrd.img:

sudo mkinitramfs 2.6.32.11+drm33.2 -o /boot/initrd.img-2.6.32.11+drm33.2
8.更新grub:

sudo update-grub
重启,在选择操作系统时便多了一项: 2.6.32.11+drm33.2

选中它便可从你编译的内核启动,不知为何,我的电脑启动的过程特别慢,需要2,3分钟。

编译过程如出现;(ld: /ubuntu/omnibook/sections.lds: No such file: No such file or directory )

解决方法:
在/usr/src/linux-source-2.6.32/ubuntu/omnibook/Makefile 中
ifeq ($(KERNELRELEASE),)
 
# Support for direct Makefile invocation
的前面增加:
PWD=$(shell pwd)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值