Fixing XenServer Ubuntu grub.GrubConf.Grub2ConfigFile Error.

I just updated Ubuntu from 12.04 to 14.04 in a xenserver vm and ran into this error:
xsshotStarting VM
Using <class ‘grub.GrubConf.Grub2ConfigFile’> to parse /grub/grub.cfg – WARNING:root:Unknown directive load_video – WARNING:root:Unknown directive terminal_output – WARNING:root:Unknown directive else – WARNING:root:Unknown directive elif – WARNING:root:Unknown directive else – WARNING:root:Unknown directive else – WARNING:root:Unknown directive else – WARNING:root:Unknown directive else – WARNING:root:Unknown directive export – WARNING:root:Unknown image directive recordfail – WARNING:root:Unknown image directive gfxmode – WARNING:root:Unknown image directive recordfail – WARNING:root:Unknown directive submenu – WARNING:root:Unknown image directive recordfail – WARNING:root:Unknown image directive gfxmode – WARNING:root:Unknown image directive recordfail – Traceback (most recent call last): – File “/usr/bin/pygrub”, line 850, in ? – raise RuntimeError, “Unable to find partition containing kernel” – RuntimeError: Unable to find partition containing kernel

So what’s going on here?

This happens because after updating your kernel, grub adds a couple of lines. If this was a regular machine you would just see those added like in the image below.

sshot169

But now that the grub has these extra entries Xenserver sometimes fails here and results in the above grub error. You could fix this manually by mounting the bootloader (xe-edit-bootloader -n your_vm_name -p 1 ) and then comment out every thing under the “Previous Linux Versions” or after doing an upgrade running a purge on previous kernel versions with a fancy command like (dpkg -l ‘linux-*’ | sed ‘/^ii/!d;/'”$(uname -r | sed “s/\(.*\)-\([^0-9]\+\)/\1/”)”‘/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d’ | xargs sudo apt-get purge -y )

But that won’t fix anything in the future. Do it the proper way and fix your xenserver. With the following.

1. Backup your /usr/lib/python2.4/site-packages/grub/GrubConf.py

2 Replace it with this working version:

GrubConf.py

3. Blamo! Your machines may upgrade now and your broken ones will boot!

 

Leave a Reply

Your email address will not be published.