kernel linux 升级

2017-12-12 22:34:00 weixin_34162401 阅读数 483

下载内核 从以下网站https://www.kernel.org/

clip_image001

上传kernel文件到/usr/src/kernels/ 目录下,此处也可以选择其他目录

clip_image002

解压kernel文件

[root@apache kernels]# tar -xJvf linux-3.16.1.tar.xz

安装包 gcc、ncurses-devel

[root@apache yum.repos.d]# yum -y install gcc ncurses-devel

Failed to set locale, defaulting to C

Loaded plugins: langpacks, product-id, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Repository 'y' is missing name in configuration, using id

y | 4.1 kB 00:00:00

Resolving Dependencies

--> Running transaction check

---> Package gcc.x86_64 0:4.8.2-16.el7 will be installed

--> Processing Dependency: cpp = 4.8.2-16.el7 for package: gcc-4.8.2-16.el7.x86_64

--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.2-16.el7.x86_64

--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.2-16.el7.x86_64

--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.2-16.el7.x86_64

---> Package ncurses-devel.x86_64 0:5.9-13.20130511.el7 will be installed

--> Running transaction check

---> Package cpp.x86_64 0:4.8.2-16.el7 will be installed

---> Package glibc-devel.x86_64 0:2.17-55.el7 will be installed

--> Processing Dependency: glibc-headers = 2.17-55.el7 for package: glibc-devel-2.17-55.el7.x86_64

--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-55.el7.x86_64

---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed

---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed

--> Running transaction check

---> Package glibc-headers.x86_64 0:2.17-55.el7 will be installed

--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.17-55.el7.x86_64

--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-55.el7.x86_64

--> Running transaction check

---> Package kernel-headers.x86_64 0:3.10.0-121.el7 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================

Package Arch Version Repository Size

==================================================================================================================

Installing:

gcc x86_64 4.8.2-16.el7 y 16 M

ncurses-devel x86_64 5.9-13.20130511.el7 y 713 k

Installing for dependencies:

cpp x86_64 4.8.2-16.el7 y 5.9 M

glibc-devel x86_64 2.17-55.el7 y 1.0 M

glibc-headers x86_64 2.17-55.el7 y 650 k

kernel-headers x86_64 3.10.0-121.el7 y 1.4 M

libmpc x86_64 1.0.1-3.el7 y 51 k

mpfr x86_64 3.1.1-4.el7 y 203 k

Transaction Summary

==================================================================================================================

Install 2 Packages (+6 Dependent packages)

Total download size: 26 M

Installed size: 61 M

Downloading packages:

------------------------------------------------------------------------------------------------------------------

Total 31 MB/s | 26 MB 00:00:00

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

Installing : mpfr-3.1.1-4.el7.x86_64 1/8

Installing : libmpc-1.0.1-3.el7.x86_64 2/8

Installing : cpp-4.8.2-16.el7.x86_64 3/8

Installing : kernel-headers-3.10.0-121.el7.x86_64 4/8

Installing : glibc-headers-2.17-55.el7.x86_64 5/8

Installing : glibc-devel-2.17-55.el7.x86_64 6/8

Installing : gcc-4.8.2-16.el7.x86_64 7/8

Installing : ncurses-devel-5.9-13.20130511.el7.x86_64 8/8

Verifying : ncurses-devel-5.9-13.20130511.el7.x86_64 1/8

Verifying : mpfr-3.1.1-4.el7.x86_64 2/8

Verifying : glibc-headers-2.17-55.el7.x86_64 3/8

Verifying : glibc-devel-2.17-55.el7.x86_64 4/8

Verifying : libmpc-1.0.1-3.el7.x86_64 5/8

Verifying : kernel-headers-3.10.0-121.el7.x86_64 6/8

Verifying : gcc-4.8.2-16.el7.x86_64 7/8

Verifying : cpp-4.8.2-16.el7.x86_64 8/8

Installed:

gcc.x86_64 0:4.8.2-16.el7 ncurses-devel.x86_64 0:5.9-13.20130511.el7

Dependency Installed:

cpp.x86_64 0:4.8.2-16.el7 glibc-devel.x86_64 0:2.17-55.el7 glibc-headers.x86_64 0:2.17-55.el7

kernel-headers.x86_64 0:3.10.0-121.el7 libmpc.x86_64 0:1.0.1-3.el7 mpfr.x86_64 0:3.1.1-4.el7

Complete!

执行make

先查看make帮助

[root@apache linux-3.16.1]# make help

