From e5aa03b98a08e008ed494cddec996c3bdb312425 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 20 Dec 2016 12:07:42 +1100 Subject: [PATCH] Use DIB_GRUB_TIMEOUT to set boot timeout We currently re-run all the grub setup in 99-fix-grub-timeout which shouldn't really be necessary (actually a little problematic; although this is dib's fault, see Ibaaa81124098f3c6febe48e455d3e1cd0a5f1761) Use the new timeout flag to set this in the bootloader element directly. I think it is also an advantage that if you build a testing image with ./tools/build_image.sh this is configurable now ... having to fiddle the bootloader for debugging is something that happens more than you'd like. This is supported since dib 1.26.0 Change-Id: Iafc660a9a8c072af6bf1fd5e51c419abccef4d54 --- .../finalise.d/99-fix-grub-timeout | 44 ------------------- nodepool/nodepool.yaml | 6 +++ tools/build-image.sh | 4 ++ 3 files changed, 10 insertions(+), 44 deletions(-) delete mode 100755 nodepool/elements/nodepool-base/finalise.d/99-fix-grub-timeout diff --git a/nodepool/elements/nodepool-base/finalise.d/99-fix-grub-timeout b/nodepool/elements/nodepool-base/finalise.d/99-fix-grub-timeout deleted file mode 100755 index b4b3be4e30..0000000000 --- a/nodepool/elements/nodepool-base/finalise.d/99-fix-grub-timeout +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# Copyright (C) 2014 Hewlett-Packard Development Company, L.P. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -# implied. -# -# See the License for the specific language governing permissions and -# limitations under the License. - -# This is done in 50 because the vm element has, at 51, an bunch of code -# for properly handling grub. All we need to do here is get our values -# in to the files. - -# dib-lint: disable=setu setpipefail -if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then - set -x -fi -set -e - -# Set grub timeout to zero to save boot time. -if [ -f /etc/default/grub ] ; then - sed -i -e 's/^GRUB_TIMEOUT=[0-9]\+/GRUB_TIMEOUT=0/' /etc/default/grub - if which update-grub &> /dev/null ; then - update-grub - else - if [[ $DISTRO_NAME == gentoo ]]; then - GRUB_CFG=/boot/grub/grub.cfg - else - GRUB_CFG=/boot/grub2/grub.cfg - fi - # If update-grub isn't available, use grub2-mkconfig directly - /usr/sbin/grub2-mkconfig -o "${GRUB_CFG}" - fi -elif [ -f /boot/grub/grub.conf ] ; then - sed -i -e 's/^timeout=[0-9]\+/timeout=0/' /boot/grub/grub.conf -fi diff --git a/nodepool/nodepool.yaml b/nodepool/nodepool.yaml index 6384dbfe6d..4ca424b25e 100644 --- a/nodepool/nodepool.yaml +++ b/nodepool/nodepool.yaml @@ -909,6 +909,7 @@ diskimages: DIB_APT_LOCAL_CACHE: '0' DIB_DISABLE_APT_CLEANUP: '1' DIB_DISTRIBUTION_MIRROR: http://ftp.us.debian.org/debian/ + DIB_GRUB_TIMEOUT: '0' - name: ubuntu-precise elements: - ubuntu-minimal @@ -928,6 +929,7 @@ diskimages: DIB_APT_LOCAL_CACHE: '0' DIB_DISABLE_APT_CLEANUP: '1' FS_TYPE: ext3 + DIB_GRUB_TIMEOUT: '0' - name: ubuntu-trusty elements: - ubuntu-minimal @@ -947,6 +949,7 @@ diskimages: DIB_IMAGE_CACHE: /opt/dib_cache DIB_APT_LOCAL_CACHE: '0' DIB_DISABLE_APT_CLEANUP: '1' + DIB_GRUB_TIMEOUT: '0' - name: ubuntu-xenial elements: - ubuntu-minimal @@ -967,6 +970,7 @@ diskimages: DIB_IMAGE_CACHE: /opt/dib_cache DIB_APT_LOCAL_CACHE: '0' DIB_DISABLE_APT_CLEANUP: '1' + DIB_GRUB_TIMEOUT: '0' - name: centos-7 elements: - centos-minimal @@ -985,6 +989,7 @@ diskimages: DIB_CHECKSUM: '1' DIB_IMAGE_CACHE: /opt/dib_cache QEMU_IMG_OPTIONS: compat=0.10 + DIB_GRUB_TIMEOUT: '0' - name: fedora-24 elements: - fedora-minimal @@ -1025,3 +1030,4 @@ diskimages: DIB_CHECKSUM: '1' DIB_IMAGE_CACHE: /opt/dib_cache QEMU_IMG_OPTIONS: compat=0.10 + DIB_GRUB_TIMEOUT: '0' diff --git a/tools/build-image.sh b/tools/build-image.sh index d63f53e5e1..5f15096ef3 100755 --- a/tools/build-image.sh +++ b/tools/build-image.sh @@ -55,6 +55,10 @@ fi ## This will get dib to drop you into a shell on error, useful for debugging # export break="after-error" +## If you need to debug the boot, setting this longer might help you +## break into the grub console. Or set it to 0 for fast boot. +# export DIB_GRUB_TIMEOUT=10 + # The list of elements here should match nodepool/nodepool.yaml disk-image-create -x --no-tmpfs -o $IMAGE_NAME \ $DISTRO \