![内核升级后无人值守的 grub 配置](https://linux22.com/image/1096856/%E5%86%85%E6%A0%B8%E5%8D%87%E7%BA%A7%E5%90%8E%E6%97%A0%E4%BA%BA%E5%80%BC%E5%AE%88%E7%9A%84%20grub%20%E9%85%8D%E7%BD%AE.png)
今天我一直在研究 ubuntu 服务器的自动部署。我在apt-get upgrade
尝试升级到新内核时卡在了服务器的自动更新上。日志如下:
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
(...)
然后提出一个问题:
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> │
│ │
└──────────────────────────────────────────────────────────────────────┘
期望的结果是选择第一个选项并继续:
Replacing config file /run/grub/menu.lst with new version
Updating /boot/grub/menu.lst ... done
手动运行升级后,我曾经debconf-get-selections
检查过该问题的正确答案(查看其他设置)。这似乎update_grub_changeprompt_threeway
是应该回答的问题。但是,使用设置它却debconf-set-selections
给我带来了同样的问题:
debconf-set-selections <<< "grub grub/update_grub_changeprompt_threeway select install_new"
apt-get -y dist-upgrade
这个问题如何自动化?
答案1
export DEBIAN_FRONTEND=noninteractive
在运行之前,我可以通过使用 来解决这个问题apt-get upgrade -y
。
答案2
在 Ubuntu 16.04 上,此序列应避免交互式对话框:
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get upgrade -yq
请注意,-q
标志很重要。
(参考:这个问题在 DevOps 上