{"id":483,"date":"2010-08-08T06:41:14","date_gmt":"2010-08-08T11:41:14","guid":{"rendered":"http:\/\/www.familytidings.com\/blog\/?p=483"},"modified":"2010-08-31T03:51:35","modified_gmt":"2010-08-31T08:51:35","slug":"changing-os-name-in-grub-2-menu","status":"publish","type":"post","link":"https:\/\/www.familytidings.com\/blog\/?p=483","title":{"rendered":"Changing OS Name in Grub 2 Menu"},"content":{"rendered":"<p>Since upgrading Boon to Ubuntu 10.04, I&#8217;ve been running the new Grub 2 boot loader.  It looks much like the old grub, but the configuration is very different.  On installation, it found all the operating systems installed on Boon, including the Gateway recovery partition, which is labeled &#8220;Windows Vista (loader) (on \/dev\/sdb1)&#8221;.  Unfortunately, the Vista installation was labeled &#8220;Windows Vista (loader) (on \/dev\/sdb2)&#8221;.   Since sdb1 was listed first, my wife chose this and ended up very much not where she wanted to be.<br \/>\nWith Grub 1 (a.k.a. Grub Legacy), I&#8217;d have edited the menu entry title in <code>\/boot\/grub\/menu.lst<\/code> and been done with it.  Now the configuration file is named <code>\/boot\/grub\/grub.cfg<\/code> and warns &#8220;DO NOT EDIT THIS FILE.&#8221;  No problem, but where <em>am<\/em> I supposed to make the change?<br \/>\nI started with the <a href=\"https:\/\/wiki.ubuntu.com\/Grub2\">Ubuntu Wiki Grub 2 instructions<\/a>.  From there, I found out how <code>grub.cfg<\/code> is created and how to exclude entries or add custom ones, but nothing specifically about how to change the title of a menu entry.  I suppose I could edit <code>\/etc\/grub.d\/30_os-prober<\/code> manually, but with all this talk of Grub 2&#8217;s increased flexibility, I suspect there&#8217;s a better way.<br \/>\nNext, I checked out the <a href=\"https:\/\/help.ubuntu.com\/community\/Grub2\">Grub 2 Community Ubuntu Documentation<\/a>.  Not much there.  Maybe I&#8217;m too optimistic, but I don&#8217;t see the average user editing shell scripts to change his boot menu.  But it seems that&#8217;s what I have to do.<br \/>\nI want to preserve the original script and work with a copy:<br \/>\n<code>sudo cp \/etc\/grub.d\/30_os-prober \/etc\/grub.d\/31_os-prober-custom<\/code><br \/>\n<code>sudo chmod -x \/etc\/grub.d\/30_os-prober<\/code><br \/>\nThe mode change prevents the original from running and producing duplicate entries.  Next, edit <code>\/etc\/grub.d\/31_os-prober-custom<\/code>:<br \/>\nFind <\/p>\n<pre>\r\n  case ${BOOT} in\r\n    chain)\r\n<\/pre>\n<p>and change the lines after that from:<\/p>\n<pre>\r\n      cat << EOF\r\nmenuentry \"${LONGNAME} (on ${DEVICE})\" {\r\nEOF\r\n<\/pre>\n<p> to: <\/p>\n<pre>\r\n      case ${DEVICE} in \r\n\t\/dev\/sdb1)\r\n        cat << EOF\r\nmenuentry \"Gateway Recovery (on ${DEVICE})\" {\r\nEOF\r\n\t;;\r\n\t*)\r\n        cat << EOF\r\nmenuentry \"${LONGNAME} (on ${DEVICE})\" {\r\nEOF\r\n        ;;\r\n      esac\r\n<\/pre>\n<p>Of course, this is specific to my installation.  What the code change does is alter the label for <em>anything<\/em> on <code>\/dev\/sdb1<\/code> to \"Gateway Recovery\".  Since there can be only one OS per partition and I'm not moving the recovery partition, this is fine.<br \/>\nTo make the changes stick, run <code>sudo update-grub<\/code>.<br \/>\nBTW, if you're using an editor such as Emacs that makes backup copies, don't worry about the backups.  <code>update-grub<\/code> is smart enough to exclude them.  I mention this only because this was a problem with a script from an older distribution that handled events on my Laptop.  Since the original script and the backup got run, closing the laptop lid caused two instances of the event to run.  The laptop would hibernate, then when the lid was opened, it would wake up and immediately hibernate again.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Since upgrading Boon to Ubuntu 10.04, I&#8217;ve been running the new Grub 2 boot loader. It looks much like the old grub, but the configuration is very different. On installation, it found all the operating systems installed on Boon, including the Gateway recovery partition, which is labeled &#8220;Windows Vista (loader) (on \/dev\/sdb1)&#8221;. Unfortunately, the Vista [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-483","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/483","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=483"}],"version-history":[{"count":18,"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions"}],"predecessor-version":[{"id":497,"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/483\/revisions\/497"}],"wp:attachment":[{"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=483"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=483"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.familytidings.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=483"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}