内核升级后无人值守的 grub 配置

内核升级后无人值守的 grub 配置

今天我一直在研究 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 上

相关内容