Debian Upgrade – How Did I End Up on Bullseye?

debianheadlessupgrade

Maybe a silly question, but a remote server was down for an extended period today. When it came back up, I realized the downtime was apparently due to a system upgrade, from Debian Buster (stable) to Bullseye (testing).

I'm a bit confused, because I am the only superuser on this server, and I have not scheduled any kind of update in some time. I don't run production machines on testing, and I didn't intentionally set the system up to automatically upgrade operating system versions. I do periodically use apt to update and upgrade individual packages, but I certainly did not call for a full release upgrade.

Any obvious configuration settings I might have made to trigger this – for example, changing my apt sources unintentionally etc.? I don't want any more unexpected updates. (It's a headless Minecraft server, for what it's worth, and downtime is bad when people want to play.)

Best Answer

There are a two things which could cause this. You can find out which by using:

cat /etc/apt/sources.list /etc/apt/sources.list.d/*
  1. Using a suite instead of a codename:
(1) deb http://ftp.debian.org/debian/ buster main
(2) deb http://ftp.debian.org/debian/ stable main

Line (1) and (2) are equivalent today, but they won't always be. One day, stable will point to bullseye. When that happens, your machine will automatically change too. If you want control, then use codename buster. Check for the testing suite. That switched from buster to bullseye on 6 July 2019.

  1. Multiple distributions:
(1) deb http://ftp.debian.org/debian/ buster main
(2) deb http://ftp.debian.org/debian/ bullseye main
(3) deb http://ftp.debian.org/debian/ testing main

If you have something like what's above, then Debian may see several versions of each package. The latest version of a package will be selected unless you've set APT::Default-Release in /etc/apt/apt.conf or explicitly pinned priorities in /etc/apt/preferences.d/.


The next question is why did your sources.list have a strange entry? It could be that you've added a line because you wanted the latest version of a package which was only available in bullseye. In that case you may have added the line, apt update then apt install -t testing some-package. But the problem is that unless you delete that line and do another apt update, or add a APT::Default-Release, you are primed for an upgrade to testing,

Another option is 3rd party software. It's common for software which doesn't exist in Debian's official archive to give you a *.deb installer. I've seen *.deb archives include a custom /etc/apt/sources.list.d/*.list so that you get updates. It wouldn't be hard for them to say "well I need version X of this dependency, and I know it exists in bullseye, so I'll create a line to add a bullseye repo". It would by sloppy of them, but not impossible.


So how to recover? There are three options at this point:

1: Complete the upgrade - Easiest/quickest

2: Downgrade - Hardest/Least likely to succeed

3: Re-install - Most reliable/Most downtime

To Complete the upgrade, first obviously fix the strange line in your /etc/apt/sources.list[.d/]. Then:

# Make everything 'bullseye'
sudo sed -i                  \
  -e 's/buster/bullseye/g'   \
  -e 's/unstable/bullseye/g' \
  -e 's/stable/bullseye/g'   \
  -e 's/testing/bullseye/g'  \
  -e 's/sid/bullseye/g'      \
  /etc/apt/sources.list      \
  /etc/apt/sources.list.d/*

# Upgrade
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt --fix-broken install
sudo apt autoremove

Toggle between upgrade, dist-upgrade, --fix-broken install and autoremove until apt finishes successfully everywhere.

To downgrade (and this is likely to fail, I can't stress that enough):

First back everything up. Then, create /etc/apt/preferences.d/buster:

Package: *
Pin: release n=buster
Pin-Priority: 1001

Then upgrade like we did in step 1

sudo sed -i                \
  -e 's/bullseye/buster/g' \
  -e 's/unstable/buster/g' \
  -e 's/stable/buster/g'   \
  -e 's/testing/buster/g'  \
  -e 's/sid/buster/g'      \
  /etc/apt/sources.list    \
  /etc/apt/sources.list.d/*

# Upgrade
sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt --fix-broken install
sudo apt autoremove

Toggle between upgrade, dist-upgrade, --fix-broken install and autoremove until apt finishes successfully everywhere.

When you are happy, delete /etc/apt/preferences.d/buster

Related Question