Cleaning targets:

clean - Remove most generated files but keep the config and

enough build support to build external modules

mrproper - Remove all generated files + config + various backup files

distclean - mrproper + remove editor backup and patch files

Configuration targets:

config - Update current config utilising a line-oriented program

nconfig - Update current config utilising a ncurses menu based program

menuconfig - Update current config utilising a menu based program

xconfig - Update current config utilising a QT based front-end

gconfig - Update current config utilising a GTK based front-end

oldconfig - Update current config utilising a provided .config as base

localmodconfig - Update current config disabling modules not loaded

localyesconfig - Update current config converting local mods to core

silentoldconfig - Same as oldconfig, but quietly, additionally update deps

defconfig - New config with default from ARCH supplied defconfig

savedefconfig - Save current config as ./defconfig (minimal config)

allnoconfig - New config where all options are answered with no

allyesconfig - New config where all options are accepted with yes

allmodconfig - New config selecting modules when possible

alldefconfig - New config with all symbols set to default

randconfig - New config with random answer to all options

listnewconfig - List new options

olddefconfig - Same as silentoldconfig but sets new symbols to their default value

Other generic targets:

all - Build all targets marked with [*]

* vmlinux - Build the bare kernel

* modules - Build all modules

modules_install - Install all modules to INSTALL_MOD_PATH (default: /)

firmware_install- Install all firmware to INSTALL_FW_PATH

(default: $(INSTALL_MOD_PATH)/lib/firmware)

dir/ - Build all files in dir and below

dir/file.[oisS] - Build specified target only

dir/file.lst - Build specified mixed source/assembly target only

(requires a recent binutils and recent build (System.map))

dir/file.ko - Build module including final link

modules_prepare - Set up for building external modules

tags/TAGS - Generate tags file for editors

cscope - Generate cscope index

gtags - Generate GNU GLOBAL index

kernelrelease - Output the release version string

kernelversion - Output the version stored in Makefile

image_name - Output the image name

headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH

(default: ./usr)

Static analysers

checkstack - Generate a list of stack hogs

namespacecheck - Name space analysis on compiled kernel

versioncheck - Sanity check on version.h usage

includecheck - Check for duplicate included header files

export_report - List the usages of all exported symbols

headers_check - Sanity check on exported headers

headerdep - Detect inclusion cycles in headers

coccicheck - Check with Coccinelle.

Kernel packaging:

rpm-pkg - Build both source and binary RPM kernel packages

binrpm-pkg - Build only the binary kernel package

deb-pkg - Build the kernel as a deb package

tar-pkg - Build the kernel as an uncompressed tarball

targz-pkg - Build the kernel as a gzip compressed tarball

tarbz2-pkg - Build the kernel as a bzip2 compressed tarball

tarxz-pkg - Build the kernel as a xz compressed tarball

perf-tar-src-pkg - Build perf-3.16.1.tar source tarball

perf-targz-src-pkg - Build perf-3.16.1.tar.gz source tarball

perf-tarbz2-src-pkg - Build perf-3.16.1.tar.bz2 source tarball

perf-tarxz-src-pkg - Build perf-3.16.1.tar.xz source tarball

Documentation targets:

Linux kernel internal documentation in different formats:

htmldocs - HTML

pdfdocs - PDF

psdocs - Postscript

xmldocs - XML DocBook

mandocs - man pages

installmandocs - install man pages generated by mandocs

cleandocs - clean all generated DocBook files

Architecture specific targets (x86):

* bzImage - Compressed kernel image (arch/x86/boot/bzImage)

install - Install kernel using

(your) ~/bin/installkernel or

(distribution) /sbin/installkernel or

install to $(INSTALL_PATH) and run lilo

fdimage - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)

fdimage144 - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)

fdimage288 - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)

isoimage - Create a boot CD-ROM image (arch/x86/boot/image.iso)

bzdisk/fdimage*/isoimage also accept:

FDARGS="..." arguments for the booted kernel

FDINITRD=file initrd for the booted kernel

kvmconfig - Enable additional options for guest kernel support

x86_64_defconfig - Build for x86_64

i386_defconfig - Build for i386

make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build

make V=2 [targets] 2 => give reason for rebuild of target

make O=dir [targets] Locate all output files in "dir", including .config

make C=1 [targets] Check all c source with $CHECK (sparse by default)

make C=2 [targets] Force check of all c source with $CHECK

make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections

make W=n [targets] Enable extra gcc checks, n=1,2,3 where

