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
############################################
卸載內核
############################################