{"id":1348,"date":"2012-10-01T10:11:17","date_gmt":"2012-10-01T08:11:17","guid":{"rendered":"http:\/\/raftaman.net\/?p=1348"},"modified":"2021-05-15T11:46:38","modified_gmt":"2021-05-15T09:46:38","slug":"adding-custom-boot-target-to-grub2","status":"publish","type":"post","link":"https:\/\/possiblelossofprecision.net\/?p=1348","title":{"rendered":"Adding custom boot target to GRUB2"},"content":{"rendered":"<p>In GRUB2 one doesn&#8217;t alter the main configuration file <code>\/boot\/grub2\/grub.cfg<\/code> manually any more. Boot menu entries are automatically determined by the <code>grub2-mkconfig<\/code> script.<\/p>\n<p>To add a custom menu entry, edit <strong><code>\/etc\/grub.d\/40_custom<\/code><\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n&#x5B;...]\r\nmenuentry 'Custom Entry' {\r\n  set root='hd0,msdos2'\r\n  echo    'Loading Linux'  \r\n  linux   \/vmlinuz\r\n  echo    'Loading initial ramdisk ...'\r\n  initrd  \/initramfs.img\r\n}\r\n<\/pre>\n<p>Note that GRUB2 <strong>partition numbering starts with 1<\/strong> (not 0 like GRUB) but disk numbering starts with 0, e.g. if your kernel and inital ramdisk are located on <code>\/dev\/sda2<\/code>, this translates to hd0,2.<\/p>\n<p>On MS-DOS type partitions (which currently is the majority of partitions out there) <code>hd0,2<\/code> and <code>hd0,msdos2<\/code> are interchangeable.<\/p>\n<p>To recreated <code>grub.cfg<\/code> with the added boot menu entry, invoke<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngrub2-mkconfig -o \/boot\/grub2\/grub.cfg\r\n<\/pre>\n<p>Resources:<br \/>\n<a href=\"http:\/\/home.roadrunner.com\/~computertaijutsu\/grub2.html\">http:\/\/home.roadrunner.com\/~computertaijutsu\/grub2.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In GRUB2 one doesn&#8217;t alter the main configuration file \/boot\/grub2\/grub.cfg manually any more. Boot menu entries are automatically determined by the grub2-mkconfig script. To add a custom menu entry, edit \/etc\/grub.d\/40_custom &#x5B;&#8230;] menuentry &#8216;Custom Entry&#8217; { set root=&#8217;hd0,msdos2&#8242; echo &#8216;Loading Linux&#8217; linux \/vmlinuz echo &#8216;Loading initial ramdisk &#8230;&#8217; initrd \/initramfs.img } Note that GRUB2 partition numbering starts with 1 (not&#8230; <a href=\"https:\/\/possiblelossofprecision.net\/?p=1348\">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":[52],"class_list":["post-1348","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-grub2"],"_links":{"self":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1348","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=1348"}],"version-history":[{"count":7,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1348\/revisions"}],"predecessor-version":[{"id":2663,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=\/wp\/v2\/posts\/1348\/revisions\/2663"}],"wp:attachment":[{"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1348"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/possiblelossofprecision.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}