When managing Debian systems remotely, particularly those significantly behind current versions, the standard apt-get dist-upgrade
process becomes problematic due to interactive prompts. The main pain points occur during:
- libc6 upgrades (keymap configuration)
- Kernel image selections
- Configuration file updates
The foundation for automation lies in these two approaches:
# Basic non-interactive mode
DEBIAN_FRONTEND=noninteractive apt-get -y dist-upgrade
However, this isn't sufficient for complex scenarios. We need preseeding:
# Create a preseed file
echo "libc6 libraries/restart-without-asking boolean true" > /tmp/preseed.cfg
echo "console-setup console-setup/charmap47 select UTF-8" >> /tmp/preseed.cfg
Here's a complete solution combining multiple techniques:
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
# Preseed common configurations
debconf-set-selections <
For particularly stubborn systems, consider these additional measures:
# Force keep existing configs
apt-get -o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
-y install --reinstall package-name
# Skip problematic configurations
echo 'libc6 libraries/restart-without-asking boolean true' | debconf-set-selections
Always implement logging for unattended upgrades:
{
DEBIAN_FRONTEND=noninteractive \
apt-get -y -o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
dist-upgrade
} | tee /var/log/unattended-upgrade-$(date +%Y%m%d).log
When managing remote Debian servers, especially those severely outdated, a fully automated dist-upgrade
becomes crucial. The main obstacles are interactive prompts from packages like libc6
(keymap configuration) and kernel image selections.
While DEBIAN_FRONTEND=noninteractive
handles basic yes/no prompts, it fails for complex dialogs. We need deeper automation:
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
apt-get -o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
dist-upgrade -y
For packages like libc6
that require keymap selection, use debconf-set-selections
:
echo "libc6 libraries/restart-without-asking boolean true" | debconf-set-selections
echo "console-setup console-setup/codeset string Lat15" | debconf-set-selections
echo "keyboard-configuration keyboard-configuration/variant select English (US)" | debconf-set-selections
To automatically keep the currently running kernel version:
apt-get install -y --install-recommends linux-image-$(uname -r)
Or to always select the newest kernel without prompt:
echo "grub-pc grub-pc/install_devices multiselect /dev/sda" | debconf-set-selections
echo "grub-pc grub-pc/install_devices_disks_changed multiselect /dev/sda" | debconf-set-selections
Here's a full solution combining all elements:
#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
export DEBIAN_PRIORITY=critical
# Preseed configurations
debconf-set-selections <
After upgrade, check for held packages:
apt-mark showhold
And review any configuration changes:
grep -r "modified by conffile" /etc