樹心幽徑

« 20160107-11 make linux-3.9.5 kernel | Main | 20160112換Linux核心(kernel-3.19.8)過程 »

20160108換Linux核心(kernel-3.19.8)過程
2016/01/08,15:31

(1) 查系統現況
[root@localhost ~]# date
五  1月  8 11:31:26 CST 2016


[root@localhost ~]# uname -a
Linux localhost.localdomain 3.14.19-100.fc19.i686.PAE #1 SMP Wed Sep 17 22:23:56                                             

UTC 2014 i686 i686 i386 GNU/Linux
[root@localhost ~]#

(2) 下載核心linux-3.19.8.tar.gz
[root@localhost ~]# wget ftp://linux.cis.nctu.edu.tw/kernel/linux/kernel/v3.x/linux-3.19.8.tar.gz
--2016-01-08 11:42:07--  ftp://linux.cis.nctu.edu.tw/kernel/linux/kernel/v3.x/linux-3.19.8.tar.gz
           => ‘linux-3.19.8.tar.gz’
:
長度: 123146642 (117M) (非正式資料)

100%[===================================================================================>] 123,146,642  466KB/s   in 5m 24s

2016-01-08 11:47:36 (371 KB/s) - ‘linux-3.19.8.tar.gz’ saved [123146642]

[root@localhost ~]#


(3)解開核心
[root@localhost ~]# tar xvzf linux-3.19.8.tar.gz
:
linux-3.19.8/virt/kvm/vfio.h

[root@localhost ~]# ll|grep linux
drwxrwxr-x  23 root root      4096  5月 11  2015 linux-3.19.8
-rw-r--r--   1 root root 123146642  1月  8 11:47 linux-3.19.8.tar.gz
[root@localhost ~]# pwd
/root
[root@localhost ~]#

(4) 建立/usr/src/linux符號連結

 
[root@localhost ~]# ln -s /root/linux-3.19.8 /usr/src/linux
[root@localhost ~]# ls /usr/src -l
總計 8
drwxr-xr-x. 2 root root 4096  7月  8  2013 debug
drwxr-xr-x. 2 root root 4096  7月  8  2013 kernels
lrwxrwxrwx  1 root root   18  1月  8 11:54 linux -> /root/linux-3.19.8
[root@localhost ~]#

[root@localhost ~]# cd /usr/src/linux/

[root@localhost linux]# ls
arch     CREDITS        drivers   include  Kbuild   lib          mm      REPORTING-BUGS  security  usr
block    crypto         firmware  init     Kconfig  MAINTAINERS  net     samples         sound     virt
COPYING  Documentation  fs        ipc      kernel   Makefile     README  scripts         tools

(5)用現有的組態為預設值建立核心組態
[root@localhost linux]# make menuconfig
:

#
# using defaults found in /boot/config-3.14.19-100.fc19.i686.PAE
#
/boot/config-3.14.19-100.fc19.i686.PAE:1304:warning: symbol value 'm' invalid for CGROUP_NET_PRIO
configuration written to .config
*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.
[root@localhost linux]#

(6)閱讀說明檔
[root@localhost linux]# cat README |more

 

(7)編譯核心

[root@localhost linux]# make

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

[root@localhost linux]# ls arch/x86/boot/bzImage -l
-rw-r--r-- 1 root root 5675104  1月  8 12:41 arch/x86/boot/bzImage

[root@localhost linux]# date
五  1月  8 14:30:15 CST 2016

(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)將新編的核心及組態檔拷至/boot目錄分別為vmlinuz-3.19.8及config-3.19.8

[root@localhost linux]# ll arch/x86/boot/bzImage
-rw-r--r-- 1 root root 5675104  1月  8 12:41 arch/x86/boot/bzImage
[root@localhost linux]# cp arch/x86/boot/bzImage /boot/vmlinuz-3.19.8
[root@localhost linux]# cp .config /boot/config-3.19.8


(11)安裝新的核心模組至/lib/modules/3.19.8
[root@localhost linux]# make modules_install

