Unattended grub configuration after kernel upgrade
Today I have been working on automatic deployment of an ubuntu server. I got stuck on automatic updating of the server using apt-get upgrade
trying to upgrade to a new kernel. The log looks like this:
Setting up linux-image-3.2.0-24-generic (3.2.0-24.39) ...
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
(...)
Then a question is presented:
Package configuration
┌─────────────────────────────────┤ ├─────────────────────────────────┐
│ A new version of /boot/grub/menu.lst is available, but the version │
│ installed currently has been locally modified. │
│ │
│ What would you like to do about menu.lst? │
│ │
│ install the package maintainer's version │
│ keep the local version currently installed │
│ show the differences between the versions │
│ show a side-by-side difference between the versions │
│ show a 3-way difference between available versions │
│ do a 3-way merge between available versions (experimental) │
│ start a new shell to examine the situation │
│ │
│ │
│ <Ok> │
│ │
└──────────────────────────────────────────────────────────────────────┘
The desired outcome would be to select the first option and to continue:
Replacing config file /run/grub/menu.lst with new version
Updating /boot/grub/menu.lst ... done
After running the upgrade by hand, I used debconf-get-selections
to inspect the correct answer for the question (see other settings). It seems like update_grub_changeprompt_threeway
is the question that should be answered. However, setting this using debconf-set-selections
presented me with the same question:
debconf-set-selections <<< "grub grub/update_grub_changeprompt_threeway select install_new"
apt-get -y dist-upgrade
How can this question be automated?
I was able to get around this by using export DEBIAN_FRONTEND=noninteractive
, before running apt-get upgrade -y
.
On Ubuntu 16.04, this sequence should avoid the interactive dialog:
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get upgrade -yq
Note that the -q
flag is important.
(Reference: This question on devops)