如何更新/替换ubuntu16.04内核

from: https://blog.csdn.net/xuyong7/article/details/54696172

1.配置编译工具

#apt-get install libncurses5-dev build-essential kernel-package

2.下载内核代码

因为kernel.org的代码和ubuntu内核的代码并不完全一致,所以直接从kernel.org下载下来的代码无法确保编译后可以成功运行于老的ubuntu平台,所以应该使用ubuntu的最新的内核代码

下载ubuntu最新的内核代码

#sudo apt-cache search linux-source

结果如下
linux-source - Linux kernel source with Ubuntu patches
linux-source-4.4.0 - Linux kernel source for version 4.4.0 with Ubuntu patches
linux-source-4.8.0 - Linux kernel source for version 4.8.0 with Ubuntu patches

选择比较新的4.8的版本

#sudo apt-get install linux-source-4.8.0

代码会下载在/usr/src下,里面内容如下:

drwxr-xr-x 27 root root 4096 421  2016 linux-headers-4.4.0-21
drwxr-xr-x  7 root root 4096 421  2016 linux-headers-4.4.0-21-generic
drwxr-xr-x 27 root root 4096 122 21:35 linux-headers-4.4.0-59
drwxr-xr-x  7 root root 4096 122 21:35 linux-headers-4.4.0-59-generic
drwxr-xr-x  4 root root 4096 122 23:00 linux-source-4.8.0
lrwxrwxrwx  1 root root   45 1222 04:36 linux-source-4.8.0.tar.bz2 -> linux-source-4.8.0/linux-source-4.8.0.tar.bz2

编译与替换

1.拷贝到其他工作目录
2.在源代码目录执行

cp  arch/x86/configs/x86_64_defconfig   .config

3.编译

make menuconfig
make
sudo make moudules_install
sudo make install
sudo reboot

验证

重启后执行uanme -a 命令,查看内核版本,会发现内核版本已经从4.4.0-59变为4.8.11

意义

编译/替换内核之后,可以获得与当前内核版本相匹配的头文件,方便进行驱动开发。另外可以获得带符号的vmlinux,可以方便的进行内核的调试与学习。

猜你喜欢

转载自blog.csdn.net/xringm/article/details/79914807