:  INSTALL /lib/firmware/keyspan_pda/keyspan_pda.fw
  INSTALL /lib/firmware/keyspan_pda/xircom_pgs.fw
  INSTALL /lib/firmware/cpia2/stv0672_vp4.bin
  INSTALL /lib/firmware/yam/1200.bin
  INSTALL /lib/firmware/yam/9600.bin
  DEPMOD  3.19.8


[root@localhost linux]# ll /lib/modules/
總計 12
drwxr-xr-x  6 root root 4096 10月  9  2014 3.14.19-100.fc19.i686.PAE
drwxr-xr-x  3 root root 4096  1月  8 14:53 3.19.8
drwxr-xr-x. 6 root root 4096  9月 22  2014 3.9.5-301.fc19.i686.PAE

(12)建立initramfs
[root@localhost linux]# dracut -v /boot/initramfs-3.19.8.img 3.19.8

:

I: Wrote /boot/initramfs-3.19.8.img:
I: -rw------- 1 root root 19669879  1月  8 15:13 /boot/initramfs-3.19.8.img
[root@localhost linux]#

(13)列出/boot
[root@localhost linux]# ll /boot
總計 97608
-rw-r--r--  1 root root   141987  9月 18  2014 config-3.14.19-100.fc19.i686.PAE
-rw-r--r--  1 root root   148440  1月  8 14:47 config-3.9.18
-rw-r--r--. 1 root root   128562  6月 12  2013 config-3.9.5-301.fc19.i686.PAE
drwxr-xr-x. 6 root root     1024 10月  9  2014 grub2
-rw-------. 1 root root 25527215  9月 22  2014 initramfs-0-rescue-6436dc21b02146c9bd2e8bb5d12ce2c1.img
-rw-------  1 root root  9110043 10月  9  2014 initramfs-3.14.19-100.fc19.i686.PAE.img
-rw-------  1 root root 19669879  1月  8 15:13 initramfs-3.19.8.img
-rw-------. 1 root root 16800247  9月 22  2014 initramfs-3.9.5-301.fc19.i686.PAE.img
-rw-r--r--. 1 root root   557301 10月  9  2014 initrd-plymouth.img
drwx------. 2 root root    12288  9月 22  2014 lost+found
-rw-------  1 root root  2242184  9月 18  2014 System.map-3.14.19-100.fc19.i686.PAE
-rw-r--r--  1 root root  2348934  1月  8 15:00 System.map-3.19.8
-rw-------. 1 root root  2055042  6月 12  2013 System.map-3.9.5-301.fc19.i686.PAE
-rwxr-xr-x. 1 root root  5025072  9月 22  2014 vmlinuz-0-rescue-6436dc21b02146c9bd2e8bb5d12ce2c1
-rwxr-xr-x  1 root root  5465744  9月 18  2014 vmlinuz-3.14.19-100.fc19.i686.PAE
-rwxr-xr-x  1 root root  5675104  1月  8 14:46 vmlinuz-3.19.8
-rwxr-xr-x. 1 root root  5025072  6月 12  2013 vmlinuz-3.9.5-301.fc19.i686.PAE
[root@localhost linux]#


(14)建立核心開機選單,最新編譯者為第1選項(預設選項)
[root@localhost linux]# 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.19-100.fc19.i686.PAE
Found initrd image: /boot/initramfs-3.14.19-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-6436dc21b02146c9bd2e8bb5d12ce2c1
Found initrd image: /boot/initramfs-0-rescue-6436dc21b02146c9bd2e8bb5d12ce2c1.img
Found FreeDOS on /dev/sda1
Found Fedora release 8 (Werewolf) on /dev/mapper/VolGroup00-LogVol00
done

(15)遠端重開機查看,新的Linux核心成功運中中

[root@localhost linux]# reboot

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.19.8 #1 SMP Fri Jan 8 12:41:11 CST 2016 i686 i686 i386 GNU/Linux
[root@localhost ~]#

Good, It's success!!

(16)參考文章

REF 1:http://linux.vbird.org/linux_basic/0540kernel.php
REF 2:http://linux.vbird.org/linux_basic/redhat6.1/linux_10kernel.php

迴響

Comment Icon
Posted by: asdad at 2016/04/27, 14:33
 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType