天天看點

阿裡雲ECS編譯更新VM核心到4.x

操作有風險,請做好快照備份。下面是操作過程:

檢視目前系統版本centos7.0;核心版本:3.10.0;

<code>1</code>

<code>[root@iz28yx1yevuz ~]</code><code># lsb_release -a</code>

<code>2</code>

<code>lsb version:    :core-4.1-amd64:core-4.1-noarch</code>

<code>3</code>

<code>distributor id: centos</code>

<code>4</code>

<code>description:    centos linux release 7.0.1406 (core)</code>

<code>5</code>

<code>release:        7.0.1406</code>

<code>6</code>

<code>codename:       core</code>

<code>7</code>

<code>[root@iz28yx1yevuz ~]</code><code># uname -r</code>

<code>8</code>

<code>3.10.0-123.9.3.el7.x86_64</code>

阿裡雲ECS編譯更新VM核心到4.x

前往kernel.org下載下傳目前最新的核心版本:

<code>[root@iz28yx1yevuz ~]</code><code>#wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.6.tar.xz;mv linux-4.1.6.tar.xz /usr/src</code>

<code>[root@iz28yx1yevuz ~]</code><code>#cd /usr/src;tar -xf linux-4.1.6.tar.xz</code>

解壓壓縮包,并通過make menuconfig方式編譯,如下,出現報錯:

阿裡雲ECS編譯更新VM核心到4.x

這是因為menuconfig需要ncurses-devel 支援,下面安裝ncurses-devel後重新編譯就可以了

<code>root@iz28yx1yevuz ~]</code><code># yum install ncurses-devel -y</code>

阿裡雲ECS編譯更新VM核心到4.x

由于阿裡雲目前大部分機器還是xen環境的,是以阿裡雲環境下編譯和普通系統相比,需要增加xen guest support,如下(menuconfig下如果找不到配置,可以個vi一樣,通過”/”方式搜尋):

注意:這些子產品需要built-in,也就是複選框内需要是*,而不是m

processor type and features-&gt;linux guest support-&gt;xen guest support

阿裡雲ECS編譯更新VM核心到4.x

 device drivers  —&gt; block devices  —&gt; xen virtual block device support

device drivers  —&gt; block devices  —&gt;  xen block-device backend driver

阿裡雲ECS編譯更新VM核心到4.x

device drivers  —&gt;xen driver support  把下面的選項建議都選上

阿裡雲ECS編譯更新VM核心到4.x

 網絡方面的驅動:

device drivers  —&gt; network device support  —&gt; xen network device frontend driver

device drivers  —&gt; network device support  —&gt;  xen backend network device

阿裡雲ECS編譯更新VM核心到4.x

完成後開始編譯,這裡使用vzimage編譯後的核心是壓縮的。

<code>[root@iz28yx1yevuz ~]</code><code>#make -j 16 bzimage</code>

(這個過程會非常的漫長,為了防止終端意外斷開導緻前功盡棄,這裡建議在screen下執行操作。我測試伺服器是16核,是以這裡制定了16個job加速編譯)

阿裡雲ECS編譯更新VM核心到4.x
阿裡雲ECS編譯更新VM核心到4.x

完成後依次編譯子產品,安裝

<code>[root@iz28yx1yevuz ~]</code><code>#make -j16 modules</code>

<code>[root@iz28yx1yevuz ~]</code><code>#make -j16 modules_install</code>

<code>[root@iz28yx1yevuz ~]</code><code>#make -j16 install</code>

阿裡雲ECS編譯更新VM核心到4.x

 完成後看一下grub檔案,目前有三個引導項目:

<code>root@iz28yx1yevuz ~]</code><code>#cat /etc/grub2.cfg |egrep ^menuentry</code>

阿裡雲ECS編譯更新VM核心到4.x

看一下目前的預設引導項是3.10.0核心

<code>root@iz28yx1yevuz linux-4.1.6]</code><code># grub2-editenv list</code>

<code>saved_entry=centos linux (3.10.0-123.9.3.el7.x86_64) 7 (core)</code>

将預設引導核心改為我們剛安裝的4.1.6版本

<code>[root@iz28yx1yevuz linux-4.1.6]</code><code># grub2-set-default "centos linux (4.1.6) 7 (core)"</code>

目前預設引導項是最新的核心了,這時候重新開機測試

<code>saved_entry=centos linux (4.1.6) 7 (core)</code>

<code>[root@iz28yx1yevuz linux-4.1.6]</code><code># reboot</code>

預設選擇的是4.1.6核心

阿裡雲ECS編譯更新VM核心到4.x

正常啟動後測試,核心已經是最新的版本了。

阿裡雲ECS編譯更新VM核心到4.x

繼續閱讀