咱們知道,一個Linux系統的主要組成是由liunx內核核心和一些支持模塊組合而成的。可是在某些場合中,須要某項功能,而當前內核的核心或者模塊不支持此功能,那麼就須要對內核進行一個升級或者從新編譯內核添加相應的功能,以此提供了對此功能的支持。linux
編譯前的準備windows
認識kernelcentos
所爲kernel,就是一種操做系統的核心,固然也是一個文件,而這種核心提供了對一些硬件的支持,通常來講其中包含了一些對常見硬件核心驅動的核心代碼。啓動系統時會經過加載MBR中的bootloader,而後將此核心文件加載到內存中。由於只是保留了核心,全部通常來講,kernel的大小也不會很大。通常kernel文件會保存/boot目錄在,格式爲:緩存
/boot/vmlinuz-XXX,如CentOS7中的:安全
[root@localhost ~]# ls -l /boot/vmlinuz-3.10.0-327.el7.x86_64 -rwxr-xr-x. 1 root root 5156528 Nov 19 2015 /boot/vmlinuz-3.10.0-327.el7.x86_64
內核模塊(kernel module)bash
kernel文件中已經包含了一些最基本的硬件探測與驅動模塊,可是其中的內容並不能徹底是因爲全部的硬件驅動,全部,對於一些不經常使用、較新的驅動,linux中會提供一種模塊化的機制,及接須要硬件或者新功能時,能夠經過加載這些核心模塊來提供對新功能的支持。固然核心模塊的各類模塊文件是獨立存在的,通常存放在/lib/modules/$(uname -r)/kernel/下:cookie
[root@localhost ~]# ls /lib/modules/3.10.0-327.el7.x86_64/kernel/ arch crypto drivers fs kernel lib mm net sound
爲何要編譯內核網絡
須要新功能的支持:架構
在生產環境中,忽然會須要使用一些新的功能,可是原有的內核並不支持此功能,這是就須要從新編譯出一個新的內核來提供對此新功能的支持,好比虛擬化、iptables功能必需要在2.4.X以上版本的內核中才支持。app
原核心太過於臃腫:
原來安裝的內核中,有不少不經常使用甚至基本上用不到的功能支持,而這些功能又會使內核文件變得很大,這時要將此變成一個簡化切功可以用的內核就須要進行從新編譯。
與硬件搭配的穩定性:
不少狀況下,系統內核中默認通常默認支持的CPU類型爲Inter,但在其它廠商,如AMD或者是較新的CPU硬件上使用此係統,可能就不能很好的支持,且不穩定。所以就須要從新編譯內核來支持最新的硬件驅動。
其它特殊需求:
linux除了在pc機上運行,固然也能支持一些其它設備,好比嵌入式的APM、智能手機等,這時或許就要進行從新編譯支持的CPU架構來支持這些特殊需求。
總結一點:kernel的做業就是所須要的硬件支持,所以在此基礎上只加須要的功能,來實現內核文件的短小精幹。
源碼包解析
源碼包解壓及位置放置:
下載kernel內核源碼包,這裏我下載到/root目錄下
#查看文件的壓縮格式,發現爲.xz格式
[root@localhost ~]# ls -l /root/linux-3.10.89.tar.xz -rw-r--r--. 1 root root 73306144 Sep 13 08:09 /root/linux-3.10.89.tar.xz
#通常kernel核心文件通常放置在下/usr/src/kernels
[root@localhost ~]# ls /usr/src/kernels/ 3.10.0-327.el7.x86_64
解析:這裏是如今正在使用的內部版本爲3.1.0版本,這裏咱們咱們解壓到kernel目錄下。
#解壓linux-3.10.89.tar.xz 內核源碼到/usr/src/kernels目錄下
[root@localhost ~]# tar -Jxf /root/linux-3.10.89.tar.xz -C /usr/src/kernels/
#查看目錄是否已經解壓成功,這裏linux-3.1.0.89爲剛纔解壓的目錄
[root@localhost ~]# ls -l /usr/src/kernels/ total 8 drwxr-xr-x. 22 root root 4096 Sep 7 16:14 3.10.0-327.el7.x86_64 drwxrwxr-x. 23 root root 4096 Sep 21 2015 linux-3.10.89
#爲了方面操做,切換到/usr/src/kernels目錄,並給此目錄添加一個符號連接
[root@localhost kernels]# ln -sv ./linux-3.10.89/ ./linux ‘./linux’ -> ‘./linux-3.10.89/’ [root@localhost kernels]# ls -l ./linux lrwxrwxrwx. 1 root root 16 Sep 13 08:35 ./linux -> ./linux-3.10.89/
#進入此目錄
[root@localhost kernels]# cd ./linux [root@localhost linux]# pwd -L /usr/src/kernels/linux [root@localhost linux]# pwd -P /usr/src/kernels/linux-3.10.89
內核模塊內部目錄解析:
#查看全部目錄
[root@localhost linux]# ls -d ./*/ ./arch/ ./crypto/ ./drivers/ ./fs/ ./init/ ./kernel/ ./mm/ ./samples/ ./security/ ./tools/ ./virt/ ./block/ ./Documentation/ ./firmware/ ./include/ ./ipc/ ./lib/ ./net/ ./scripts/ ./sound/ ./usr/
#核心原始碼下的此目錄做用說明:
arch:與硬件平臺有關的項目,大部分指的是CPU的類型,例如x86,x86_64,Xen虛擬支持等。
block:與成組設備較相關的設定數據,區塊數據一般指一些大量存儲媒體,還包括相似ext3等文件系統的支持是否容許等。
crypto:核心所支持的加密技術,如md5、des、sha512等。
Documentation:與核心有關的一堆說明文件,其中包括了對上面全部目錄裏的說明。
firmware:一些舊式硬件的微腳步數據。
fs:內核所支持的filesystems(文件系統),例如ext系列、ntfs、reisefs等。
include:一些可以讓其它過程調用的標頭(header)定義數據。
init:一些初始化的定義功能,包括掛載和init 程序的呼叫等。
ipc:定義Linux操做系統內各程序進程間的通訊。
kernel:定義核心的程序、核心狀態、線程、程序的排程(schedule)、程序的訊號(signle)等。
lib:一些函數庫。
mm:與內存單元有關的各項數據,包括swap與虛擬內存等。
net:與網絡有關的各項協議數據,還有防火牆模塊(net/ipv4/netfilter/*) 等。
security:包括selinux等在內的安全性設定。
sound:與音效有關的各項模塊。
virt:與虛擬化機器有關的信息,目前核心支持的是KVM( Kernel base Vitual Machine )。
注意:這裏目錄說明,對於未來要經過patch模塊補丁文件來升級模塊的新功能有不少做業,知道了相應的做業去查找對應位置纔會成功更新模塊。
內核編譯前的準備
1、查看當前目標主機的硬件設備相關信息:
使用的命令有關:lscpu(cpu詳細信息)、lspci(pci插槽)、lsusb(usb接口)、lsblk(塊設備)、hal-device(全部硬件詳細信息)。
注:上面的命令若是是最小化安裝的系統,可能會沒有這些工具,所以安裝對應工具包便可
#安裝命令須要的工具包
[root@localhost linux]# yum install -y pciutils usbutils util-linux
#查看cpu型號
[root@localhost linux]# lscpu |sed-n's/^Model [^[:space:]]\+:[[:space:]]\+\([^[:space:]]\+\)/\1/gp' Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
#查看pci
[root@localhost linux]# lspci | grep -o '[A-Z].*' | uniq -c | tr -s ' ' | xargs -I {} echo -e '\e[032m' {} '\e[0m'
#查看usb接口
[root@localhost linux]# lsusb
清空源代碼的其它信息
注:下載下來的源碼包通常狀況下不肯定是否已經編譯過,或者還殘留有生成的一塊兒文件,這裏爲了編譯時不會出現未知的錯誤,進行清理。
#對內核源碼目錄進行清理
[root@localhost linux]# pwd -P /usr/src/kernels/linux-3.10.89 [root@localhost linux]# make mrproper
核心功能的挑選
注:在咱們當前已經安裝的系統中的/boot目錄下存在一個名爲conf-xxx 的文件,那個文件其實就是核心功能列表選擇文件,如:
[root@localhost linux]# ls -l /boot/config-3.10.0-327.el7.x86_64 -rw-r--r--. 1 root root 126426 Nov 19 2015 /boot/config-3.10.0-327.el7.x86_64
解析:在經過核心功能挑選結束後,會在源碼核心目錄下生成一個.config的隱藏文件,其中就是/boot/config-xxx文件。
#下面驗證當前系統下的conf-xxx文件是否就是其對應.config文件:
[root@localhost linux]# diff /boot/config-`uname -r` /usr/src/kernels/`uname -r`/.config [root@localhost linux]# echo $? 0
解析:這裏並是由diff文件比較命令,並無比較出有什麼不一樣,全部,能夠推斷config-xxx文件就是對應的內核版本目錄下的.config文件。
編碼內核選擇界面(生成.config的方法):
make help: #支持「更新模式進行配置」。 make menuconfig: #基於curses的文本窗口界面 make gconfig: #基於GTK(GOME)環境窗口界面 make xconfig: #基於QT(KDE) 環境的窗口界面 make config: #老舊的命令行遍歷方式逐一配置每一個可配置的選項 make oldconfig: #透過已經存在的./.config文件內容,並使用該文件內設定值爲默認值,只將新版本核心的新功能列出讓用戶選擇,能夠簡化核心功能挑選過程。對與升級內核很好選擇。 make defconfig: #基於內核爲目標平臺執行提供的「默認」配置進行配置 make allyesconfig: #全部選項均回答爲」yes」 make allnoconfig: #全部選項均回答爲」no」
根據已有的設定來處理核心項目與功能的選擇:
#拷貝當前系統內核中的config-xxx文件到須要編譯的內核目錄下
[root@localhost linux]# cp /boot/config-`uname -r` ./.config [root@localhost linux]# ls -l ./.config -rw-r--r--. 1 root root 126426 Sep 13 10:10 ./.config
注意:這裏拷貝以後,必定不要再使用make mrproper,否則會清除剛纔拷貝的.config文件。
使用make menuconfig 命令進行菜單化界面來選擇內核功能:
[root@localhost linux]# make menuconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o *** 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
解析:這裏出現了錯誤,根據上面的提示說須要安裝ncurses庫文件。並提示了其庫文件的軟件包名爲ncurses-devel。
#因而安裝ncuress-devel包
[root@localhost linux]# yum install ncurses-devel -y
#同時檢查是否有編譯環境,雖然已經安裝了gcc,可是爲了保險起見,仍是安裝一個開發工具包組」Development Tools」
[root@localhost ~]# rpm -q gcc gcc-4.8.5-4.el7.x86_64
#再次使用make menuconfig進入功能選擇菜單
解析:根據界面頭部的信息提示可知:
左右箭頭鍵:用來移動選擇最下面的select、exit、help、save、load幾個按鈕
上下箭頭鍵:能夠移動上面的菜單來選中對應的功能選項,選項後與--> 表示內部有子菜單須要選擇。
選定項目:使用上下鍵選擇設定的項目,並使用左右鍵選擇select按鈕,而後按回車就可進入項目中的子菜單選擇。
挑選功能:在項目的功能名稱前面,有[]或者<>纔可使用 空格鍵 來選擇。
挑選說明:顯示爲<*>[*]表示編譯進核心;若爲<M>表示編譯成模塊。
離開選擇項:左右鍵選擇Exit按回車便可
功能選擇的建議:
一、核心必定要的功能,直接編譯進核心內;
二、可能之後會用到的功能,儘可能編譯成模塊;
三、不指定功能的具體做業,按help顯示幫助也不明顯,保留其默認值或編譯爲模塊。
各個項目菜單選項的介紹:
Generl setup基本的linux核心功能,最相關的驅動程序、版本說明 核心說明代碼。
()Cross-compiler toolprefix #是否使用交叉編譯 (meng-1-1.1) Local version - append to kernel release #自定義一個版本號 [*]Automatically append version information to the version string #是否自動追加版本號 Kernel compression mode (Bizp2) ---> #這裏進入子菜單建議選擇bizp2,壓縮比高 ((none)) Default hostname <M> Kernel .config support [ ] Enable access to .config through /proc/config.gz (NEW) #是否生成config文件保留配置 (20) Kernel log buffer size (16 => 64KB, 17 => 128KB) #登陸文件的緩存文件默認值便可 [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support #支持開啓啓動加載initrd文件 [ ] Optimize for size #是否減低核心文件大小,這裏不須要 Configure standard kernel features (expert users) ---> [ ] Embedded system #是否支持嵌入式系統,否
loadable module 模塊加載和卸載
[*] Enable loadable module support #啓用才能進入子菜單 --- Enable loadable module support [*]Forced module loading #是否強制加載模塊 [*] Module unloading #模塊卸載 [*] Forced module unloading #強制卸載模塊 [*] Module versioning support #支持模塊多版本 [*] Source checksum for all modules #是否讓檢查原有全部模塊校驗和 [*] Module signature verification [ ] Require modules to be validly signed [*] Automatically sign all modules #模塊功能的自動調用 Which hash algorithm should modules be signed with? (Sign modules with SHA-256) #選SHA256
block layer 塊設備的支持
--Enablethe blocklayer -*- Block layer SG support v4 #塊層對SGv4的支持 [*]BlocklayerSG support v4 helperlib #塊層對SGv4的輔助支持 [*]Block layer data integritysupport #塊層完整性的支持 [*]Block layer bio throttling support #塊層節流此支持 Partition Types ---> #分區類型的支持 [*] Macintosh partition map support #蘋果系統分區結果的支持 [*] PC BIOS (MSDOS partition tables) support #基於mbr的分區,通常爲必選 [*]Windows Logical Disk Manager (Dynamic Disk) support #windows邏輯捲動態管理器支持 [*]SGI partition support #SGI分區結構支持 [*]EFI GUID Partition support #EFI及對與GPT分區結構的支持 IO Schedulers ---> #磁盤陣列的處理方式 [*]Deadline I/O scheduler #最後期限調度 <*> CFQ I/O scheduler #CFQ磁盤 [*] CFQ Group Scheduling support Default I/O scheduler (Deadline) ---> #默認磁盤整列處理方式,通常爲Deadline
Processor type and features 處理器類型和其功能選擇
Symmetric multi-processing support #多處理器的支持 Linux guest support ---> #Linux 虛擬化的支持 [*]Enable paravirtualization code #啓用半虛擬化代碼 [*]Paravirtualization layer for spinlocks #半虛擬化 [*] Xen guest support #高級虛擬化 [*]KVM Guest support (including kvmclock) #虛擬化鎖 [*]Paravirtual steal time accounting Processor family (Generic-x86-64) ---> #通用的處理器結構,若是不是很老的處理器就選擇 [*]Enable Maximum number of SMP Processors and NUMA Nodes #啓動SMP處理器和NUMA節點最大數量 [*]Multi-core scheduler support #多核心處理器調用 Preemption Model (Voluntary Kernel Preemption (Desktop)) ---> #選擇優先模式,推薦爲Server Timer frequency (300 HZ) --->#表示處理器的迴應,若是爲桌面模式,能夠設置1000HZ
Power management and ACPI options 電源管理和ACPI選項
[*]ACPI (Advanced Configuration and Power Interface) Support ---> #高級配置和接口 [*]CPU Frequency scaling ---> #CPU頻率擴展 <M> CPU frequency translation statistics Default CPUFreq governor (ondemand) ---> #通常選擇ondemand會更好,下面默認便可 -*- 'performance' governor <*> 'powersave' governor <*> 'userspace' governor for userspace frequency scaling -*- 'ondemand' cpufreq policy governor <*> 'conservative' cpufreq governor x86 CPU frequency scaling drivers --->
Bus options (PCI etc.) 總線選項和PCI插槽
[*] PCI support #PCI支持 [*] Support mmconfig PCI config space access #PCI內存訪問空間 [*] PCI Express support #PCI-E支持 <*> PCI Express Hotplug driver #子項目默認值便可 [*] PCI Debugging #若是須要虛擬化,此選項必選
Executable file formats / Emulations 編譯後執行檔的格式
-*- Kernel support for ELF binaries #支持擴展二進制文件 [*] Write ELF core dumps with partial segments #部分轉儲片斷寫入擴展核心 <*> Kernel support for scripts starting with #! #內核腳步支持 <M> Kernel support for MISC binaries #misc程序支持 [M] IA32 Emulation #模擬32功能,爲了兼容而已 <M> IA32 a.out support #32爲輸出格式支持 [*] x32 ABI for 64-bit mode #f仿32位的64模式
Networking support 核心網絡功能
[*] TCP/IP networking #TCP/IP網絡協議支持 [*] IP: multicasting #IP多播傳輸 [*] IP: advanced router #高級路由功能 [*] FIB TRIE statistics #靜態TRIE [*] IP: policy routing #路由規則 [*] IP: equal cost multipath #多路徑平衡傳輸 [*] IP: verbose route monitoring #路由監控 [*] IP: broadcast GRE over IP #IP廣播 [*] IP: multicast routing #多播路由 [*] IP: multicast policy routing #多播路由規則 [*] IP: PIM-SM version 1 support #PIM-SM支持 [*] IP: PIM-SM version 2 support [*] IP: TCP syncookie support #數據同步 [*] Network packet filtering framework (Netfilter) ---> #網絡防火牆 [*]Core Netfilter Configuration ---> #裏面都編譯成模塊 [*] QoS and/or fair queueing ---> #裏面都編譯成模塊 [*]Network testing ---> #默認值便可
Device Drivers 設備驅動
Serial ATA and Parallel ATA drivers ---> #裏面有對IDE/SATA硬盤的支持 [*] Multiple devices driver support (RAID and LVM) ---> #raid整列和lvm邏輯卷的支持 -*- Network device support ---> #網絡設備,網卡等驅動 <M> Bonding driver support --> #多網卡綁定功能驅動,要選 <M>Ethernet team driver support ---> #team網卡組支持,要選 <M>Virtio network driver --> #虛擬網卡 --- Ethernet driver support #以太網卡類型,選擇10G卡 [*] Brocade devices <M> Brocade 1010/1020 10Gb Ethernet Driver support <M> Calxeda 1G/10G XGMAC Ethernet driver <M> Chelsio 10Gb Ethernet support <M> Intel(R) PRO/10GbE support <M> PPP (point-to-point protocol) support #撥號上網協議 USB Network Adapters ---> #移動網絡適配器,全打成模塊 [*] Wireless LAN ---> #無線網卡 <*> xHCI HCD (USB 3.0) support <*> EHCI HCD (USB 2.0) support <*> OHCI HCD support <*> UHCI HCD (most Intel and VIA) support [*] Virtualization drivers ---> #虛擬化驅動程序 Virtio drivers ---> #虛擬化項目程序驅動 Hardware Spinlock drivers ---> #跟虛擬化有關
File systems 文件系統的支持
<M> Second extended fs support #ext2的支持 <M> Ext3 journalling file system support #ext3的支持 [*] Default to 'data=ordered' in ext3 (NEW) [*] Ext3 extended attributes (NEW) [*] Ext3 POSIX Access Control Lists <M> The Extended 4 (ext4) filesystem #ext4必選 <M> XFS filesystem support #xfs必選 [*] XFS Quota support #xfs文件系統對quota的支持 [*] XFS POSIX ACL support #xfs中訪問控制列表支持 <M> Btrfs filesystem support #btrufs文件系統 [*] Quota support #磁盤配額驅動模塊 CD-ROM/DVDFilesystems---> #iso鏡像都考它 DOS/FAT/NT Filesystems ---> #dos文件系統 <M> MSDOS fs support #dos分區文件系統 <M> VFAT (Windows-95) fs support #vfat/fat32 (950) Default codepage for FAT #950 支持中文 (uft-8) Default iocharset for FAT #支持中文 <M> NTFS file system support #支持NTFS文件系統 [*] NTFS write support #支持對NTFS分區系統可寫 Pseudo filesystems ---> #對文件系統設備的映射 --- Native language support #選擇utf8爲預設的語言 (utf8) Default NLS Option
解析:由於是linux-3.10.89,全部相比其它低版本kernel的功能須要選擇有所不一樣,這裏以centos7爲例,全部一些重要的功能仍是要選擇的。
#選擇完成後選擇第一個界面的SAVE保存按鈕,保存到.config文件。
編譯安裝具體步驟:
一、核心和模塊編譯級別模塊安裝
[root@localhost linux]# make -j 4 clean [root@localhost linux]# make -j 4 bzImage Setup is 16752 bytes (padded to 16896 bytes). System is 4594 kB CRC 9dced73c Kernel: arch/x86/boot/bzImage is ready (#1)
解析:最後出現這些表示顯示成功。
#查看bzImage內核是否已經生成
[root@localhost linux]# ll arch/x86/boot/bzImage -rw-r--r--. 1 root root 4720464 Sep 13 16:30 arch/x86/boot/bzImage
#編譯模塊
[root@localhost linux]# make -j 4 modules
#安裝模塊
[root@localhost linux]# make modules_install
#查看安裝好的模塊文件
[root@localhost linux]# ll -ld /lib/modules/*/ drwxr-xr-x. 7 root root 4096 Sep 7 16:25 /lib/modules/3.10.0-327.el7.x86_64/ drwxr-xr-x. 3 root root 4096 Sep 13 16:40 /lib/modules/3.10.89meng-1-1.1/
解析:這裏的3.10.89meng-1.1就是剛纔咱們安裝好的模塊。
二、開始配置安裝新核心與多核心group菜單
注:實際上以後直接執行make install就能直接安裝內核了,可是爲進一步認識centos7中的grub2新機制,這裏咱們模擬實現make install的工做,手動添加內核及grub配置
模擬make install的文件拷貝工做
#移動新內核到/boot目錄下
[root@localhost linux]# basename /lib/modules/3.10.89meng-1-1.1/ 3.10.89meng-1-1.1
#拷貝內核文件到/boot目錄下
[root@localhost linux]# cp arch/x86/boot/bzImage /boot/vmlinuz-`basename /lib/modules/3.10.89meng-1-1.1/`
#將.config備份文件也靠過來,當作個備份
[root@localhost linux]# cp .config /boot/config-`basename /lib/modules/3.10.89meng-1-1.1/`
#給vmlinuz內核文件加執行權限
[root@localhost linux]# chmod a+x /boot/vmlinuz-3.10.89meng-1-1.1
#拷貝系統內核映射文件
[root@localhost linux]# cp System.map /boot/System.map-`basename /lib/modules/3.10.89meng-1-1.1/`
#拷貝內核模塊列表
[root@localhost inux]# gzip -c Module.symvers > /boot/symvers-`basename /lib/modules/3.10.89meng-1-1.1/`.gz
#從新還原/boot目錄下文件的安全上下文
[root@localhost linux]# restorecon -Rv /boot restorecon reset /boot/System.map-3.10.89meng-1-1.1 context unconfined_u:object_r:boot_t:s0->unconfined_u:object_r:system_map_t:s0
安裝新版本的initrd/initramfs文件
#生成對應版本的initramfs文件
[root@localhost linux]# dracut -v /boot/initramfs-`basename /lib/modules/3.10.89meng-1-1.1/`
#更新grub.cfg配置,加入新內核記錄
[root@localhost linux]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub configuration file ... Found linux p_w_picpath: /boot/vmlinuz-3.10.89meng-1-1.1 Found linux p_w_picpath: /boot/vmlinuz-3.10.0-327.el7.x86_64 Found initrd p_w_picpath: /boot/initramfs-3.10.0-327.el7.x86_64.img Found linux p_w_picpath: /boot/vmlinuz-0-rescue-fb8d28a0639e4047894f5d177a5d8be3 Found initrd p_w_picpath: /boot/initramfs-0-rescue-fb8d28a0639e4047894f5d177a5d8be3.img done
#查看/boot/grub2/grub.cfg下啊是否生成了新的菜單
[root@localhost linux]# grep -o -e 'linux16.*meng' -oe '^menuentry.*meng.*)' /boot/grub2/grub.cfg menuentry 'CentOS Linux (3.10.89meng-1-1.1) 7 (Core) linux16 /vmlinuz-3.10.89meng
#查看當前grub裏的menuentry菜單,新內核排在第一個
[root@localhost linux]# grep -o "^menuentry [^[:space:]]\+.*)" /boot/grub2/grub.cfg menuentry 'CentOS Linux (3.10.89meng-1-1.1) 7 (Core) menuentry 'CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core) menuentry 'CentOS Linux (0-rescue-fb8d28a0639e4047894f5d177a5d8be3) 7 (Core)
#查看新內核的grub2.conf配置詳細信息
注意:上面好像出現了問題,沒有將initramfs.img文件讀入其中,那麼就須要手動添加此行。這必須必須的啊,否則怎麼找到/目錄。
#在linux16及kernel內核指定行下加一行爲initrd16表示initramfs路徑
#重啓機器,測試內核是否有問題
[root@localhost linux]# shutdown -r now