(1)機器現況 [webadm@localhost ~]$ uname -a (2)下載核心壓縮檔: wget https://mirrors.edge.kernel.org/pub/linux/kernel/v3.x/linux-3.19.8.tar.gz : 2019-01-11 10:21:52 (721 KB/s) - ‘linux-3.19.8.tar.gz’ saved [123146642/123146642] (3)解開核心 # tar xvzf linux-3.19.8.tar.gz (4)建立符號連結 #sudo ln -s /root/linux-3.19.8 /usr/src/linux (5)用現有的組態為預設值建立核心組態 $ uname -r 3.14.27-100.fc19.i686.PAE # cp /boot/config-3.14.27-100.fc19.i686.PAE /home/webadm/linux-3.19.8 (6a) # make menuconfig 失敗 (6b)# yum install gcc (6c)# make menuconfig 失敗 (6d) # (6e)# make menuconfig 終於成功 (7) 編譯核心成功 # make
: IHEX firmware/yam/9600.bin # date
(8)列出剛編譯完成的核心 [root@localhost linux-3.19.8]# ls arch/x86/boot/bzImage -l (9)將新編的核心 及 組態檔 及System.map 拷至/boot目錄分別為vmlinuz-3.19.8及config-3.19.8 及 System.map-3.19.8 # cp arch/x86/boot/bzImage /boot/vmlinuz-3.19.8 # cp .config /boot/config-3.19.8 # cp System.map /boot/System.map-3.19.8 (10)安裝新的核心模組至/lib/modules/3.19.8成功 # make modules_install # ls -l /lib/modules/total 12drwxr-xr-x 6 root root 4096 Jan 3 2002 3.14.27-100.fc19.i686.PAEdrwxr-xr-x 3 root root 4096 Jan 15 08:56 3.19.8drwxr-xr-x. 6 root root 4096 Dec 29 2015 3.9.5-301.fc19.i686.PAE (11)建立initramfs成功 [root@localhost linux-3.19.8]# dracut -v /boot/initramfs-3.19.8.img 3.19.8 : I: Wrote /boot/initramfs-3.19.8.img:I: -rw------- 1 root root 19791005 Jan 15 09:57 /boot/initramfs-3.19.8.img
(12) # ls /boot -l total 97788-rw-r--r-- 1 root root 142005 Dec 17 2014 config-3.14.27-100.fc19.i686.PAE-rw-r--r-- 1 root root 148439 Jan 15 08:48 config-3.19.8-rw-r--r--. 1 root root 128562 Jun 11 2013 config-3.9.5-301.fc19.i686.PAEdrwxr-xr-x. 6 root root 1024 Jan 3 2002 grub2-rw-------. 1 root root 25530244 Dec 29 2015 initramfs-0-rescue-2607e2e8500f42a1b59e68e1dde968cd.img-rw------- 1 root root 9160930 Jan 3 2002 initramfs-3.14.27-100.fc19.i686.PAE.img-rw------- 1 root root 19791005 Jan 15 09:57 initramfs-3.19.8.img-rw-------. 1 root root 16807019 Dec 29 2015 initramfs-3.9.5-301.fc19.i686.PAE.img-rw-r--r--. 1 root root 556897 Jan 3 2002 initrd-plymouth.imgdrwx------. 2 root root 12288 Dec 30 2015 lost+found-rw------- 1 root root 2244508 Dec 17 2014 System.map-3.14.27-100.fc19.i686.PAE-rw-r--r-- 1 root root 2348304 Jan 15 08:49 System.map-3.19.8-rw-------. 1 root root 2055042 Jun 11 2013 System.map-3.9.5-301.fc19.i686.PAE-rwxr-xr-x. 1 root root 5025072 Dec 29 2015 vmlinuz-0-rescue-2607e2e8500f42a1b59e68e1dde968cd-rwxr-xr-x 1 root root 5471888 Dec 17 2014 vmlinuz-3.14.27-100.fc19.i686.PAE-rw-r--r-- 1 root root 5668960 Jan 15 08:48 vmlinuz-3.19.8-rwxr-xr-x. 1 root root 5025072 Jun 11 2013 vmlinuz-3.9.5-301.fc19.i686.PAE (13)建立核心開機選單,最新編譯者為第1選項(預設選項) #grub2-mkconfig -o /boot/grub2/grub.cfg Generating grub.cfg ...Found linux image: /boot/vmlinuz-3.19.8Found initrd image: /boot/initramfs-3.19.8.imgFound linux image: /boot/vmlinuz-3.14.27-100.fc19.i686.PAEFound initrd image: /boot/initramfs-3.14.27-100.fc19.i686.PAE.imgFound linux image: /boot/vmlinuz-3.9.5-301.fc19.i686.PAEFound initrd image: /boot/initramfs-3.9.5-301.fc19.i686.PAE.imgFound linux image: /boot/vmlinuz-0-rescue-2607e2e8500f42a1b59e68e1dde968cdFound initrd image: /boot/initramfs-0-rescue-2607e2e8500f42a1b59e68e1dde968cd.imgdone[root@localhost linux-3.19.8]#
(14)遠端重開機查看 #reboot (15)新核心運作中,但iptables 的 nat router無法啟用
(16)# 重新make menuconfig勾選啟用netfilter的nat支援 (17)重編核心 # make (18) # ls arch/x86/boot/bzImage -l (19) # cp arch/x86/boot/bzImage /boot/vmlinuz-3.19.8 # cp .config /boot/config-3.19.8 # cp System.map /boot/System.map-3.19.8 (20)重裝模組ok # make modules_install # ls -l /lib/modules/ (21)重建initramfs : I: Wrote /boot/initramfs-3.19.8.img:
(22)# ls /boot -l (23)grub2-mkconfig -o /boot/grub2/grub.cfg (24)reboot (25)新核心運作中 # uname -a (26)# cat /etc/rc.d/rc.local (27)iptables 的nat router 運作成功 # iptables -t nat -L |