Docker-01 無人值守升級 CentOS 6.x 系統核心到 3.10.101

來源:互聯網
上載者:User

標籤:

  1 #!/bin/bash  2   3 #  4 #    無人值守升級 CentOS 6.x 系統核心到 3.10.101  5 #  6 #    全程參考 https://segmentfault.com/a/1190000000733628  7 #  8   9  10 # 11 #    1、檢查作業系統是否為 CentOS 6.x 12 # 13  14 cat /etc/centos-release |grep -i centos |egrep ‘6.[[:digit:]]+‘ &>/dev.null 15 if [[ $? != 0 ]] 16 then 17     echo -e "不支援的作業系統,該指令碼只適用於 CentOS 6.x 作業系統" 18     exit 1 19 fi 20  21 # 22 #    2、檢查當前核心版本是否滿足安裝 Docker 的要求: 23 #       如果滿足直接退出指令碼,如果不滿足將自動升級系統核心 24 # 25  26 if [[ $(uname -r |awk -F ‘.‘ ‘{print $1}‘) -ge 3 ]] 27 then 28     if [[ $(uname -r |awk -F ‘.‘ ‘{print $2}‘) -ge 10 ]] 29     then 30         echo "該作業系統核心版本已滿足安裝 Docker 的要求,無需升級" 31         exit 1 32     fi 33 fi 34  35 # 36 #    3、檢查 YUM 源是否可用 37 # 38          39 yum list &>/dev/null 40  41 if [[ $? != 0 ]] 42 then 43     echo "YUM 源配置錯誤" 44     exit 1 45 fi 46  47 # 48 #    4、安裝軟體包組 "Development Tools" 49 # 50  51 yum groupinstall -y "Development Tools"  52  53 if [[ $? != 0 ]] 54 then 55     echo "YUM 安裝開發工具失敗" 56     exit 1 57 fi 58  59 # 60 #    5、安裝編譯 Linux 核心除 "Development Tools" 以外的其他軟體包 61 # 62  63 yum install -y wget ncurses-devel hmaccalc zlib-devel binutils-devel elfutils-libelf-devel 64  65 if [[ $? != 0 ]] 66 then 67     echo "YUM 安裝開發工具失敗" 68     exit 1 69 fi 70  71 # 72 #    6、下載 Linux 核心檔案 3.10.101 ,並解壓到 /usr/src/ 目錄下 73 # 74  75 #wget https://cdn.kernel.org/pub/linux/kernel/v3.x/linux-3.10.101.tar.xz 76 wget http://mirrors.aliyun.com/linux-kernel/v3.x/linux-3.10.101.tar.xz 77 tar -xf linux-3.10.101.tar.xz -C /usr/src 78 if [[ ! -d /usr/src/linux-3.10.101/ ]] 79 then 80     echo "Linux 核心檔案 3.10.101 下載失敗" 81     exit 1 82 fi 83  84 # 85 #    7、在原有核心設定檔的基礎上建立新的編譯選項 86 # 87  88 cd /usr/src/linux-3.10.101/ 89 cp /boot/config-$(uname -r) .config 90 sh -c ‘yes "" | make oldconfig‘ 91  92 # 93 #    8、開始編譯 Linux 核心 3.10.101 94 #        產生核心檔案 95 #        編譯模組 96 #        編譯安裝模組 97 # 98  99 cd /usr/src/linux-3.10.101/100 101 make -j$(cat /proc/cpuinfo |grep processor |wc -l) bzImage102 103 if [[ $? != 0 ]]104 then105     echo "產生核心檔案失敗"106     exit 1107 fi108 109 make -j$(cat /proc/cpuinfo |grep processor |wc -l) modules110 111 if [[ $? != 0 ]]112 then113     echo "編譯模組失敗"114     exit 1115 fi116 117 make -j$(cat /proc/cpuinfo |grep processor |wc -l) modules_install118 119 if [[ $? != 0 ]]120 then121     echo "編譯安裝模組失敗"122     exit 1123 fi124 125 #126 #    9、安裝 Linux 核心 3.10.101127 #128 129 cd /usr/src/linux-3.10.101/130 make install131 132 #133 #    10、配置 GRUB ,下次啟動時載入新的核心134 #135 136 sed -i ‘s/default=1/default=0/‘ /etc/grub.conf137 sed -i ‘s/default=1/default=0/‘ /boot/grub/grub.conf138 echo -en "\n\t"139 read -p "立即重啟作業系統,載入核心 3.10.101 [y/N]" rebootnow140 if [[ $rebootnow == y ]]141 then142     reboot143 else144     echo -e "\n\t稍後手動重啟作業系統載入核心 3.10.101\n"145 fi

 

Docker-01 無人值守升級 CentOS 6.x 系統核心到 3.10.101

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.