How to Upgrade from Debian 11 to Debian 12

Updated on September 20, 2024
How to Upgrade from Debian 11 to Debian 12 header image

Introduction

Upgrading your Debian operating system ensures your server runs with the latest security patches, performance enhancements, and software updates. Debian 12 offers up-to-date system driver packages and kernel versions with better stability and performance.

This article explains how to upgrade from Debian 11 to Debian 12 and migrate all existing packages with minimal downtime.

Prerequisites

Before you begin:

  • Deploy a Debian 11 instance on Vultr to test the upgrade process.

  • Access the instance using SSH as a non-root user with sudo privileges.

  • Verify that your instance has at least 2GB of available space.

    console
    $ df -h
    

    Your output should be similar to the one below:

    Filesystem      Size  Used Avail Use% Mounted on
    udev            462M     0  462M   0% /dev
    tmpfs            96M  1.9M   94M   2% /run
    /dev/vda2        23G  5.1G   17G  23% /
    tmpfs           480M     0  480M   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    /dev/vda1       511M   12M  500M   3% /boot/efi
    tmpfs            96M     0   96M   0% /run/user/0

Create a Full Server Backup

Upgrading to Debian 12 can corrupt existing server packages that may be incompatible with the new operating system. A snapshot is a point-in-time copy of your instance state and file system used for versioning and backup purposes. Follow the steps below to take a new snapshot and recover your instance in case the upgrade process fails.

  1. Open the Vultr Customer Portal.

  2. Click Products and select Compute on the main navigation menu.

    Deploy a new instance

  3. Select your target Debian 11 instance to open its management page.

  4. Navigate to the Snapshots tab.

    Click Snapshots

  5. Enter a new snapshot label in the Label field and click Take Snapshot.

    Enter Snapshot Label

  6. Monitor the snapshot's progress and verify the status changes from Pending to Available.

    Monitor the Snapshot progress

    You have created a new snapshot you can use to recover your original instance state in case of any upgrade failures. Use backup tools such as rsync or tar on a physical server to back up your instance data before starting the upgrade process.

Test the Compatibility of Installed Applications

Some applications may be incompatible with Debian 12. Follow the steps below to verify the installed applications on your server and ensure compatibility with Debian 12.

  • View the official application documentation sources: Visit each application's official documentation or releases page to verify it's compatible with Debian 12.

  • Test in a sandbox environment: Replicate your existing environment on Debian 12 to identify any runtime or configuration issues.

  • Verify the installed packages: Run the following command to view all installed applications and software packages on your server and export the list to a single .txt file.

    console
    $ sudo dpkg --get-selections > installed-packages.txt
    
    • View the file contents to verify the installed packages.

      console
      $ cat installed-packages.txt
      

Pre-upgrade Preparation

Server preparation enables you to upgrade all existing packages for a smooth and successful upgrade. Follow the steps below to update your server packages and prepare for the system upgrade.

  1. Update the server's package information index.

    console
    $ sudo apt update -y
    
  2. Upgrade all installed packages to the latest versions.

    console
    $ sudo apt upgrade -y
    
  3. Perform a full upgrade to resolve potential dependency issues and install or remove specific packages.

    console
    $ sudo apt full-upgrade -y
    
  4. Remove any orphaned dependency packages to prevent potential conflicts during the upgrade process.

    console
    $ sudo apt autoremove -y
    
  5. Remove cached packages.

    console
    $ sudo apt clean
    

Upgrade from Debian 11 to Debian 12