1: warnings which may be relevant and do not occur too often

2: warnings which occur quite often but may still be relevant

3: more obscure warnings, can most likely be ignored

Multiple levels can be combined with W=12 or W=123

Execute "make" or "make all" to build all targets marked with [*]

For further info see the ./README file

[root@apache linux-3.16.1]#

执行 make menuconfig命令 出现图形

clip_image003

save

clip_image004

生成.config文件

clip_image005

退出

clip_image006

提示执行make继续或查看帮助

clip_image007

执行 make命令,根据环境编译kernel,生成模块文件。等待一段时间

执行make all 生成内核文件 和 模块文件

[root@dns linux-3.16.1]# make all

CHK include/config/kernel.release

CHK include/generated/uapi/linux/version.h

CHK include/generated/utsrelease.h

CALL scripts/checksyscalls.sh

CHK include/generated/compile.h

CERTS kernel/x509_certificate_list

- Including cert signing_key.x509

AS kernel/system_certificates.o

LD kernel/built-in.o

CHK include/generated/uapi/linux/version.h

LINK vmlinux

LD vmlinux.o

MODPOST vmlinux.o

GEN .version

CHK include/generated/compile.h

UPD include/generated/compile.h

CC init/version.o

LD init/built-in.o

KSYM .tmp_kallsyms1.o

KSYM .tmp_kallsyms2.o

LD vmlinux

SORTEX vmlinux

SYSMAP System.map

TEST posttest

Succeed: decoded and checked 1702020 instructions

TEST posttest

arch/x86/tools/insn_sanity: Success: decoded and checked 1000000 random instructions with 0 errors (seed:0x769ca218)

VOFFSET arch/x86/boot/voffset.h

OBJCOPY arch/x86/boot/compressed/vmlinux.bin

GZIP arch/x86/boot/compressed/vmlinux.bin.gz

MKPIGGY arch/x86/boot/compressed/piggy.S

AS arch/x86/boot/compressed/piggy.o

LD arch/x86/boot/compressed/vmlinux

ZOFFSET arch/x86/boot/zoffset.h

AS arch/x86/boot/header.o

CC arch/x86/boot/version.o

LD arch/x86/boot/setup.elf

OBJCOPY arch/x86/boot/setup.bin

OBJCOPY arch/x86/boot/vmlinux.bin

BUILD arch/x86/boot/bzImage

Setup is 17104 bytes (padded to 17408 bytes).

System is 5064 kB

CRC 67447bac

