【教學】Ubuntu 16.04 / 18.04 還原指定版本 Kernel



實作環境:

  • 平台: AWS

  • OS: Ubuntu 18.04


Step 1. 使用指令查詢當前 Kernel 的 $menuentry_id_option

執行指令

grep submenu /boot/grub/grub.cfg


記住$menuentry_id_option

以我為例就是記住 gnulinux-advanced-1b28661d-dff9-40d3-970a-8798394d54f6

submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-1b28661d-dff9-40d3-970a-8798394d54f6' {


Step 2. 使用指令查詢你想要還原的 Kernel 的 $menuentry_id_option

執行以下指令

grep gnulinux /boot/grub/grub.cfg


找到想要用的 Kernel,並記住 $menuentry_id_option

以我為例,假如我想使用 5.4.0-1029-aws ,就記下 gnulinux-5.4.0-1029-aws-advanced-1b28661d-dff9-40d3-970a-8798394d54f6

menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-1b28661d-dff9-40d3-970a-8798394d54f6' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-1b28661d-dff9-40d3-970a-8798394d54f6' {
menuentry 'Ubuntu, with Linux 5.4.0-1037-aws' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-1037-aws-advanced-1b28661d-dff9-40d3-970a-8798394d54f6' {
menuentry 'Ubuntu, with Linux 5.4.0-1037-aws (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-1037-aws-recovery-1b28661d-dff9-40d3-970a-8798394d54f6' {
menuentry 'Ubuntu, with Linux 5.4.0-1035-aws' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-1035-aws-advanced-1b28661d-dff9-40d3-970a-8798394d54f6' {
menuentry 'Ubuntu, with Linux 5.4.0-1035-aws (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-1035-aws-recovery-1b28661d-dff9-40d3-970a-8798394d54f6' {
menuentry 'Ubuntu, with Linux 5.4.0-1029-aws' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-1029-aws-advanced-1b28661d-dff9-40d3-970a-8798394d54f6' {
menuentry 'Ubuntu, with Linux 5.4.0-1029-aws (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-1029-aws-recovery-1b28661d-dff9-40d3-970a-8798394d54f6' {


Step 3. 使用 ">" 合併兩個查詢到的值

請以當前 Kernel > 要還原的 Kernel 組合,以本篇為例,合併後就是以下的值

gnulinux-advanced-1b28661d-dff9-40d3-970a-8798394d54f6>gnulinux-5.4.0-1029-aws-advanced-1b28661d-dff9-40d3-970a-8798394d54f6


Step 4. 修改 /etc/default/grub

修改 GRUB_DEFAULT=0 這欄,改成你所組合的值,類似以下範例。記得用 " 括起來

GRUB_DEFAULT="gnulinux-advanced-1b28661d-dff9-40d3-970a-8798394d54f6>gnulinux-5.4.0-1029-aws-advanced-1b28661d-dff9-40d3-970a-8798394d54f6"
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""


Step 5. 更新 Grub 使設定生效

sudo update-grub


Step 6. 重啟

使用以下指令確認 Kernel 版本

uname -r




留言

  1. Slots casino site - Lucky Club
    The UK's largest online casino luckyclub is now live with Playtech, and this is thanks to the addition of their own proprietary software. Players can also  Rating: 4 · ‎Review by Lucky Club

    回覆刪除