{"id":1334,"date":"2012-09-19T09:33:54","date_gmt":"2012-09-19T07:33:54","guid":{"rendered":"http:\/\/raftaman.net\/?p=1334"},"modified":"2021-05-15T11:46:39","modified_gmt":"2021-05-15T09:46:39","slug":"change-grub2-default-boot-target-2","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=1334","title":{"rendered":"Change GRUB2 default boot target"},"content":{"rendered":"<p>In GRUB, the default boot menu entry was determined by the order of entries in <code>\/boot\/grub\/menu.lst<\/code>, the default one being the n-th specified by the <code>default=n<\/code> parameter.<\/p>\n<p>In GRUB2 the main configuration file <code>\/boot\/grub2\/grub.cfg<\/code> isn&#8217;t usually altered manually any more but automatically generated by invoking <code>grub2-mkconfig<\/code>. You can change the default boot target by changing the <code>GRUB_DEFAULT<\/code> paramater in <strong><code>\/etc\/default\/grub<\/code><\/strong>. It takes three different values:<\/p>\n<p><strong><code>GRUB_DEFAULT=n<\/code><\/strong> specifies the <strong>n-th entry<\/strong> in <code>\/boot\/grub2\/grub.cfg<\/code>. The first entry is selected with <code>GRUB_DEFAULT=0<\/code>, just like in GRUB.<\/p>\n<p><strong><code>GRUB_DEFAULT=\"String\"<\/code><\/strong> chooses an entry <strong>by name<\/strong> (e.g. &#8220;Fedora (3.5.3-1.fc17.x86_64)&#8221;)<\/p>\n<p><strong><code>GRUB_DEFAULT=saved<\/code><\/strong> chooses the boot target specified in <strong><code>\/boot\/grub\/grubenv<\/code><\/strong> regardless whether the order of entries has changed (e.g. due to a kernel update).<\/p>\n<p>To manipulate <code>\/boot\/grub\/grubenv<\/code>, you can list all possible entries<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ngrep ^menuentry \/boot\/grub2\/grub.cfg | cut -d &quot;'&quot; -f2\r\n<\/pre>\n<p>and specify the desired one with<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ngrub2-set-default &lt;menu entry title&gt;\r\n<\/pre>\n<p>To verify the default menu entry, use<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ngrub2-editenv list\r\n<\/pre>\n<p>Note that you have to run <\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ngrub2-mkconfig -o \/boot\/grub2\/grub.cfg\r\n<\/pre>\n<p>if you make any changes to <code>\/etc\/default\/grub<\/code> (e.g. change the <code>GRUB_DEFAULT<\/code> parameter). You don&#8217;t have to invoke it, if you just change the default target with <code>grub2-set-default<\/code> since this just alters <code>grubenv<\/code> but doesn&#8217;t make any changes to <code>grub.cfg<\/code>.<\/p>\n<p>Resources:<br \/>\n<a href=\"http:\/\/fedoraproject.org\/wiki\/GRUB_2\">http:\/\/fedoraproject.org\/wiki\/GRUB_2<\/a><br \/>\n<a href=\"http:\/\/www.linuxreaders.com\/2011\/11\/fedora-16-how-to-change-boot-sequence-grub2.html\">http:\/\/www.linuxreaders.com\/2011\/11\/fedora-16-how-to-change-boot-sequence-grub2.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In GRUB, the default boot menu entry was determined by the order of entries in \/boot\/grub\/menu.lst, the default one being the n-th specified by the default=n parameter. In GRUB2 the main configuration file \/boot\/grub2\/grub.cfg isn&#8217;t usually altered manually any more but automatically generated by invoking grub2-mkconfig. You can change the default boot target by changing the GRUB_DEFAULT paramater in \/etc\/default\/grub&#8230;. <a href=\"https:\/\/possiblelossofprecision.net\/?p=1334\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[7,52],"class_list":["post-1334","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-fedora","tag-grub2"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1334","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1334"}],"version-history":[{"count":10,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1334\/revisions"}],"predecessor-version":[{"id":2664,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1334\/revisions\/2664"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1334"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1334"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1334"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}