linux内核升级图文攻略.docx
- 文档编号:27591663
- 上传时间:2023-07-03
- 格式:DOCX
- 页数:8
- 大小:21.98KB
linux内核升级图文攻略.docx
《linux内核升级图文攻略.docx》由会员分享,可在线阅读,更多相关《linux内核升级图文攻略.docx(8页珍藏版)》请在冰豆网上搜索。
linux内核升级图文攻略
linux内核升级图文攻略
一、Linux内核概览Linux是一个一体化内核(monolithickernel)系统。
设备驱动程序可以完全访问硬件。
Linux内的设备驱动程序可以方便地以模块化(modularize)的形式设置,并在系统运行期间可直接装载或卸载。
1.linux内核linux操作系统是一个用来和硬件打交道并为用户程序提供一个有限服务集的低级支撑软件。
一个计算机系统是一个硬件和软件的共生体,它们互相依赖,不可分割。
计算机的硬件,含有外围设备、处理器、内存、硬盘和其他的电子设备组成计算机的发动机。
但是没有软件来操作和控制它,自身是不能工作的。
完成这个控制工作的软件就称为操作系统,在Linux的术语中被称为“内核”,也可以称为“核心”。
Linux内核的主要模块(或组件)分以下几个部分:
.进程管理(processmanagement).定时器(timer).中断管理(interruptmanagement).内存管理(memorymanagement).模块管理(modulemanagement).虚拟文件系统接口(VFSlayer).文件系统(filesystem).设备驱动程序(devicedriver).进程间通信(inter-processcommunication).网络管理(networkmanagement.系统启动(systeminit)等操作系统功能的实现。
2.linux内核版本号Linux内核使用三种不同的版本编号方式。
.第一种方式用于1.0版本之前(包括1.0)。
第一个版本是0.01,紧接着是0.02、0.03、0.10、0.11、0.12、0.95、0.96、0.97、0.98、0.99和之后的1.0。
.第二种方式用于1.0之后到2.6,数字由三部分“A.B.C”,A代表主版本号,B代表次主版本号,C代表较小的末版本号。
只有在内核发生很大变化时(历史上只发生过两次,1994年的1.0,1996年的2.0),A才变化。
可以通过数字B来判断Linux是否稳定,偶数的B代表稳定版,奇数的B代表开发版。
C代表一些bug修复,安全更新,新特性和驱动的次数。
以版本2.4.0为例,2代表主版本号,4代表次版本号,0代表改动较小的末版本号。
在版本号中,序号的第二位为偶数的版本表明这是一个可以使用的稳定版本,如2.2.5;而序号的第二位为奇数的版本一般有一些新的东西加入,是个不一定很稳定的测试版本,如2.3.1。
这样稳定版本来源于上一个测试版升级版本号,而一个稳定版本发展到完全成熟后就不再发展。
.第三种方式从2004年2.6.0版本开始,使用一种“time-based”的方式。
3.0版本之前,是一种“A.B.C.D”的格式。
七年里,前两个数字A.B即“2.6”保持不变,C随着新版本的发布而增加,D代表一些bug修复,安全更新,添加新特性和驱动的次数。
3.0版本之后是“A.B.C”格式,B随着新版本的发布而增加,C代表一些bug修复,安全更新,新特性和驱动的次数。
第三种方式中不使用偶数代表稳定版,奇数代表开发版这样的命名方式。
举个例子:
3.7.0代表的不是开发版,而是稳定版!
linux内核升级时间图谱如下:
linux内核版本的详细表格如下(http:
//en.wikipedia.org/wiki/Linux_kernel#Version_numbering):
longtermsupport:
提供长期支持的内核版本stable:
稳定版本,而不是Beta测试版关系就是:
稳定版本不一定都提供长期支持,而提供长期支持的一定是稳定版本3.linux发行版Linux内核的发展过程中,我们还不得不提一下各种Linux发行版的作用,因为正是它们推动了Linux的应用,从而也让更多的人开始关注Linux。
一些组织或厂家,将Linux系统的内核与外围实用程序(Utilities)软件和文档包装起来,并提供一些系统安装界面和系统配置、设定与管理工具,就构成了一种发行版本(distribution),Linux的发行版本其实就是Linux核心再加上外围的实用程序组成的一个大软件包而已。
相对于Linux操作系统内核版本,发行版本的版本号随发布者的不同而不同,与Linux系统内核的版本号是相对独立的。
因此把SUSE、RedHat、Ubuntu、Slackware等直接说成是Linux是不确切的,它们是Linux的发行版本,更确切地说,应该叫做“以Linux为核心的操作系统软件包”。
根据GPL准则,这些发行版本虽然都源自一个内核,并且都有自己各自的贡献,但都没有自己的版权。
Linux的各个发行版本(distribution),都是使用Linus主导开发并发布的同一个Linux内核,因此在内核层不存在什么兼容性问题。
每个版本都不一样的感觉,只是在发行版本的最外层才有所体现,而绝不是Linux本身特别是内核不统一或是不兼容。
90年代初期Linux开始出现的时候,仅仅是以源代码形式出现,用户需要在其他操作系统下进行编译才能使用。
后来出现了一些正式版本。
目前最流行的几个正式版本有:
SUSE、RedHat、Fedora、Debian、Ubuntu、CentOS、Gentoo,等等。
用户可根据自己的经验和喜好选用合适的Linux发行版。
二、内核升级攻略1.查看linux内核版本:
#uname-r2.6.18-194.el52.下载新的内核版本:
去官网上下载最新的内核版本和对应的补丁:
https:
//www.kernel.org/我选的是3.2.14#wget-chttp:
//www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.14.tar.bz23.解压将所需文件复制到/usr/src下并解压。
(注:
如果/usr/src下的空间不够,将源文件放在别的目录下也是一样的)#cplinux-3.2.14.tar.gz/usr/src/#cd/usr/src/将文件解压到/usr/src/kernels#tar-xvflinux-3.2.14.tar.gz-C/usr/src/kernels4.清理文件清除掉以前升级留下的一些不正确文件。
#cd/usr/src/kernels/linux-3.2.14#yuminstallncurses-devel#升级ncurses#makemrporper#cp/boot/config-‘uname-r’/usr/src/kernels/linux3.2.14/.config#使用原来的配置文件5.通过菜单方式配置内核#cd/usr/src/kernels/linux-3.2.14#makemenuconfiglinux配置菜单如下图所示:
一定要勾选(输入y选中,M编译为模块)a、Generalsetup→[*]enabledeprecatedsysfsfeaturestosupportolduserspacetoolsb、Processortypeandfeatures→HighMemorySupport。
c、找到以下选中选项并选中:
networkingsupport→networkingoptions→networkpacketfilteringframework(netfilter)
(1)Corenetfilterconfiguration.勾中"Netfilterconnectiontrackingsupport"-mstate相关模块是依赖它的,不选则没有。
.将netbiosnameserviceprotocalsupport(new)编译成模块,不然后面升级iptables后启动时会出错.勾中"NetfilterXtablessupport(requiredforip_tables)"
(2)IP:
NetfilterConfiguration.将"IPv4connectiontrackingsupport(requireforNAT)"编译成模块。
.勾中IPtablessupport(requiredforfiltering/masq/NAT)。
.将"FullNAT"下的"MASQUERADEtargetsupport"和"REDIRECTtargetsupport"编译成模块6.编译并安装内核#makeclean//清除下内核编译的目标文件#makebzImage//生成内核文件#makemodules//编码模块#makemodules_install//安装模块#makeinstall//安装7.编辑开机菜单选项grub文件将default=1改为default=0#vim/etc/grub.conf#grub.confgeneratedbyanaconda##Notethatyoudonothavetorerungrubaftermakingchangestothisfile#NOTICE:
Youdonothavea/bootpartition.Thismeansthat#allkernelandinitrdpathsarerelativeto/,eg.#root(hd0,0)#kernel/boot/vmlinuz-versionroroot=/dev/sda1#initrd/boot/initrd-version.img#boot=/dev/sdadefault=0timeout=5splashimage=(hd0,0)/boot/grub/splash.xpm.gzhiddenmenutitleRedHatEnterpriseLinuxServer(3.2.14)root(hd0,0)kernel/boot/vmlinuz-3.2.14roroot=LABEL=/initrd/boot/initrd-3.2.14.imgtitleRedHatEnterpriseLinuxServer(2.6.18-274.el5)root(hd0,0)kernel/boot/vmlinuz-2.6.18-274.el5roroot=LABEL=/initrd/boot/initrd-2.6.18-274.el5.img【保存并退出】8.重启#shutdown-r"now"9.查看内核编译结果#uname-r3.2.14-rt24三、内核编译中遇到的错误及解决办法错误一、编译时出现错误提示Infileincludedfrom/usr/include/sys/time.h:
31,from/usr/include/linux/input.h:
12,fromsamples/hidraw/hid-example.c:
14:
/usr/include/sys/select.h:
78:
error:
conflictingtypesfor'fd_set'/usr/include/linux/types.h:
12:
error:
previousdeclarationof'fd_set'washereInfileincludedfrom/usr/include/linux/input.h:
14,fromsamples/hidraw/hid-example.c:
14:
/usr/include/sys/types.h:
46:
error:
conflictingtypesfor'loff_t'/usr/include/linux/types.h:
30:
error:
previousdeclarationof'loff_t'washere/usr/include/sys/types.h:
62:
error:
conflictingtypesfor'dev_t'/usr/include/linux/types.h:
13:
error:
previousdeclarationof'dev_t'washereInfileincludedfrom/usr/include/sys/types.h:
133,from/usr/include/linux/input.h:
14,fromsamples/hidraw/hid-example.c:
14:
/usr/include/time.h:
105:
error:
conflictingtypesfor'timer_t'/usr/include/linux/types.h:
22:
error:
previousdeclarationof'timer_t'washereInfileincludedfrom/usr/include/linux/input.h:
14,fromsamples/hidraw/hid-example.c:
14:
/usr/include/sys/types.h:
198:
error:
conflictingtypesfor'int64_t'/usr/include/linux/types.h:
98:
error:
previousdeclarationof'int64_t'washere/usr/include/sys/types.h:
204:
error:
conflictingtypesfor'u_int64_t'/usr/include/linux/types.h:
97:
error:
previousdeclarationof'u_int64_t'washereInfileincludedfrom/usr/include/linux/input.h:
14,fromsamples/hidraw/hid-example.c:
14:
/usr/include/sys/types.h:
235:
error:
conflictingtypesfor'blkcnt_t'/usr/include/linux/types.h:
114:
error:
previousdeclarationof'blkcnt_t'washeresamples/hidraw/hid-example.c:
15:
26:
error:
linux/hidraw.h:
Nosuchfileordirectorysamples/hidraw/hid-example.c:
Infunction'main':
samples/hidraw/hid-example.c:
48:
error:
storagesizeof'rpt_desc'isn'tknownsamples/hidraw/hid-example.c:
49:
error:
storagesizeof'info'isn'tknownsamples/hidraw/hid-example.c:
65:
error:
'HIDIOCGRDESCSIZE'undeclared(firstuseinthisfunction)samples/hidraw/hid-example.c:
65:
error:
(Eachundeclaredidentifierisreportedonlyoncesamples/hidraw/hid-example.c:
65:
error:
foreachfunctionitappearsin.)samples/hidraw/hid-example.c:
73:
error:
'HIDIOCGRDESC'undeclared(firstuseinthisfunction)samples/hidraw/hid-example.c:
84:
warning:
implicitdeclarationoffunction'HIDIOCGRAWNAME'samples/hidraw/hid-example.c:
91:
warning:
implicitdeclarationoffunction'HIDIOCGRAWPHYS'samples/hidraw/hid-example.c:
98:
error:
'HIDIOCGRAWINFO'undeclared(firstuseinthisfunction)samples/hidraw/hid-example.c:
49:
warning:
unusedvariable'info'samples/hidraw/hid-example.c:
48:
warning:
unusedvariable'rpt_desc'samples/hidraw/hid-example.c:
Infunction'bus_str':
samples/hidraw/hid-example.c:
171:
error:
'BUS_VIRTUAL'undeclared(firstuseinthisfunction)make[2]:
***[samples/hidraw/hid-example]Error1make[1]:
***[samples/hidraw]Error2make:
***[vmlinux]Error2解决方案:
#cpinclude/linux/hidraw.h/usr/include/linux/#cpinclude/linux/hid.h/usr/include/linux/#vimsamples/hidraw/hid-example.c(在Linux下编译程序有时会遇到这种问题,这貌似是一个Linux历史遗留问题:
把所有#include都提到最前面,把#include的包含放在其后,就可以编译通过了,之所以出现面的问题是存在循环引用所致。
)将13-15行的如下3行移动到33行以后。
13#include14#include15#include29#include30#include31#include32#include33#include【保存并退出】#vim/usr/include/linux/input.hline647#defineBUS_PCI0x01#defineBUS_ISAPNP0x02#defineBUS_USB0x03#defineBUS_HIL0x04#defineBUS_BLUETOOTH0x05/*以下一行为新增*/#defineBUS_VIRTUAL0x06#defineBUS_ISA0x10#defineBUS_I80420x11#defineBUS_XTKBD0x12#defineBUS_RS2320x13#defineBUS_GAMEPORT0x14#defineBUS_PARPORT0x15#defineBUS_AMIGA0x16#defineBUS_ADB0x17#defineBUS_I2C0x18#defineBUS_HOST0x19#defineBUS_GSC0x1A/*以下两行为新增*/#defineBUS_ATARI0x1B#defineBUS_SPI0x1C【保存并退出】再重新编译;错误二:
错误提示:
Kernelpanic—notsyncing:
vfs:
unabletomountrootfsonunkown—block(0,0)错误分析:
initrd-*.*.img文件有问题;未能成功挂载真正的根文件系统。
解决方法:
请你确认执行了makeinstall命令,我就因为没有执行这条命令而浪费了一周时间错误三:
错误提示:
Createrootdevicemkrootdev:
label/notfoundMountingrootfilesystemmount:
error2mountingext3mount:
error2mountingnoneswitchrootmountfailed:
22umount/initrd/devfailed:
2kernelpanic-notsynicncing:
Attemptedtokillinit.(错误提示是不是有点长,貌似错误很多哦,其实可能就一个原因导致)错误分析:
1、根文件系统找不到挂载点,修改grub.conf文件为root=/dev/*2、硬盘驱动未能找到,请看看你机器的硬盘是都是SATA盘,是的话同样恭喜你本文对你有帮助。
错误解决:
1.、修改grub.conf文件试试,具体修改点root=/dev/**指的是原系统中/分区的挂载点。
修改后,重启进入新内核系统,估计十有八九又会遇到如下错误提示:
Mountingrootfilesystemmount:
error6mountingext3mount:
error2mountingnoneswitchrootmountfailed:
22umount/initrd/devfailed:
2kernelpanic-notsynicncing:
Attemptedtokillinit.如果不幸被我言中,请接着往下看。
2、硬盘驱动未能成功找到,SCSI驱动有问题。
我在内核编译升级中遇到这个问题,对内核选项选了又选,方法试了很多种,错误依旧。
最终让我无意中选正确选项,成功升级内核。
具体选项是:
DeviceDrivers--------SCSIdevicesupport------SCSIlow-leveldrivers----SerialATA(SATA)support选为M,然后再选择相应的子选项,我选择了IntelPIIX/ICHSATAsupport(new)后机器就成功启动了。
错误四:
错误提示:
Enforcingmoderequestedbutnopolicyloaded.Haltingnow.kernelpanic-notsyncing:
Attenptedtokillinit!
错误分析:
原内核中启用了selinux,新内核未选择selinux的选项,不能成功启动。
解决方法:
修改grub.conf文件,在root=LABEL=/后加入enforcing=0错误五:
编译完重启后出现:
switchroot:
mountfailed:
22umount/initrd/devfailed:
2kernelpanic-notsymcing:
Attemptedtokillinit!
的错误,解决办法:
重新makemenuconfig,使CONFIG_SYSFS_DEPRECATED_V2=y也可以打开文件.config做修改和验证;再执行:
#makebzImage#makemodules#makemodules_install#makeinstall#shutdown-r"now"四、linux内核启动流程计算机在启动时都是先加电,然后进行硬件检测并引导操作系统的初始化程序,然后操作系统的初始化程序程负责读入系统内核并建产系统的运行环境.一这过程相对来说比较复而且与CPU体系结构相关,这里我们通过linux并以i386的体系结构对这一过程进
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- linux 内核 升级 图文 攻略