{"id":429,"date":"2018-10-04T22:41:05","date_gmt":"2018-10-04T22:41:05","guid":{"rendered":"http:\/\/linuxresellerwebhosting.in\/blog\/?p=429"},"modified":"2018-10-04T22:49:29","modified_gmt":"2018-10-04T22:49:29","slug":"how-to-change-default-kernel-on-cent-os","status":"publish","type":"post","link":"https:\/\/linuxresellerwebhosting.in\/blog\/how-to-change-default-kernel-on-cent-os\/","title":{"rendered":"How to Change Default Kernel on Cent OS"},"content":{"rendered":"<p>Hi All,<\/p>\n<p>Today, We are going to about how to change the default Kernel on CentOS.<\/p>\n<p>What is Kernel ?<\/p>\n<p>Kernel is heart of Operating System, It is low level interrupter for user and hardware.<\/p>\n<p>Kernel is heart of Operating System.<\/p>\n<p><strong>GRUB2<\/strong> is the most common bootloader for RHEL 7 systems. A symlink to the GRUB2 config file should be present at <strong>\/etc\/grub2.cfg<\/strong>. The post describes changing the default kernel to a old kernel.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"How_GRUB2_selects_which_kernel_to_boot_from\"><\/span><strong>How GRUB2 selects which kernel to boot from<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3><div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-light-blue ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/how-to-change-default-kernel-on-cent-os\/#How_GRUB2_selects_which_kernel_to_boot_from\" >How GRUB2 selects which kernel to boot from<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/how-to-change-default-kernel-on-cent-os\/#Change_default_kernel\" >Change default kernel<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/how-to-change-default-kernel-on-cent-os\/#Verify_the_new_default_kernel\" >Verify the new default kernel<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/linuxresellerwebhosting.in\/blog\/how-to-change-default-kernel-on-cent-os\/#Rebuild_GRUB2\" >Rebuild GRUB2<\/a><\/li><\/ul><\/nav><\/div>\n\n<pre class=\"\"># cat \/etc\/default\/grub\r\nGRUB_TIMEOUT=5\r\n&lt;strong&gt;GRUB_DEFAULT=saved&lt;\/strong&gt;\r\nGRUB_DISABLE_SUBMENU=true\r\nGRUB_TERMINAL_OUTPUT=\"console\"\r\nGRUB_CMDLINE_LINUX=\"nomodeset crashkernel=auto rd.lvm.lv=vg_os\/lv_root rd.lvm.lv=vg_os\/lv_swap rhgb quiet\"\r\nGRUB_DISABLE_RECOVERY=\"true\"<\/pre>\n<p>This instructs GRUB 2 to load the kernel specified by the <strong>saved_entry<\/strong> directive in the GRUB 2 environment file, located at <strong>\/boot\/grub2\/grubenv<\/strong>.<\/p>\n<pre class=\"\"># cat \/boot\/grub2\/grubenv \r\n# GRUB Environment Block\r\nsaved_entry=Red Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo)<\/pre>\n<p>One can set another GRUB record to be the default, using the <strong>grub2-set-default<\/strong> 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 <strong>\/etc\/sysconfig\/kernel<\/strong> by the <strong>UPDATEDEFAULT<\/strong> and <strong>DEFAULTKERNEL<\/strong> directives.<\/p>\n<pre class=\"\"># cat \/etc\/sysconfig\/kernel\r\n# UPDATEDEFAULT specifies if new-kernel-pkg should make\r\n# new kernels the default\r\nUPDATEDEFAULT=yes\r\n\r\n# DEFAULTKERNEL specifies the default kernel package type\r\nDEFAULTKERNEL=kernel\r\n\r\n# MAKEDEBUG specifies if new-kernel-pkg should create non-default\r\n# \"debug\" entries for new kernels.\r\nMAKEDEBUG=yes<\/pre>\n<h3><span class=\"ez-toc-section\" id=\"Change_default_kernel\"><\/span><strong>Change default kernel<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>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 <strong>\/etc\/default\/grub<\/strong> file. The following command will print a list of the menu entries present in GRUB2\u2019s configuration.<\/p>\n<pre class=\"\"># awk -F\\' \/^menuentry\/{print\\$2} \/etc\/grub2.cfg\r\nRed Hat Enterprise Linux Server (3.10.0-327.10.1.el7.x86_64) 7.2 (Maipo)                          ===&gt; entry 0\r\nRed Hat Enterprise Linux Server (3.10.0-229.el7.x86_64) 7.2 (Maipo)                               ===&gt; entry 1\r\nRed Hat Enterprise Linux Server (0-rescue-0cb6313ed65e4b36ba5daace11f3ad50) 7.2 (Maipo)<\/pre>\n<div class=\"codeme\">\n<pre># grub2-set-default 1<\/pre>\n<\/div>\n<p>This will make <strong>3.10.0-229.el7.x86_64<\/strong> as defaul kernel which was the old kernel in the system.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Verify_the_new_default_kernel\"><\/span><strong>Verify the new default kernel<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>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.<\/p>\n<div class=\"codeme\">\n<pre class=\"\"># cat \/boot\/grub2\/grubenv |grep saved\r\nsaved_entry=1<\/pre>\n<\/div>\n<h3><span class=\"ez-toc-section\" id=\"Rebuild_GRUB2\"><\/span><strong>Rebuild GRUB2<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Changes to \/etc\/default\/grub require rebuilding the grub.cfg file as follows:<\/p>\n<div class=\"codeme\">\n<pre class=\"\"># grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/pre>\n<\/div>\n<p>After rebooting server, the changes will take effect.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi All, Today, We are going to about how to change the default Kernel on CentOS. What is Kernel ?<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[1],"tags":[],"class_list":["post-429","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":7,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":444,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/posts\/429\/revisions\/444"}],"wp:attachment":[{"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxresellerwebhosting.in\/blog\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}