Kernel: arch/x86/boot/bzImage is ready (#2)

Building modules, stage 2.

MODPOST 2161 modules

[root@dns linux-3.16.1]#

执行 make modules_install 安装模块

执行 make install

clip_image008

重启

shutdown -r 0

选择新的kernel启动

image

查看当前kernel,uname -r

clip_image009

升级内核完成


本文转自ICT时空 dbasdk博客,原文链接: linux 内核升级步骤,kernel升级 ,如需转载请自行联系原博主。

2018-08-20 23:41:18 wf19930209 阅读数 42362

Linux升级内核的正确姿势

很多童鞋在玩耍linux发行版的时候,都会遇到各种各样的问题,比如:网卡不能使用亮度不能调节触摸板不能识别蓝牙不能使用等等,这些关系都和linux内核有关系。

什么是linux内核?

Linux内核(英语:Linux kernel),是一种开源的类Unix操作系统宏内核

Linux内核最早是于1991年由芬兰黑客林纳斯·托瓦兹为自己的个人计算机开发的,他当时在Usenet新闻组comp.os.minix登载帖子,这份著名的帖子标志着Linux内核计划的正式开始。如今,该计划已经拓展到支持大量的计算机体系架构,远超其他操作系统和内核。它迅速吸引了一批开发者和用户,利用它作为其他自由软件项目的内核,如著名的 GNU 操作系统。

内核长什么样子呢?

这里写图片描述

有精力的同学可以去学习学习!

查看当前内核

打开终端执行:

vincent@dell-Inspiron-7559 Dir:~
·····$uname -r
4.15.0-32-generic

当前电脑内核为4.15版本,一般更换内核我们是将内核升级为更高版本。

下载内核

目前下载有很多地址,我主要使用以下两个:

  1. github上下载linux kernel
  2. ubuntu的仓库中下载linux kernel

内核需要下载那些文件?

目前ubuntu 18.04已经使用4.15版本内核,linux mint 19也使用4.15版本内核。

4代版本中4.164.17有安装上的区别:

下面是4.16版本的文件选择:

这里写图片描述

下面是4.17版本的文件选择:

这里写图片描述

安装顺序

使用sudo dpkg -i ***.deb 的形式安装。

  1. 首先安装linux-headers-4.17.0-041700_4.17.0-041700.201806041953_all.deb

  2. 安装linux-headers-4.17.0-041700-generic_4.17.0-041700.201806041953_amd64.deb

  3. 安装linux-modules-4.17.0-041700-generic_4.17.0-041700.201806041953_amd64.deb

  4. 安装linux-image-unsigned-4.17.0-041700-generic_4.17.0-041700.201806041953_amd64.deb

如果是4.16版本及以前内核,此文件是没有的,也不需要安装。

安装完成后重启即可。

删除多余内核

1. 查看当前系统安装的内核

dpkg --get-selections| grep linux
console-setup-linux install
libselinux1:amd64 install
libselinux1:i386 install
linux-base install
linux-firmware install
linux-generic install
linux-headers-4.4.0-22 install
linux-headers-4.4.0-22-generic install
linux-headers-4.4.0-24 install
linux-headers-4.4.0-24-generic install
linux-headers-4.4.0-28 install
linux-headers-4.4.0-28-generic install
linux-headers-4.4.0-31 install
linux-headers-4.4.0-31-generic install
linux-headers-4.4.0-34 install
linux-headers-4.4.0-34-generic install
linux-headers-4.4.0-36 install
linux-headers-4.4.0-36-generic install
linux-headers-4.4.0-38 install
linux-headers-4.4.0-38-generic install
linux-headers-4.4.0-42 install
linux-headers-4.4.0-42-generic install
linux-headers-generic install
linux-image-4.2.0-21-generic deinstall
linux-image-4.2.0-22-generic deinstall
linux-image-4.4.0-31-generic deinstall
linux-image-4.4.0-34-generic install
linux-image-4.4.0-36-generic install
linux-image-4.4.0-38-generic install
linux-image-4.4.0-42-generic install
linux-image-extra-4.2.0-21-generic deinstall
linux-image-extra-4.4.0-31-generic deinstall
linux-image-extra-4.4.0-34-generic deinstall
linux-image-extra-4.4.0-36-generic deinstall
linux-image-extra-4.4.0-38-generic install
linux-image-extra-4.4.0-42-generic install
linux-image-generic install
linux-libc-dev:amd64 install
linux-sound-base install
pptp-linux install
syslinux install
syslinux-common install
syslinux-legacy install
util-linux install

2. 卸载内核

可以看到系统已经安装了多个内核版本,包括 headers 和 image ,可以删除这些来卸载旧的内核。

比如删除 4.4.0-22 内核,我们看到上面只有 headers,因此可以这样:

sudo apt-get remove --purge linux-headers-4.4.0-22

sudo apt-get remove --purge linux-image-4.2.0-22-generic

以此类推。

然后终端执行:

sudo apt-get autoclean
sudo apt-get autoremove

然后重启电脑即可。

END

2017-10-20 13:10:36 donetboy328 阅读数 3060

今天按如下流程升级了一下Linux Kenrnel内核,remark一下


1.系统更新
yum update
yum upgrade


2.检查目前版本
uname -a
Linux centos6 2.6.32-696.13.2.el6.x86_64 #1 SMP Thu Oct 5 21:22:16 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
cat /etc/redhat-release
CentOS release 6.9 (Final)


3.安装必要组件
[root@centos ~]# yum install vim wget
[root@centos ~]# yum install gcc gcc-c++ xz
[root@centos ~]# yum install bc
[root@centos ~]# yum install ncurses-devel
[root@centos ~]# yum install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel


4.下载内核原文件
[root@centos ~]# cd /usr/local/src/
[root@centos ~]# wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.12.17.tar.xz
[root@centos ~]# tar -vxf linux-3.12.17.tar.xz
[root@centos ~]# cd linux-3.12.17
***/usr/local/src/linux-3.12.17此目录当编译目录,编译过程,操作都必须在此目录


5.清除以前编译内核生成文件
cd linux-3.12.17
make distclean 
清除以前编译内核生成的所有文件(除了清除可执行文件和目标文件外,configure所产生的Makefile也会清除掉)


6.复制配置文件
将系统默认的内核配置文件复制到linux-2.6.35.13目录下,并命名.config


7.内核配置(make menuconfig)
a)make config:基于文本的最为传统的配置界面,不推荐使用
b)make menuconfig:基于文本选单的配置界面,字符终端下推荐使用。
注意:使用make menuconfig 需要安装ncurses(yum -y install ncurses-devel) ,如果未安装会报如下错误:
c)make xconfig:基于图形窗口模式的配置界面,Xwindow下推荐使用
注意:如果要用make xconfig,则要先安装QT3开发包,并配置。如果未安装会报如下错误:


