Upgrade Debian 11 to Debian 12 from Command Line with Easy Steps

Posted on

Upgrade Debian 11 to Debian 12 from Command Line with Easy Steps

Upgrade Debian 11 to Debian 12 from Command Line with Easy Steps

In this guide, you will learn to Upgrade Debian 11 to Debian 12 from Command Line interface. Debian 12, known as "Bookworm," represents the latest stable release of the Debian distribution. On the Orcacore website, this tutorial will walk you through the process of upgrading your Debian system to this new release, familiarizing you with the changes and improvements it offers. Successfully Upgrade Debian 11 to Debian 12 from Command Line is simpler than you think.

To begin, ensure you have access to your Debian server as a non-root user with sudo privileges. If needed, you can refer to the Initial Server Setup with Debian 11 guide for assistance.

Important Note: Before proceeding with the upgrade, create a backup of all your important data and files. Utilities like rsync or rsnapshot are excellent for this purpose.

Step 1 – Check the Current Debian Version From the Command Line

Open your terminal and execute the following command to retrieve information about your current Debian 11 installation:

lsb_release -a

The output will resemble this:

**Output**
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

Next, verify your Debian kernel version using the following command:

uname -mrs

The output should look similar to this:

**Output**
Linux 5.10.0-8-amd64 x86_64

Alternatively, you can also check your Debian version using this command:

cat /etc/debian_version
**Output**
11.0

Step 2 – Update Debian 11 Bullseye Packages

Now, update and upgrade your Debian 11 system using the following commands:

sudo apt update
sudo apt upgrade

After the upgrade, remove any unnecessary packages using the following command:

sudo apt --purge autoremove

Step 3 – Update /etc/apt/sources.list File To Point To Debian 12 Repositories

Edit the /etc/apt/sources.list file to point to the Debian 12 repositories. Open the file with your preferred text editor (e.g., vi):

sudo vi /etc/apt/sources.list

Replace all instances of "bullseye" (Debian 11) with "bookworm" (Debian 12). The following example configuration includes the non-free and non-free-firmware repositories, which are useful if you need drivers or packages that aren’t entirely open source:

deb https://ftp.debian.org/debian/ bookworm contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm contrib main non-free non-free-firmware

deb https://ftp.debian.org/debian/ bookworm-updates contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm-updates contrib main non-free non-free-firmware

deb https://ftp.debian.org/debian/ bookworm-proposed-updates contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm-proposed-updates contrib main non-free non-free-firmware

deb https://ftp.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware
# deb-src https://ftp.debian.org/debian/ bookworm-backports contrib main non-free non-free-firmware

deb https://security.debian.org/debian-security/ bookworm-security contrib main non-free non-free-firmware
# deb-src https://security.debian.org/debian-security/ bookworm-security contrib main non-free non-free-firmware

Save and close the file.

Step 4 – Upgrade Debian 11 Version to Debian 12

Update the system’s package lists:

sudo apt update

Then, perform an initial upgrade of existing packages:

sudo apt upgrade --without-new-pkgs

When prompted about restarting services during package upgrades, select "Yes" to proceed automatically.

Finally, perform a full system upgrade to Debian 12:

sudo apt full-upgrade

During the upgrade, you might encounter configuration file prompts. Press Enter to navigate to the end of the file and press q to exit. When prompted to choose an action, select "keep the local version currently installed" and click "ok".

Reboot your server to apply the changes:

sudo systemctl reboot

Step 5 – Verify Debian 12 Version Installed

After logging back into your server, verify the Debian version using the following command:

lsb_release -a

The output should resemble the following image:

[Image of bookworm output]

Also, verify the Debian 12 Bookworm kernel version:

uname -mrs
**Output**
Linux 6.1.0-9-amd64 x86_64

Finally, remove any remaining unwanted packages:

sudo apt --purge autoremove

That’s it! The Upgrade Debian 11 to Debian 12 from Command Line is completed.

Conclusion

You have successfully learned how to Upgrade Debian 11 bullseye to Debian 12 Bookworm from the Command-line interface. Debian 12 boasts numerous improvements, features, and updated software packages compared to Debian 11. Enjoy exploring this new distribution.

You might be interested in these articles:

How To Upgrade Debian 10 to Debian 11

Upgrade Linux Kernel on Debian 11

FAQs

What’s new in Debian 12 Bookworm?

