跳到主要內容

How to boot with old kernel version in RHEL7 ?














Environment

Red Hat Enterprise Linux 7 [ALL]

Issue
System installed with latest kernel version, but need to boot with old one.
How to change the default boot entry for kernel in RHEL 7 ?

Resolution


By default, the key for the GRUB_DEFAULT directive in the /etc/default/grub file is the word saved. This instructs GRUB 2 to load the kernel specified by the saved_entry directive in the GRUB 2 environment file, located at /boot/grub2/grubenv. One can set another GRUB record to be the default, using the grub2-set-default command, which will update the GRUB 2 environment file.


By default, the saved_entry value is set to the name of latest installed kernel of package type kernel. This is defined in /etc/sysconfig/kernel by the UPDATEDEFAULT and DEFAULTKERNEL directives. The file can be viewed by the root user as follows:




$ cat /etc/sysconfig/kernel


# UPDATEDEFAULT specifies if new-kernel-pkg should make


# new kernels the default


UPDATEDEFAULT=yes






# DEFAULTKERNEL specifies the default kernel package type


DEFAULTKERNEL=kernel


To force a system to always use a particular menu entry, use the menu entry name as the key to the GRUB_DEFAULT directive in the /etc/default/grub file. To list the available menu entries, run the following command as root:




~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2.cfg






Eg:


~]# awk -F\' '$1=="menuentry " {print $2}' /etc/grub2-efi.cfg


Red Hat Enterprise Linux Server (3.10.0-693.el7.x86_64) 7.3 (Maipo) <<==== Entry 0


Red Hat Enterprise Linux Server (3.10.0-514.el7.x86_64) 7.3 (Maipo) <<==== Entry 1


Red Hat Enterprise Linux Server (0-rescue-d3c598b9d2204138bd2e1001316a5cc6) 7.3 (Maipo)


GRUB 2 supports using a numeric value as the key for the saved_entry directive to change the default order in which the kernel or operating systems are loaded. To specify which kernel or operating system should be loaded first, pass its number to the grub2-set-default command. For example:




~]# grub2-set-default 1


Check the below file to see the kernel which will be loaded at next boot, crosscheck the numeric value with the menuentry in the /etc/default/grub file.




~]# cat /boot/grub2/grubenv |grep saved






Eg:


~]# cat /boot/grub2/grubenv |grep saved


saved_entry=1


Changes to /etc/default/grub require rebuilding the grub.cfg file as follows:


Rebuild the /boot/grub2/grub.cfg file by running the grub2-mkconfig -o command as follows:
On BIOS machines: ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
On UEFI machines: ~]# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg


留言

這個網誌中的熱門文章

AIX 7.1 參數

壹、 CPU 參數 一、SMT 說明:smt 此功能可加強CPU的使用效能,此功能可設定CPU在同一時間可同時處理的程序數量。 使用時間:為增加CPU的使用效率,且欲使程式執行時,可在同一時間執行多個程序,則可開啟此功能。AIX預設是有開啟此功能,預設值為4。 使用方法: 1.使用AIX 系統指令:smtctl -m off|on -w reboot|now開啟或關閉smt機制,系統預設smt機制為啟用,SMT=4 選擇關閉smt時smt=1 2.可透過AIX 系統指令:smtctl -t 1|2|4 -w now 修改smt個數。 系統影響:使用這項技術可以較明顯的提高處理器的的實際利用率,進而表現出更強的運算性能,但是主要還是以AP的特性為主。 現況:證交所使用預設值:SMT 4。 二、Resource set 說明:使用'resource set' 可將兩個不同的工作量分隔成兩個類別,並提供每一個類別不同的CPU 子集合,則可以確定即使這兩個工作量仍競爭實體記憶體及I/O 頻寬,它們也絕不會彼此競爭CPU 資源。 使用時間:欲將系統的AP所使用的CPU資源與其他AP隔離,確保AP一直擁有所設定的CPU使用權。使用方法: 1.使用系統指令:mkrset -c 'thread id' 'rsetname' 來定義一個CPU set 2.使用系統指令:execrset 'rsetname' -e '欲執行的AP'來分配CPU set 給AP使用 3.使用系統指令:lsrset -v -n 'rsetname' 查詢已分配的CPU set 系統影響:當分配CPU set 給某AP使用時,系統內的其他程序便無法使用該CPU set 裡的資源. 故欲使用resource set時,應先確定AP所使用的CPU資源。 現況:證交所並未使用,因CPU調用時較無彈性。 三、vpm_fold_policy 說明:是將CPU進行folding動作,此為當系統不忙時,將用不到的CPU對收起,當需要時才再將開啟。(default :1 ) 使用方法: 1. 使用系統指令:sched...

AIX clone update procedure

確認是否有mirror lsvg -l rootvg 解mirror Unmirrorvg rootvg hdisk1 將hdisk1退出rootvg Reducevg rootvg hdisk1 確認hdisk1已退出rootvg lspv 檢查開機磁碟 bootlist -m normal -o  rootvg clone alt_disk_copy -d hdisk1 檢查開機磁碟,此時開機磁碟將變到hdisk1 bootlist -m normal -o  將開機碟改回hdisk0 bootlist -m normal hdisk0 升級 install_all_updates -s /usr/sys/inst.images 重啟系統 cd /tmp/ & nohup shutdown -Fr &&  如升級運作正常,刪除舊的rootvg資料 alt_rootvg_op -X altinst_rootvg lspv 如升級運行不正常,使用clone的rootvg開啟 bootlist -m normal -o hdisk1 bootlist -m normal -o  重啟系統 cd /tmp/ &  nohup shutdown -Fr && 刪除異常rootvg資料 lspv alt_rootvg_op -X old_rootvg