美文网首页
Centos7编译安装

Centos7编译安装

作者: ALuckyLive | 来源:发表于2017-07-12 20:51 被阅读0次
    内核编译安装系统
    1/从官网下载kernel包文件;www.kernel.org
    
    2/下载完成后解压到/root下;查看文件大小;
     #ll -h linux-4.12.tar.xz
     查看分区空间及硬盘空间大小;是否足够;
    
    
    3/解压kernel包;
     tar -xvf kernel-4.12.tar.xz
    
     
    4/查看目录大小
    #du -sh linux-4.12
    
    5/参考当前操作系统文件为模板进行调整
    [root@centos7 ~]#ll /boot/vmlinuz-3.10.0-514.el7.x86_64 -rwxr-xr-x. 1 root root 5392080 Nov 23  2016 /boot/vmlinuz-3.10.0-514.el7.x86_64
    模板对应的配置文件;
    #cd /boot
    config-3.10.0-514.el7.x86_64  模板配置文件
    grub
    grub2
    initramfs-0-rescue-c13ed9ba529c45d6bf915ca67e74c338.img
    initramfs-3.10.0-514.el7.x86_64.img
    initramfs-3.10.0-514.el7.x86_64kdump.img
    initrd-plymouth.img
    symvers-3.10.0-514.el7.x86_64.gz
    System.map-3.10.0-514.el7.x86_64
    vmlinuz-0-rescue-c13ed9ba529c45d6bf915ca67e74c338
    vmlinuz-3.10.0-514.el7.x86_64
    
    ***
    confing-3.10.0-514.el7.x86_64 
    在此文件里有记录了vmlinuz所选的功能,给以在此之上选择想加进去的功能选项;
    
    有些不常用的驱动模块放置到 /lib/modules里
    ***
    /boot/vmlinuz-3.10.0-514.el7.x86_6
    常用的驱动放置
    
    /usr/lib/modules/3.10.0-514.el7.x86_64---ko文件,模块方式
    不常用的驱动模块放置
    ***
    
    vim confing-3.10.0-514.el7.x86_64
    查看配置文件,
    
    
    [root@centos7 boot]#updatedb
    [root@centos7 boot]#locate ntfs.ko
    [root@centos7 boot]#vim config-3.10.0-514.el7.x86_64 
    
    # Automatically generated file; DO NOT EDIT.
    # Linux/x86_64 3.10.0-514.el7.x86_64 Kernel Configuration
    #
    CONFIG_64BIT=y              y表示安装到/boot/vmlinuz-3.10.0-514.el7.x86_6
    CONFIG_X86=y
    CONFIG_INSTRUCTION_DECODER=y
    CONFIG_OUTPUT_FORMAT="elf64-x86-64"
    CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"
    
    CONFIG_SLUB=y
    CONFIG_PROFILING=y
    CONFIG_TRACEPOINTS=y
    CONFIG_OPROFILE=m           m表示安装到/usr/lib/modules/3.10.0-514.el7.x86_64
    CONFIG_OPROFILE_EVENT_MULTIPLEX=y
    CONFIG_HAVE_OPROFILE=y
    CONFIG_OPROFILE_NMI_TIMER=y
    CONFIG_KPROBES=y
    
    # CONFIG_EXT3_FS is not set
    CONFIG_EXT4_FS=m             模块文件
    CONFIG_EXT4_USE_FOR_EXT23=y
    CONFIG_EXT4_FS_POSIX_ACL=y
    CONFIG_EXT4_FS_SECURITY=y
    
    
    [root@centos7 ~]#locate ext.ko
    /usr/lib/modules/3.10.0-514.el7.x86_64/kernel/net/sched/em_text.ko
    
    
    6/将配置文件拷贝到/root/linux-4.12/.config
    
    [root@centos7 boot]#cp config-3.10.0-514.el7.x86_64  /root/linux-4.12/.config
    [root@centos7 boot]#wc -l /root/linux-4.12/.config 
    5848 /root/linux-4.12/.config
    查看文件行数
    
    配置文件行数较多,用菜单工具定制内核选项;
    需安装开发工具包组
    [root@centos7 boot]#yum install "Development tools"
    [root@centos7 boot]#yum groupinstall "Development tools"
    
    包组安装完成后,运行软件工具 make menuconfig
    
    进入到/linux-4.12目录下运行软件工具;
    
    
    [root@centos7 ~]#ls
    1.log                  Downloads             Pictures
    2017-07-02-22.tar.xz   initial-setup-ks.cfg  Public
    2017-07-02-Jul.tar.xz  IP.sh                 script
    a                      linux-4.12            select.sh
    anaconda-ks.cfg        linux-4.12.tar.xz     Templates
    cat                    Music                 testdir
    Desktop                oper2017-07-07.log    Videos
    Documents              opertion.sh
    [root@centos7 ~]#cd linux-4.12
    [root@centos7 linux-4.12]#ls
    arch     crypto         include  kernel       net       sound
    block    Documentation  init     lib          README    tools
    certs    drivers        ipc      MAINTAINERS  samples   usr
    COPYING  firmware       Kbuild   Makefile     scripts   virt
    CREDITS  fs             Kconfig  mm           security
    [root@centos7 linux-4.12]#make menuconfig
      HOSTCC  scripts/basic/fixdep
     *** Unable to find the ncurses libraries or the
     *** required header files.
     *** 'make menuconfig' requires the ncurses libraries.
     *** 
     *** Install ncurses (ncurses-devel) and try again.
     *** 
    make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
    make: *** [menuconfig] Error 2
    [root@centos7 linux-4.12]#yum install ncurses-devel
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.hust.edu.cn
     * extras: mirror.lzu.edu.cn
     * updates: mirrors.nju.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package ncurses-devel.x86_64 0:5.9-13.20130511.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ==========================================================================
     Package            Arch        Version                   Repository
                                                                         Size
    ==========================================================================
    Installing:
     ncurses-devel      x86_64      5.9-13.20130511.el7       base      713 k
    
    Transaction Summary
    ==========================================================================
    Install  1 Package
    
    Total download size: 713 k
    Installed size: 2.1 M
    Is this ok [y/d/N]: y
    Downloading packages:
    ncurses-devel-5.9-13.20130511.el7.x86_64.rpm         | 713 kB   00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : ncurses-devel-5.9-13.20130511.el7.x86_64               1/1 
      Verifying  : ncurses-devel-5.9-13.20130511.el7.x86_64               1/1 
    
    Installed:
      ncurses-devel.x86_64 0:5.9-13.20130511.el7                              
    
    Complete!
    
    
    安装缺少的安装包;
    
    进入到/root/linux-4.12目录下(解压的目录):
    [root@centos7 linux-4.12]#make menuconfig
    
    * 为保存到内核文件/boot/vmlinuz
    
    M 为保存到模块文件/usr/lib/modules/
    
    
    进入图形菜单栏,编辑本地kernel版本,
    General setup--->
    
    local - append to kernel release
    
    save---保存
    
    File systems --->编辑文件系统
    
    DOS/FAT/NT Filesystems --->
    
    <M> NTFS file system support                           
    
    [*]   NTFS debugging support                          
    [*]   NTFS write support 
    
    save ---> 保存退出
    
    [root@centos7 linux-4.12]#ll .config /boot/config-3.10.0-514.el7.x86_64 
    -rw-r--r--. 1 root root 137696 Nov 23  2016 /boot/config-3.10.0-514.el7.x86_64
    -rw-r--r--. 1 root root 168537 Jul 12 17:40 .config
    
    # CONFIG_FAT_DEFAULT_UTF8 is not set
    CONFIG_NTFS_FS=m      设置成功
    CONFIG_NTFS_DEBUG=y
    CONFIG_NTFS_RW=y
    
    #
    # Pseudo filesystems
    
    
    #在/root/linux-4.2-- 目录下
    #make -j 4 编译
    
    #ll -sh
    
    
    #make modules_install 生成KO文件;
    
    [root@centos7 linux-4.12]#ls /lib/modules
    3.10.0-514.el7.x86_64  4.12.0-byf-1.2
    
    [root@centos7 modules]#find 4.12.0-byf-1.2/ -name "*.ko"
    
    [root@centos7 linux-4.12]#make install
    Makefile:933: "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel"
    sh ./arch/x86/boot/install.sh 4.12.0-byf-1.2 arch/x86/boot/bzImage \
            System.map "/boot"
    ^Cmkinitrd failed
    make: *** [install] Interrupt
    
    [root@centos7 linux-4.12]#yum install  elfutils-libelf-devel
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirrors.hust.edu.cn
     * extras: mirror.lzu.edu.cn
     * updates: mirrors.nju.edu.cn
    Resolving Dependencies
    --> Running transaction check
    ---> Package elfutils-libelf-devel.x86_64 0:0.166-2.el7 will be installed
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    =========================================================================================================================
     Package                                Arch                    Version                      Repository             Size
    =========================================================================================================================
    Installing:
     elfutils-libelf-devel                  x86_64                  0.166-2.el7                  base                   37 k
    
    Transaction Summary
    =========================================================================================================================
    Install  1 Package
    
    Total download size: 37 k
    Installed size: 31 k
    Is this ok [y/d/N]: y
    Downloading packages:
    elfutils-libelf-devel-0.166-2.el7.x86_64.rpm                                                      |  37 kB  00:00:00     
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      Installing : elfutils-libelf-devel-0.166-2.el7.x86_64                                                              1/1 
      Verifying  : elfutils-libelf-devel-0.166-2.el7.x86_64                                                              1/1 
    
    Installed:
      elfutils-libelf-devel.x86_64 0:0.166-2.el7                                                                             
    
    Complete!
    
    
    
    [root@centos7 linux-4.12]#[root@centos7 linux-4.12]#ls /boot
    config-3.10.0-514.el7.x86_64                             System.map-3.10.0-514.el7.x86_64
    grub                                                     System.map-4.12.0-byf-1.2
    grub2                                                    System.map-4.12.0-byf-1.2.old
    initramfs-0-rescue-c13ed9ba529c45d6bf915ca67e74c338.img  vmlinuz
    initramfs-3.10.0-514.el7.x86_64.img                      vmlinuz-0-rescue-c13ed9ba529c45d6bf915ca67e74c338
    initramfs-3.10.0-514.el7.x86_64kdump.img                 vmlinuz-3.10.0-514.el7.x86_64
    initrd-plymouth.img                                      vmlinuz-4.12.0-byf-1.2
    symvers-3.10.0-514.el7.x86_64.gz                         vmlinuz-4.12.0-byf-1.2.old
    
    
    [root@centos7 linux-4.12]#make install
    sh ./arch/x86/boot/install.sh 4.12.0-byf-1.2 arch/x86/boot/bzImage \
            System.map "/boot"
    
    [root@centos7 linux-4.12]#cat /boot/grub2/grub.cfg 
    查看配置文件是否生成
    menuentry 'CentOS Linux (4.12.0-byf-1.2) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-f86bb45c-c257-4f7c-ae3c-fa72b50f277c' 
    
    
    [root@centos7 linux-4.12]#uname -r
    3.10.0-514.el7.x86_64
    
    重启选择编译的内核启动;
    
    [root@centos7 ~]#uname -r
    4.12.0-byf-1.2
    启动成功;
    
    ntfs格式linux只支持只读;
    #mount -o rw /dev/sdc1 /mnt
    #mount 可以看出只读;
    
    1下载kernel 源码包
    tar xf linux.XXX.xz
    /root/linux.4.12/
    
    2 生成配置模版文件 
    cp /boot/config.XXX /root/linux.4.12/.config
    
    3 yum groupnstall  "Development Tools"
    yum install ncurses-devel 
    
    4 make menuconfig 
    选中NTFS
    local version 
    
    5 make -j 4 && for i in {1..10};do echo -e "\a";sleep 1;done
    
    6 make modules_install  /lib/modules/`uname -r`
    
    7 make install  /boot/vmlinuz  /boot/grub2/grub.cfg
    
    在已经执行过编译操作的内核源码树做重新编译
      需要事先清理操作:
    make clean :清理大多数编译生成的文件,但会保留
    config 文件等
    make mrproper:  清理所有编译生成的文件、config 及某
    些备份文件
    make distclean :mrproper 、patches以及编辑器备份文件
    
      删除/lib/modules/ 目录下不需要的内核库文件
      删除/usr/src/linux/ 目录下不需要的内核源码
      删除/boot 目录下启动的内核和内核映像文件
      更改grub 的配置文件,删除不需要的内核启动列表
    
    
    编译安装
    
    cd isolinux/
    ll vmlinuz 内核文件
    跟boot目录下的一样
    出厂版本,及日期
    
    上传 linux-4.12.tar.xz文件(rz)
    
    占用10G多的空间
    
    解开包--解压缩 
    tar xf linux---
    
    
    #du -sh linux-4.12
    
    
    ll /boot/vmlinuz  参考文件进行修改
    
    cd /boot
    
    config----   配置文件,
    
    ls /lib/modules
    
    
    更新数据库updatedb
    
    locate ntfs.ko
    
    ls
    
    locate ext4.ko
    
    菜单工具
    
    安装开发工具包组
    yum groupinstall "development Tools“
    
    
    make menuconfig 运行软件工具
    
    
    install 安装缺少的包文件
     
    
    uname -r
    内核版本
    
    
    fIle system 
    文件系统
    
    
    DOS/FAT/NT  ntfs
    
    
    make -j  4  有四颗cpu 四线程
     
    cd /root/lnux---
    ls 
    查看生成的目录
    
    (b)make manuconfig
    
    ls /lib/modules
    make  modules_install
    自动添加到配置文建中
     
    编译:
    cd /root/linux
    
    ls net/
    
    1、可以选择性编译
    
    2、指定某个特定的目录进行编译
    
    
    编译的平台 make ARHM
    
    
    updatedb 更新
    
    locate ntfs.ko
    看文件
    
    make modules_install
    
    
    cd /root/linux-
    切换 并进行操作 make install
    
    reboot
    重启后选择新的内核启动
    
    
    系统中的程序支持不支持内核,不支持将使用不了
    
    ntfs 不支持,只读更改不了{windows}
    
    locate /lib/modules
    
    选择性编译;
    
    
    
    
    #############################################make clean 清除文件
    在 想~清理的目录下进行清理
    
    make mrproper 清理所有的编译生成的文件
    
    makedistclean  
    
    ############################################
    卸载内核 
    
    
    
    
    
    ############################################
    

    相关文章

      网友评论

          本文标题:Centos7编译安装

          本文链接:https://www.haomeiwen.com/subject/ffhihxtx.html