20160113換Linux核心(kernel-3.16.7)過程
(1) 查系統現況
[root@localhost ~]# uname -a Linux localhost.localdomain 3.19.8 #3 SMP Wed Jan 13 07:43:30 CST 2016 i686 i686 i386 GNU/Linux [root@localhost ~]# date Wed Jan 13 13:28:52 CST 2016 [root@localhost ~]#
(2) 下載核心linux-3.16.7.tar.gz [root@localhost ~]# wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.16.7.tar.gz --2016-01-13 13:15:24-- https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.16.7.tar.gz Resolving www.kernel.org (www.kernel.org)... 199.204.44.194, 198.145.20.140, 149.20.4.69, ... Connecting to www.kernel.org (www.kernel.org)|199.204.44.194|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 121773906 (116M) [application/x-gzip] Saving to: ‘linux-3.16.7.tar.gz’
(3)解開核心 [root@localhost ~]# tar xvzf linux-3.16.7.tar.gz
(4) 建立/usr/src/linux符號連結 [root@localhost ~]# rm /usr/src/linux rm: remove symbolic link ‘/usr/src/linux’? y [root@localhost ~]# ln -s /root/linux-3.16.7 /usr/src/linux [root@localhost ~]# ls /usr/src -l total 12 drwxr-xr-x. 2 root root 4096 Jul 8 2013 debug drwxr-xr-x 2 root root 4096 Jan 11 13:06 ipt-netflow- drwxr-xr-x. 4 root root 4096 Jan 6 17:06 kernels lrwxrwxrwx 1 root root 18 Jan 13 13:30 linux -> /root/linux-3.16.7 [root@localhost ~]#
(5)用現有的組態為預設值建立核心組態
[root@localhost ~]# cd /usr/src/linux/ [root@localhost linux]# cp /boot/config-3.19.8 .config [root@localhost linux]# pwd /usr/src/linux [root@localhost linux]# [root@localhost linux]# make menuconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/lxdialog/checklist.o HOSTCC scripts/kconfig/lxdialog/inputbox.o HOSTCC scripts/kconfig/lxdialog/menubox.o HOSTCC scripts/kconfig/lxdialog/textbox.o HOSTCC scripts/kconfig/lxdialog/util.o HOSTCC scripts/kconfig/lxdialog/yesno.o HOSTCC scripts/kconfig/mconf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/mconf scripts/kconfig/mconf Kconfig .config:880:warning: symbol value 'm' invalid for BRIDGE_NETFILTER .config:1345:warning: symbol value 'm' invalid for OPENVSWITCH_GRE .config:1346:warning: symbol value 'm' invalid for OPENVSWITCH_VXLAN configuration written to .config
*** End of the configuration. *** Execute 'make' to start the build or try 'make help'.
(6)閱讀說明檔 [root@localhost linux]# cat README |more
(7)編譯核心 [root@localhost linux]# make ok
(8)列出剛編譯完成的核心 [root@localhost linux]# ls arch/x86/boot/bzImage -l -rw-r--r-- 1 root root 5490256 Jan 13 14:11 arch/x86/boot/bzImage [root@localhost linux]#
(9)查看不可手動修改的開機選單設定檔 [root@localhost linux]# cat /boot/grub2/grub.cfg # # DO NOT EDIT THIS FILE # # It is automatically generated by grub2-mkconfig using templates # from /etc/grub.d and settings from /etc/default/grub # : (10)將新編的核心 及 組態檔 及System.map 拷至/boot目錄分別為vmlinuz-3.16.7及config-3.16.7 及 System.map-3.16.7 [root@localhost linux]# cp arch/x86/boot/bzImage /boot/vmlinuz-3.16.7 [root@localhost linux]# cp .config /boot/config-3.16.7 [root@localhost linux]# cp System.map /boot/System.map-3.16.7 [root@localhost linux]#
(11)安裝新的核心模組至/lib/modules/3.16.7 [root@localhost linux]# make modules_install : INSTALL /lib/firmware/yam/1200.bin INSTALL /lib/firmware/yam/9600.bin DEPMOD 3.16.7 [root@localhost linux]# ll /lib/modules/ total 24 drwxr-xr-x 6 root root 4096 Jan 5 17:34 3.14.27-100.fc19.i686.PAE drwxr-xr-x 3 root root 4096 Jan 13 14:41 3.16.7 drwxr-xr-x 3 root root 4096 Jan 13 07:55 3.19.8 drwxr-xr-x 4 root root 4096 Jan 11 13:06 3.9.5 drwxr-xr-x 6 root root 4096 Jan 6 16:03 3.9.5-301.fc19.i686 drwxr-xr-x. 6 root root 4096 Jan 6 12:46 3.9.5-301.fc19.i686.PAE [root@localhost linux]#
(12)建立initramfs [root@localhost linux]# dracut -v /boot/initramfs-3.16.7.img 3.16.7 : I: -rw------- 1 root root 17653321 Jan 13 14:42 /boot/initramfs-3.16.7.img
(13)列出/boot
[root@localhost linux]# cd /boot [root@localhost boot]# mv initramfs-3.19.8.img old3.initramfs-3.19.8.img [root@localhost boot]# mv System.map-3.19.8 old3.System.map-3.19.8 [root@localhost boot]# mv vmlinuz-3.19.8 old3.vmlinuz-3.19.8 [root@localhost boot]# mv config-3.19.8 old3.config-3.19.8
[root@localhost linux]# chmod 755 /boot/vmlinuz-3.16.7 [root@localhost boot]# ll /boot total 220126 -rw-r--r-- 1 root root 144293 Jan 13 14:37 config-3.16.7 -rw-r--r-- 1 root root 130928 Jun 12 2013 config-3.9.5-301.fc19.i686 -rw-r--r--. 1 root root 128562 Jun 12 2013 config-3.9.5-301.fc19.i686.PAE -rw-r--r-- 1 root root 128296 Jan 11 07:34 config-3.9.5-treehrt drwxr-xr-x. 6 root root 1024 Jan 13 08:00 grub2 -rw-------. 1 root root 25509635 Dec 23 12:26 initramfs-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8.img -rw------- 1 root root 17653321 Jan 13 14:42 initramfs-3.16.7.img -rw------- 1 root root 8745331 Jan 6 16:03 initramfs-3.9.5-301.fc19.i686.img -rw-------. 1 root root 16779573 Dec 23 12:26 initramfs-3.9.5-301.fc19.i686.PAE.img -rw------- 1 root root 17736016 Jan 11 07:42 initramfs-3.9.5.img -rw------- 1 root root 8236814 Jan 11 07:47 initramfs-3.9.5-treehrt.img -rw-r--r--. 1 root root 557284 Jan 5 17:34 initrd-plymouth.img drwx------. 2 root root 12288 Dec 23 12:05 lost+found -rw-r--r-- 1 root root 148506 Jan 12 16:14 old2.config-3.19.8 -rw------- 1 root root 26308183 Jan 12 16:29 old2.initramfs-3.19.8.img -rw-r--r-- 1 root root 2348934 Jan 12 16:14 old2.System.map-3.19.8 -rwxr-xr-x 1 root root 5675104 Jan 12 16:14 old2.vmlinuz-3.19.8 -rw-r--r-- 1 root root 148612 Jan 13 07:51 old3.config-3.19.8 -rw------- 1 root root 19461944 Jan 13 07:57 old3.initramfs-3.19.8.img -rw-r--r-- 1 root root 2348934 Jan 13 07:51 old3.System.map-3.19.8 -rw-r--r-- 1 root root 5675104 Jan 13 07:51 old3.vmlinuz-3.19.8 -rw-r--r-- 1 root root 142005 Dec 18 2014 old.config-3.14.27-100.fc19.i686.PAE -rw-r--r-- 1 root root 97454 Jan 11 17:27 old.config-3.19.8 -rw------- 1 root root 9162360 Jan 5 17:34 old.initramfs-3.14.27-100.fc19.i686.PAE.img -rw------- 1 root root 8242449 Jan 11 17:31 old.initramfs-3.19.8.img -rw------- 1 root root 2244508 Dec 18 2014 old.System.map-3.14.27-100.fc19.i686.PAE -rw-r--r-- 1 root root 2513181 Jan 11 17:28 old.System.map-3.19.8 -rwxr-xr-x 1 root root 5471888 Dec 18 2014 old.vmlinuz-3.14.27-100.fc19.i686.PAE -rwxr-xr-x 1 root root 5738112 Jan 11 17:27 old.vmlinuz-3.19.8 -rw-r--r-- 1 root root 2268451 Jan 13 14:37 System.map-3.16.7 -rw------- 1 root root 2017641 Jun 12 2013 System.map-3.9.5-301.fc19.i686 -rw-------. 1 root root 2055042 Jun 12 2013 System.map-3.9.5-301.fc19.i686.PAE -rw-r--r-- 1 root root 2052858 Jan 11 07:35 System.map-3.9.5-treehrt -rwxr-xr-x. 1 root root 5025072 Dec 23 12:26 vmlinuz-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8 -rwxr-xr-x 1 root root 5490256 Jan 13 14:36 vmlinuz-3.16.7 -rwxr-xr-x 1 root root 4939088 Jun 12 2013 vmlinuz-3.9.5-301.fc19.i686 -rwxr-xr-x. 1 root root 5025072 Jun 12 2013 vmlinuz-3.9.5-301.fc19.i686.PAE -rwxr-xr-x 1 root root 5013728 Jan 11 07:33 vmlinuz-3.9.5-treehrt [root@localhost boot]#
(14)建立核心開機選單,最新編譯者為第1選項(預設選項) [root@localhost boot]# grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub.cfg ... Found linux image: /boot/vmlinuz-3.16.7 Found initrd image: /boot/initramfs-3.16.7.img Found linux image: /boot/vmlinuz-3.9.5-treehrt Found initrd image: /boot/initramfs-3.9.5-treehrt.img Found linux image: /boot/vmlinuz-3.9.5-301.fc19.i686.PAE Found initrd image: /boot/initramfs-3.9.5-301.fc19.i686.PAE.img Found linux image: /boot/vmlinuz-3.9.5-301.fc19.i686 Found initrd image: /boot/initramfs-3.9.5-301.fc19.i686.img Found linux image: /boot/vmlinuz-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8 Found initrd image: /boot/initramfs-0-rescue-fe190f81d1ab45818aafd3f4c1c5edd8.img done [root@localhost boot]# reboot
(15)遠端重開機查看,新的Linux核心成功運中中
Good, It's success!!
[root@localhost ~]# uname -a Linux localhost.localdomain 3.16.7 #1 SMP Wed Jan 13 14:11:09 CST 2016 i686 i686 i386 GNU/Linux [root@localhost ~]# iptables -t nat -L Chain PREROUTING (policy ACCEPT) target prot opt source destination
Chain INPUT (policy ACCEPT) target prot opt source destination
Chain OUTPUT (policy ACCEPT) target prot opt source destination
Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE all -- 10.2.2.0/24 anywhere [root@localhost ~]#
(16)參考文章
REF 1:http://linux.vbird.org/linux_basic/0540kernel.php REF 2:http://linux.vbird.org/linux_basic/redhat6.1/linux_10kernel.php
|