{"id":98,"date":"2015-02-21T16:28:44","date_gmt":"2015-02-21T15:28:44","guid":{"rendered":"http:\/\/www.underealm.com\/tech\/?p=98"},"modified":"2015-02-21T16:32:22","modified_gmt":"2015-02-21T15:32:22","slug":"xenserver-grubconf-fix-script","status":"publish","type":"post","link":"http:\/\/www.underealm.com\/tech\/2015\/02\/xenserver-grubconf-fix-script\/","title":{"rendered":"XenServer GrubConf.py fix script"},"content":{"rendered":"<p>In a previous article (<a href=\"\/tech\/2014\/09\/fixing-xenserver-error-unable-to-find-partition-containing-kernel\/\">Fixing XenServer error \u201cUnable to find partition containing kernel\u201d<\/a>) I described how to fix a recurring problem after patching XenServer 6.2 installations. While the fix is known from years it&#8217;s never been adopted, and different distros (such as Ubuntu LTS 14.04) fail to boot properly when the GrubConf.py (on dom0) gets reset to its default state.<\/p>\n<p>Being the lazy person that I am I decided to set up a script to do the work for me, after all we&#8217;re admins, not monkeys.<\/p>\n<pre class=\"toolbar:1\" lang=\"bash\" title=\"fixboot.sh\"><code>#!\/bin\/bash\r\nGRUBCONF=\"\/usr\/lib\/python2.4\/site-packages\/grub\/GrubConf.py\"\r\nPATCHED=$(grep \"_entry\" $GRUBCONF | wc -l)\r\nif [ $PATCHED -eq 2 ]; then\r\n  echo \"GrubConf.py is already patched\"\r\nelse\r\n  echo \"Patching GrubConf.py to fix boot...\"\r\n  sed -i 's\/_entry}\":\/_entry}\":\\n                        arg = \"0\"\\n                    elif arg.strip() == \"${next_entry}\":\/' $GRUBCONF\r\n  PATCHED=$(grep \"_entry\" $GRUBCONF | wc -l)\r\n  if [ $PATCHED -eq 2 ]; then\r\n    echo \"- Patch was applied successfully.\"\r\n  else\r\n    echo \"- There was a problem while applying the patch.\"\r\n  fi;\r\nfi;\r\necho<\/code><\/pre>\n<p>This does just what I\/we used to do manually: detects if <strong>GrubConf.py<\/strong> has been reverted and, if not, patches it up. Supplementary tests added for paranoia \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a previous article (Fixing XenServer error \u201cUnable to find partition containing kernel\u201d) I described how to fix a recurring problem after patching XenServer 6.2 installations. While the fix is known from years it&#8217;s never been adopted, and different distros (such as Ubuntu LTS 14.04) fail to boot properly when the GrubConf.py (on dom0) gets [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[13,9,10,5,11,14,8,58,59],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-xenserver","tag-bash-script","tag-boot-problem","tag-bootloader","tag-citrix","tag-grub","tag-grub2","tag-python","tag-sysad","tag-xenserver"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/posts\/98"}],"collection":[{"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":0,"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.underealm.com\/tech\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}