樹心幽徑

« 20190109在Ubuntu1604安裝VirtualBox5.1 | Main | 20190112將Ubuntu1604的64位元Linux核心由4.13.0-45更新成linux-4.20.0成功 »

20190111將Fedora19 的3.14.27-100Linux核心(32位元)昇級成3.19.8
2019/01/11,15:07

(1)機器現況

[webadm@localhost ~]$ uname -a
Linux localhost.localdomain 3.14.27-100.fc19.i686.PAE #1 SMP Wed Dec 17 19:56:19 UTC 2014 i686 i686 i386 GNU/Linux

(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 失敗
  HOSTCC  scripts/basic/fixdep
/bin/sh: gcc: command not found
make[1]: *** [scripts/basic/fixdep] Error 127
make: *** [scripts_basic] Error 2

(6b)# yum install gcc

(6c)# make menuconfig 失敗
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/mconf.o
In file included from scripts/kconfig/mconf.c:23:0:
scripts/kconfig/lxdialog/dialog.h:38:20: fatal error: curses.h: No such file or directory
 #include CURSES_LOC
                    ^
compilation terminated.
make[1]: *** [scripts/kconfig/mconf.o] Error 1
make: *** [menuconfig] Error 2

(6d) #yum install ncurses-devel ncurses

(6e)# make menuconfig 終於成功

(7) 編譯核心成功
 

# make

 

:

 IHEX    firmware/yam/9600.bin

# date
Tue Jan 15 08:45:56 EST 2019

 

(8)列出剛編譯完成的核心

[root@localhost linux-3.19.8]#  ls arch/x86/boot/bzImage -l
-rw-r--r-- 1 root root 5668960 Jan 15 08:01 arch/x86/boot/bzImage

(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
-rw-r--r-- 1 root root 5668960 Jan 15 10:35 arch/x86/boot/bzImage
[root@localhost linux-3.19.8]# pwd
/home/webadm/linux-3.19.8

(19)

# cp arch/x86/boot/bzImage /boot/vmlinuz-3.19.8
cp: overwrite ‘/boot/vmlinuz-3.19.8’? y

#  cp .config /boot/config-3.19.8
cp: overwrite ‘/boot/config-3.19.8’? y

# cp System.map /boot/System.map-3.19.8
cp: overwrite ‘/boot/System.map-3.19.8’? y

(20)重裝模組ok

#  make modules_install

#  ls -l /lib/modules/
total 12
drwxr-xr-x  6 root root 4096 Jan  3  2002 3.14.27-100.fc19.i686.PAE
drwxr-xr-x  3 root root 4096 Jan 15 11:35 3.19.8
drwxr-xr-x. 6 root root 4096 Dec 29  2015 3.9.5-301.fc19.i686.PAE

(21)重建initramfs
[root@localhost linux]# dracut -v /boot/initramfs-3.19.8.img 3.19.8 --force

:

I: Wrote /boot/initramfs-3.19.8.img:
I: -rw------- 1 root root 19791125 Jan 15 11:45 /boot/initramfs-3.19.8.img

 

(22)#  ls /boot -l
total 97789
-rw-r--r--  1 root root   142005 Dec 17  2014 config-3.14.27-100.fc19.i686.PAE
-rw-r--r--  1 root root   148499 Jan 15 11:28 config-3.19.8
-rw-r--r--. 1 root root   128562 Jun 11  2013 config-3.9.5-301.fc19.i686.PAE
drwxr-xr-x. 6 root root     1024 Jan 15 10:11 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 19791125 Jan 15 11:45 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.img
drwx------. 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 11:28 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 11:28 vmlinuz-3.19.8
-rwxr-xr-x. 1 root root  5025072 Jun 11  2013 vmlinuz-3.9.5-301.fc19.i686.PAE

(23)grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.19.8
Found initrd image: /boot/initramfs-3.19.8.img
Found linux image: /boot/vmlinuz-3.14.27-100.fc19.i686.PAE
Found initrd image: /boot/initramfs-3.14.27-100.fc19.i686.PAE.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-0-rescue-2607e2e8500f42a1b59e68e1dde968cd
Found initrd image: /boot/initramfs-0-rescue-2607e2e8500f42a1b59e68e1dde968cd.img
done

(24)reboot

(25)新核心運作中

# uname -a
Linux localhost.localdomain 3.19.8 #2 SMP Tue Jan 15 10:33:48 EST 2019 i686 i686 i386 GNU/Linux

(26)# cat /etc/rc.d/rc.local
#!/bin/sh
iptables -t nat -F
echo "1" > /proc/sys/net/ipv4/ip_forward
modprobe ip_nat_ftp
modprobe ip_nat_irc
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc

iptables -t nat -A POSTROUTING -s 10.1.1.0/24  -j MASQUERADE
echo "1" > /proc/sys/net/ipv4/ip_forward


(27)iptables 的nat router 運作成功

# 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.1.1.0/24          anywhere


迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType