linux 内核升级步骤,kernel升级

简介:

    下载内核 从以下网站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升级 ,如需转载请自行联系原博主。

相关文章
|
20天前
|
Ubuntu 安全 Linux
|
2月前
|
安全 Linux 网络安全
Linux端的ssh如何升级?
Linux端的ssh如何升级?
260 59
|
7天前
|
人工智能 安全 Linux
|
2月前
|
NoSQL Linux Redis
linux安装单机版redis详细步骤,及python连接redis案例
这篇文章提供了在Linux系统中安装单机版Redis的详细步骤,并展示了如何配置Redis为systemctl启动,以及使用Python连接Redis进行数据操作的案例。
63 2
|
1月前
|
应用服务中间件 Linux Shell
Linux 配置 Nginx 服务的详细步骤,绝对干货
Linux 配置 Nginx 服务的详细步骤,绝对干货
67 0
|
2月前
|
存储 缓存 编译器
Linux kernel memory barriers 【ChatGPT】
Linux kernel memory barriers 【ChatGPT】
54 11
|
3月前
|
Linux TensorFlow 算法框架/工具
在Linux上安装其他版本的cmake 或 升级cmake
在Linux上安装其他版本的cmake 或 升级cmake
83 2
|
3月前
|
Linux 网络安全 开发工具
内核实验(二):自定义一个迷你Linux ARM系统,基于Kernel v5.15.102, Busybox,Qemu
本文介绍了如何基于Linux Kernel 5.15.102版本和BusyBox创建一个自定义的迷你Linux ARM系统,并使用QEMU进行启动和调试,包括内核和BusyBox的编译配置、根文件系统的制作以及运行QEMU时的命令和参数设置。
261 0
内核实验(二):自定义一个迷你Linux ARM系统,基于Kernel v5.15.102, Busybox,Qemu
|
3月前
|
JavaScript Linux API
【Azure 应用服务】NodeJS Express + MSAL 应用实现AAD集成登录并部署在App Service Linux环境中的实现步骤
【Azure 应用服务】NodeJS Express + MSAL 应用实现AAD集成登录并部署在App Service Linux环境中的实现步骤
|
3月前
|
Ubuntu 安全 Linux
在Linux中,编译内核的意义与步骤?
在Linux中,编译内核的意义与步骤?