日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

编译安装内核

發布時間:2023/12/6 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 编译安装内核 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

編譯安裝內核

升級內核到 linux-4.20.3.tar.xz

查看當前內核版本: [root@centos7 data]#uname -r 3.10.0-862.el7.x86_64獲取內核源代碼包:www.kernel.org linux-4.20.3.tar.xz

==實施步驟

1. 安裝編譯所需的工具 gcc ncurses-devel make(開發工具) 2. 下載內核源碼 a. www.kernel.org(最新) b. ftp://ftp.redhat.com/pub/redhat/linux/enterprise/5Serverftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Server 3. 解壓linux-4.20.3.tar.xz 4. 配置內核編譯的參數make menuconfig 5. 開始編譯make //等價于這兩個命令make bzImage make modules 6. 安裝模塊make modules_install //安裝到了 /lib/modules/$(uname -r) 7. 安裝內核make install //安裝到了 /boot 8. 檢查 ls /boot, /boot/grub/grub.conf, /lib/modules

==具體實施

1、安裝工具:
[root@centos7 data]#yum -y install gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel zlib-devel vim lrzsz tree screen lsof
tcpdump wget ntpdate net-tools iotop bc zip unzip

[root@centos7 data]#yum -y install ncurses-devel
[root@centos7 linux-4.20.3]#yum -y install elfutils-libelf-devel //第一次編譯時報錯,未安裝此包。

  • 上傳安裝包,解壓
    [root@centos7 data]#tar xvf linux-4.20.3.tar.xz //解壓
    [root@centos7 data]#cd linux-4.20.3/
    [root@centos7 linux-4.20.3]#cp /boot/config-3.10.0-862.el7.x86_64 .config //準備文本配置文件

  • 配置內核選項
    [root@centos7 linux-4.20.3]#make menuconfig
    [root@centos7 linux-4.20.3]#less .config |grep NTFS
    CONFIG_NTFS_FS=m

    CONFIG_NTFS_DEBUG is not set

    CONFIG_NTFS_RW=y

    可選操作:定制kernel版本名
    [root@centos7 linux-4.20.3]#head Makefile

    SPDX-License-Identifier: GPL-2.0

    VERSION = 4
    PATCHLEVEL = 20
    SUBLEVEL = 3
    EXTRAVERSION =
    NAME = Li xinzhou

  • 開始編譯make
    [root@centos7 linux-4.20.3]#make -j 8 && echo -e '\a'

  • 安裝模塊
    [root@centos7 linux-4.20.3]#make modules_install

    第一次遇到下面的錯誤:
    ln: target ‘Linux/source’ is not a directory
    make: *** [modinst] Error 1

    原因:內核配置項General setup——》Local version - append to kernel release,所填內容有空格。

    解決辦法:
    刪除空格,然后make modules, 再安裝模塊。由于版本信息改變,需要重新編譯安裝內核。

  • 安裝內核相關文件
    [root@centos7 linux-4.20.3]#make install
    sh ./arch/x86/boot/install.sh 4.20.3-1.0-xinzhoulinux arch/x86/boot/bzImage \
    System.map "/boot"

    安裝bzImage為/boot/vmlinuz-VERSION-RELEASE 生成initramfs文件 編輯grub的配置文件
  • 檢查 ls /boot, /boot/grub2/grub.cfg, /lib/modules
    [root@centos7 linux-4.20.3]#ls /boot/ //查看是否有新kernel
    config-3.10.0-862.el7.x86_64 symvers-3.10.0-862.el7.x86_64.gz
    efi System.map
    extlinux System.map-3.10.0-862.el7.x86_64
    grub System.map-4.20.3-1.0-xinzhoulinux
    grub2 vmlinuz
    initramfs-0-rescue-18ed42c1c89e4d28870e69320e88d637.img vmlinuz-0-rescue-18ed42c1c89e4d28870e69320e88d637
    initramfs-3.10.0-862.el7.x86_64.img vmlinuz-3.10.0-862.el7.x86_64
    initramfs-4.20.3-1.0-xinzhoulinux.img vmlinuz-4.20.3-1.0-xinzhoulinux

    [root@centos7 linux-4.20.3]#vim /boot/grub2/grub.cfg
    menuentry 'CentOS Linux (4.20.3-1.0-xinzhoulinux) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $m
    enuentry_id_option 'gnulinux-3.10.0-862.el7.x86_64-advanced-576ed6fe-d3e8-403d-832f-2dc117ba8d2f' {
    load_video
    set gfxpayload=keep
    insmod gzio
    insmod part_msdos
    insmod xfs
    set root='hd0,msdos1'
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='
    hd0,msdos1' 6e6694fc-5a2f-47a1-b96b-509621e5fc1e
    else
    search --no-floppy --fs-uuid --set=root 6e6694fc-5a2f-47a1-b96b-509621e5fc1e
    fi
    linux16 /vmlinuz-4.20.3-1.0-xinzhoulinux root=UUID=576ed6fe-d3e8-403d-832f-2dc117ba8d2f ro crashkernel=auto rhgb quiet LANG=e
    n_US.UTF-8
    initrd16 /initramfs-4.20.3-1.0-xinzhoulinux.img
    }

    [root@centos7 linux-4.20.3]#ls /lib/modules/4.20.3-1.0-xinzhoulinux/kernel/fs/ntfs/ //檢查模塊是否存在
    ntfs.ko

    [root@centos7 ~]#du -sh /data/linux-4.20.3 //編譯后的文件大小11G
    11G /data/linux-4.20.3

    [root@centos7 ~]#uname -r //reboot, 查看到新的內核
    4.20.3-1.0-xinzhoulinux

    [root@centos7 data]#locate ntfs.ko
    [root@centos7 data]#updatedb // updatedb - update a database for mlocate
    [root@centos7 data]#locate ntfs.ko //已經支持新的ntfs模塊
    /data/linux-4.20.3/fs/ntfs/.ntfs.ko.cmd
    /data/linux-4.20.3/fs/ntfs/ntfs.ko
    /usr/lib/modules/4.20.3-1.0-xinzhoulinux/kernel/fs/ntfs/ntfs.ko

  • 卸載內核
    刪除/lib/modules/目錄下不需要的內核庫文件
    刪除/usr/src/linux/目錄下不需要的內核源碼
    刪除/boot目錄下啟動的內核和內核映像文件
    更改grub的配置文件,刪除不需要的內核啟動列表
  • 轉載于:https://blog.51cto.com/8845692/2345381

    創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

    總結

    以上是生活随笔為你收集整理的编译安装内核的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。