Upgrading from Debian 11 to Debian 12 may take between 30 to 60 minutes depending on the number of packages on your server. Follow the steps below to upgrade from Debian 11 to Debian 12.

  1. View your server's distribution version and verify that it's Debian 11 (bullseye).

    console
    $ lsb_release -a
    

    Output:

    Distributor ID: Debian
    Description:    Debian GNU/Linux 11 (bullseye)
    Release:        11
    Codename:       bullseye
  2. Update the /etc/apt/sources.list file and any files within /etc/apt/sources.list.d/ directory from bullseye (Debian 11) to bookworm (Debian 12).

    console
    $ sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list && sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*
    
  3. Update the server's package information index.

    console
    $ sudo apt update
    
  4. Upgrade the server to Debian 12.

    console
    $ sudo apt upgrade
    

    Press Space to browse the apt-listchanges: News options and press Y to close the pager. When prompted, reply to each of the following prompts:

    • Character set to support: Press Enter to use the default keyboard layout.

      Console setup prompt

    • Restart services during package upgrades without asking?: Select Yes and press Enter to continue with the upgrade process.

      Restart service during package upgrades

    • What do you want to do about modified configuration file ssh_config?: Select install the package maintainer's version and press Tab to select OK and press Enter.

      What do you want to do about modified configuration file ssh_config

    • What do you want to do about modified configuration file grub?: Select install the package maintainer's version, select OK, and press Enter.

      What do you want to do about modified configuration file grub

    • Configuration file '/etc/ntpsec/ntp.conf: Enter Y and press Enter to install the NTP package maintainer's version.

      Configuration file '/etc/ntpsec/ntp.conf'
      ==> File on system created by you or by a script.
      ==> File also in package provided by package maintainer.
        What would you like to do about it ?  Your options are:
         Y or I : install the package maintainer's version
         N or O : keep your currently-installed version
         D : show the differences between the versions
         Z : start a shell to examine the situation
      The default action is to keep your current version.
      *** ntp.conf (Y/I/N/O/D/Z) [default=N] ? Y
  5. Perform a full upgrade of all packages on the server.

    console
    $ sudo apt full-upgrade -y
    

    The above command upgrades all installed packages to their latest versions, installs new packages, and removes any conflicting or obsolete packages.

  6. Remove any unnecessary packages and clear the package cache.

    console
    $ sudo apt autoremove -y && sudo apt clean -y
    
  7. View your server's distribution version and verify you have upgraded to Debian 12 (bookworm).

    console
    $ lsb_release -a
    

    Output:

    Distributor ID: Debian
    Description:    Debian GNU/Linux 12 (bookworm)
    Release:        12
    Codename:       bookworm
  8. Restart the server to apply all changes.

    console
    $ sudo reboot
    

Test the Upgraded Debian 12 Server

Follow the steps below to test the upgraded Debian server and verify that all packages run correctly with the latest versions.

  1. View your server distribution version and verify that it's Debian 12 (bookworm).

    console
    $ lsb_release -a
    

    Output:

    Distributor ID: Debian
    Description:    Debian GNU/Linux 12 (bookworm)
    Release:        12
    Codename:       bookworm

    Debian 12 (bookworm) is the active operating system version on your server based on the above output.

  2. View the updated Linux kernel version.

    console
    $ uname -r
    

    Output:

    5.10.0-31-amd64
  3. Test access to a common domain such as google.com to verify network connectivity.

    console
    $ ping -c 4 google.com
    

    Output:

    PING google.com(2c0f:fb50:4002:81d::200e (2c0f:fb50:4002:81d::200e)) 56 data bytes
    64 bytes from 2c0f:fb50:4002:81d::200e (2c0f:fb50:4002:81d::200e): icmp_seq=1 ttl=59 time=0.745 ms
    64 bytes from 2c0f:fb50:4002:81d::200e (2c0f:fb50:4002:81d::200e): icmp_seq=2 ttl=59 time=0.758 ms
    64 bytes from 2c0f:fb50:4002:81d::200e (2c0f:fb50:4002:81d::200e): icmp_seq=3 ttl=59 time=0.798 ms
    64 bytes from 2c0f:fb50:4002:81d::200e (2c0f:fb50:4002:81d::200e): icmp_seq=4 ttl=59 time=0.775 ms
    
    --- google.com ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3004ms
    rtt min/avg/max/mdev = 0.745/0.769/0.798/0.019 ms

Conclusion

You have upgraded your server from Debian 11 to Debian 12. Upgrading your operating system version ensures that your server receives the latest security patches and updates to improve the system's performance. For more information, visit the Debian upgrade documentation.