The Debian 12 LTS also called Bookworm was released on 10th June 2023 and it is supported and maintained for 5 years. Debian 12 has many more software packages and updates than Debian 11. Also, it has several desktop applications and environments. It also has many more man documentation pages.
Another amazing feature of Debian 12 Bookworm is that it introduced a new repository called “non-free-firmware” that separates non-free firmware from the remaining non-free packages.

What is Debian 12 GNOME version?

As we said, Debian 12 has several desktop applications. Available desks have been upgraded to the versions GNOME 43, plasma 5.27, LXDE 11, LXQt 1.2.0, MATE 1.26, Cinnamon 5.6 y Xfce 4.18. 

What is Debian 12 Kernel Version?

Debian 12 Bookworm comes with Linux kernel 6.1 and a new non-free firmware repository.

Alternative Approaches to Upgrading to Debian 12

While the command-line method outlined above is the standard and generally recommended approach, there are a couple of alternative strategies you could employ, although they are generally less preferred and might introduce complexities.

1. Using aptitude instead of apt

aptitude is another package management tool for Debian-based systems. It is similar to apt but offers some different features, including a more sophisticated dependency resolver. In some cases, especially with complex dependency issues, aptitude might handle the upgrade process more smoothly.

Explanation:

aptitude has a more advanced algorithm for resolving dependencies than apt. This can be helpful if the apt full-upgrade command encounters issues due to broken dependencies or conflicting packages. aptitude also provides a text-based user interface (TUI) which some users find easier to navigate.

How to use aptitude:

  1. Install aptitude: If it’s not already installed:

    sudo apt install aptitude
  2. Update the package lists:

    sudo aptitude update
  3. Perform the upgrade:

    sudo aptitude full-upgrade

    aptitude will analyze the dependencies and propose a solution. You’ll have the opportunity to review the proposed changes before committing to the upgrade. You might be presented with several possible solutions, and you can cycle through them using the . key. Press y to accept a solution and proceed with the upgrade.

  4. Clean up:

    sudo aptitude autoclean
    sudo aptitude autopurge

Caveats:

  • aptitude can sometimes be overly aggressive in its dependency resolution, potentially removing packages you might want to keep. Always carefully review the proposed changes before accepting them.
  • It’s generally recommended to stick with apt unless you’re encountering specific problems that aptitude might resolve. Mixing package managers can lead to inconsistencies and issues.

2. A Fresh Installation (The "Nuclear Option")

This involves backing up your data, downloading the Debian 12 ISO image, creating a bootable USB drive or DVD, and installing Debian 12 from scratch. This is the most drastic option and is generally only recommended if you’re experiencing significant problems with your existing system or if you want a completely clean slate. This is the safest way to Upgrade Debian 11 to Debian 12 from Command Line.

Explanation:

A fresh installation avoids any potential issues arising from remnants of the previous Debian 11 installation. It provides a clean, optimized system with the latest software versions and configurations.

Steps:

  1. Backup your data: This is crucial! Copy all important files and configurations to an external drive or cloud storage.

  2. Download the Debian 12 ISO: Obtain the appropriate ISO image for your architecture from the official Debian website.

  3. Create bootable media: Use a tool like dd (Linux) or Rufus (Windows) to create a bootable USB drive or DVD from the ISO image.

    • Using dd (Linux):

      sudo dd bs=4M if=/path/to/debian-12.iso of=/dev/sdX status=progress oflag=sync

      Replace /path/to/debian-12.iso with the actual path to your ISO file and /dev/sdX with the device identifier of your USB drive (be extremely careful to identify the correct drive!).

  4. Boot from the media: Configure your BIOS/UEFI to boot from the USB drive or DVD.

  5. Follow the installation instructions: The Debian installer will guide you through the process of partitioning your hard drive, selecting a desktop environment (if desired), and configuring your system.

  6. Restore your data: Once the installation is complete, restore your backed-up data.

Caveats:

  • This is the most time-consuming option.
  • You will need to reinstall all your applications and reconfigure your system settings.
  • It requires a solid understanding of partitioning and the Debian installation process.
  • Ensuring the correct drivers are installed, especially for proprietary hardware, might require extra effort.

In summary, while the in-place upgrade using apt is the preferred method, aptitude offers a slightly different approach to package management that may resolve some dependency conflicts, and a fresh installation provides the cleanest but most time-consuming solution for moving to Debian 12. Choose the method that best suits your needs and technical expertise.