8.修改.config配置文件
在.config文件搜索CONFIG_SYSFS_DEPRECATED_V2,会发现# CONFIG_SYSFS_DEPRECATED_V2 is not set这一行,将该行修改为CONFIG_SYSFS_DEPRECATED_V2=y。假如不修改该行,在升级重新启动后会报如下的错,导致启动失败:


9.编译内核
make all
大概需要30至60分钟左右,具体时间看机子的性能


10.编译模块
make modules_install


11.安装
make install


12.修改grub.conf,让引导程序默认从新的内核启动
vi /boot/grub/grub.conf
default=0


13.重启电脑
#uname -r

2019-01-22 16:52:00 weixin_33871366 阅读数 162

 

1. https://www.kernel.org/ 下载kernel,如linux-4.20.3.tar.xz
2. 配置yum
3. yum install gcc
4. yum install openssl openssl-devel
5. yum install elfutils-libelf-devel
6. make mrproper
7. make clean
8. make oldconfig
9. make
10. make modules_install
11. make install
12 重启,kernel那会有新的kernel,但是默认还是旧的,得做修改

 

修改默认启动的内核:
1.查看所有可用的内核
cat /boot/grub2/grub.cfg |grep menuentry

2. grub2-set-default ‘要设置的kernel,如复制红框里’
3. grub2-editenv list 查看内核修改结果,重启

 

转载于:https://www.cnblogs.com/ningchenglong/p/10304713.html

2017-12-21 15:02:13 GGGoodLuck 阅读数 2973

1.解压

tar -xf linux-3.10.58.tar.xz

2.更新当前系统

sudo yum update

说明:执行此操作会升级系统版本,建议不要执行

3.安装编译内核所需要的软件包

sudo yum groupinstall "Development Tools"  # 一口气安装编译时所需的一切工具
sudo yum install ncurses-devel  #必须这样才能让 make *config 这个指令正确地执行。
sudo yum install qt-devel       #如果你没有 X 环境,这一条可以不用
sudo yum install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel  #创建CentOS-6 内核时需要它们

4.uname -r

  2.6.32-358.11.1.el6.x86_64    #查看当前系统内核

5.获取并解压内核源码,配置编译项,将当前系统的配置文件拷贝到当前目录。

   tar -xf linux-3.10.58.tar.xz -C /usr/src/

   cd /usr/src/linux-3.10.58/

   cp /boot/config-2.6.32-358.11.1.el6.x86_64 ./.config  # 此处boot下的这个config文件要根据实际,未必是这个文件名的文件。

6.使用旧内核配置,并自动接受每个新增选项的默认设置

sh -c 'yes "" | makeoldconfig'   # make oldconfig会读取当前目录下的.config文件,在.config文件里没有找到的选项则提示用户填写,然后备份.config文件为.config.old,并生成新的.config文件

 http://stackoverflow.com/questions/4178526/what-does-make-oldconfig-do-exactly-linux-kernel-makefile

7.编译

sudo make -j16  bzImage    #生成内核文件
sudo make -j16 modules         #编译模块
sudo make -j16 modules_install   #编译安装模块

要严格按照这个顺序进行编译,不能合并成一句,sudo make -j8 bzImage modules modules_install

-j后面的数字是线程数,用于加快编译速度,一般的经验是,有多少G内存,就填写那个数字, free -m查看内存大小,我的设备是16G内存,则为-j16

8.安装后重启

sudomake install     #如果弹出问题1.如下,需重新升级内核,升级成功。

如果出现了 ERROR: modinfo: could not find module xxx,数量少的话,可以忽略。

9.修改Grub引导顺序

安装完成后,需要修改Grub引导顺序,让新安装的内核作为默认内核。

编辑 grub.conf文件:

sudovim /etc/grub.conf    # 数一下刚刚新安装的内核在哪个位置,从0开始,然后设置default为那个数字,一般新安装的内核在第一个位置,所以设置default=0

10.重启

sudoreboot

uname–r     #重启后,看一下当前内核版本号,

3.10.58

sap 升级kernel

阅读数 4116