]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Configure grub to default to the right kernel, not the greatest installed one.
authorTommi Virtanen <tommi.virtanen@dreamhost.com>
Wed, 10 Aug 2011 20:40:00 +0000 (13:40 -0700)
committerTommi Virtanen <tommi.virtanen@dreamhost.com>
Wed, 10 Aug 2011 20:40:00 +0000 (13:40 -0700)
This is sticky; that is, even if you install other kernels (manually/via fab/etc),
grub will keep booting up the one that was last enabled via teuthology config.
Use teuthology to switch kernels and it'll just work.

If the kernel the grub default points to is removed, grub will fall back to
booting the kernel with the greatest version number.

Closes: http://tracker.newdream.net/issues/1364
teuthology/task/kernel.py

index 7f3ce70e139fbcb5d93b366d70131718f76defd2..50a40a1952f58815acc0ec5754f630a1fe116f11 100644 (file)
@@ -119,6 +119,50 @@ def install_and_reboot(ctx, config):
                 '-i',
                 '/tmp/linux-image.deb',
                 run.Raw('&&'),
+                # and now extract the actual boot image name from the deb
+                'dpkg-deb',
+                '--fsys-tarfile',
+                '/tmp/linux-image.deb',
+                run.Raw('|'),
+                'tar',
+                '-t',
+                '-v',
+                '-f', '-',
+                '--wildcards',
+                '--',
+                './boot/vmlinuz-*',
+                run.Raw('|'),
+                # we can only rely on mawk being installed, so just call it explicitly
+                'mawk',
+                # and use the image name to construct the content of
+                # the grub menu entry, so we can default to it;
+                # hardcoded to assume Ubuntu, English, etc.
+                r'{sub("^\\./boot/vmlinuz-", "", $6); print "cat <<EOF\n" "set default=\"Ubuntu, with Linux " $6 "\"\n" "EOF"}',
+                # make it look like an emacs backup file so
+                # unfortunately timed update-grub runs don't pick it
+                # up yet; use sudo tee so we are able to write to /etc
+                run.Raw('|'),
+                'sudo',
+                'tee',
+                '--',
+                '/etc/grub.d/01_ceph_kernel.tmp~',
+                run.Raw('>/dev/null'),
+                run.Raw('&&'),
+                'sudo',
+                'chmod',
+                'a+x',
+                '--',
+                '/etc/grub.d/01_ceph_kernel.tmp~',
+                run.Raw('&&'),
+                'sudo',
+                'mv',
+                '--',
+                '/etc/grub.d/01_ceph_kernel.tmp~',
+                '/etc/grub.d/01_ceph_kernel',
+                run.Raw('&&'),
+                'sudo',
+                'update-grub',
+                run.Raw('&&'),
                 'rm',
                 '/tmp/linux-image.deb',
                 run.Raw('&&'),