Debian 12, codenamed Bookworm, is released a few days ago! This Step-by-Step guide explains how to upgrade to Debian 12 bookworm from Debian 11 bullseye from command line. From updating repositories to backing up your data, we’ll cover all the necessary steps to ensure a successful Debian 12 upgrade.
Step-by-Step Guide to Upgrade to Debian 12 from Debian 11
Contents
- 1 Step-by-Step Guide to Upgrade to Debian 12 from Debian 11
- 1.1 Step 1: Verify Your Current Debian Version
- 1.2 Step 2: Update and Upgrade Your Debian 11 Packages
- 1.3 Step 3: Backup your Data
- 1.4 Step 4: Modify the /etc/apt/sources.list File
- 1.5 Step 5: Perform Minimal System Upgrade
- 1.6 Step 6: Upgrade to Debian 12
- 1.7 Step 7: Verify if Everything Works Fine
- 1.8 Step 8: Restore the Backup (Optional)
- 2 TL;DR
The release of Debian 12 (bookworm) brings forth a wealth of new features, enhanced performance, and increased stability. Upgrading your Debian 11 system to Debian 12 will unlock the full potential of this latest operating system. In this detailed guide, we provide you with an easy-to-follow step-by-step process for seamlessly upgrading to Debian 12.
Step 1: Verify Your Current Debian Version
First, you need to confirm that you are currently running Debian 11. To check the Debian distribution name and version number, run the following command in your terminal:
$ lsb_release -d
This should return “Description: Debian GNU/Linux 11 (bullseye)
“ if you’re running Debian 11. You can also display the version number using the cat command:
$ cat /etc/debian_version
This should return 11.x where x is the current point release of Debian 11.
Step 2: Update and Upgrade Your Debian 11 Packages
Prior to upgrading Debian bullseye to bookworm, it is essential to ensure that all existing packages are updated and upgraded to their latest available versions. Follow these steps carefully:
Open a terminal window. Run the following commands one by one, entering your administrator password when prompted:
$ sudo apt update
$ sudo apt upgrade
$ sudo apt dist-upgrade
Once the upgrades are complete, clean any residual packages and configuration files using the following commands:
$ sudo apt --purge autoremove
$ sudo apt autoclean
$ sudo find /etc -name '.dpkg-' -o -name '.ucf-' -o -name '*.merge-error'
With the introduction of numerous new packages, the Debian bookworm release discontinues and excludes several old packages that were present in bullseye. These obsolete packages do not have a designated upgrade path. While it is technically possible to continue using these obsolete packages, it’s important to note that the Debian project generally ceases security support for them approximately one year after the release of bookworm. Furthermore, the Debian project typically does not provide other forms of support during this period. Therefore, it is recommended to replace these obsolete packages with available alternatives, if any exist.
To identify and remove “Obsolete and Locally Created Packages” from the command line, you can use the following commands:
To list all obsolete packages, enter:
$ apt list '~o'
To remove these obsolete packages, use the purge command with the ‘~o’ filter:
$ sudo apt purge '~o'
These commands will help ensure that your system remains clean and free from unnecessary packages after the upgrade process.
To apply all the updates, it is recommended to reboot your system. Execute the following command:
$ sudo reboot
After the system restarts, you can proceed with the Debian bullseye to bookworm upgrade process.
Step 3: Backup your Data
The subsequent crucial step is to create a backup of your data. It is essential to ensure that you have a copy of all important personal files, directories, and configuration files before proceeding with the upgrade process.
Your backup serves as a safety net to ensure the preservation of your important data in case of any unforeseen issues during the upgrade process.
To perform a comprehensive backup, focus on backing up the following:
- The contents of the
/etc
directory: This directory contains various system configuration files. Make sure to create a backup of its entire contents. - The
/var/lib/dpkg
directory: This directory holds the package database. It is important to have a backup of this directory to preserve package information. - The
/var/lib/apt/extended_states
file: This file contains additional information about installed packages. Include this file in your backup to retain relevant package states. - The output of the
dpkg --get-selections "*"
command: Execute this command, including the quotes, to generate a list of all installed packages. Backing up this output will help you restore your package selections.
By backing up these essential components, you can safeguard your data and configuration settings. This ensures that you have the necessary resources to restore your system or recover specific files if needed.
You also have a variety of options when it comes to selecting backup applications for your Debian Linux system. Consider using one or two of the following applications to backup your data and system settings:
- Rsync: This powerful command-line utility is ideal for backing up personal data and the contents of your $HOME directory.
- Deja Dup: If you prefer a simple graphical interface, Deja Dup is a user-friendly utility that allows you to back up your personal data with ease.
- Timeshift: For backing up system files and settings, Timeshift provides a graphical application that enables you to create snapshots of your system.
- Restic: This command-line utility offers the ability to save multiple revisions of files and directories in an encrypted repository stored on different backends.
- Rsnapshot: If you require periodic snapshots of both local and remote machines over SSH, Rsnapshot is a command-line utility that can fulfill this requirement.
Personally, I use Deja Dup and Timeshift for my backups. However, feel free to choose any combination of the above-listed applications that best suits your preferences and backup needs.
Step 4: Modify the /etc/apt/sources.list File
Prior to updating the software repositories in Debian buster, it is important to back up the current software source list. Follow these steps to create a backup:
Create a new directory named “apt
“ in your home directory by running the following command:
$ mkdir ~/apt
Make a copy of the main software source list by executing the following command with administrator privileges:
$ sudo cp /etc/apt/sources.list ~/apt
Create a copy of the additional software sources located in the “sources.list.d
“ directory using the recursive and verbose options:
$ sudo cp -rv /etc/apt/sources.list.d/ ~/apt
To ensure that the software repository lists have been successfully copied, verify the contents of the “~/apt
” directory by running the following command:
$ ls apt/ sources.list sources.list.d
After executing these steps, you should see the “sources.list
” file and the “sources.list.d
” directory listed in the output, confirming that the backup process was completed successfully.
Next, you’ll need to update your package sources to point to the Debian 12 repositories. To update the Debian 11 (bullseye) repositories to Debian 12 (bookworm) repositories, execute the following commands:
From the terminal, run the following command with administrator privileges to update the main software source list:
$ sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list
This command uses the sed
utility to replace all occurrences of “bullseye” with “bookworm” in the /etc/apt/sources.list
file.
Update the additional software source lists in the “sources.list.d” directory by executing the following command:
$ sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*
Similarly, this command replaces “bullseye” with “bookworm” in all files within the /etc/apt/sources.list.d/
directory.
Additionally, you should add the “non-free-firmware” repository for hardware driver support.
$ sudo sed -i 's/non-free/non-free non-free-firmware/g' /etc/apt/sources.list
$ sudo sed -i 's/non-free/non-free non-free-firmware/g' /etc/apt/sources.list.d/*
By following these steps, you will have replaced and updated the Debian 11 (bullseye) repositories with the Debian 12 (bookworm) repositories in your system’s software source lists.
Verify if the sources list file has been updated with the new repository links by running the following command:
$ cat /etc/apt/sources.list
This command displays the contents of the /etc/apt/sources.list
file, allowing you to confirm if the repository links have been successfully updated.
Here is the contents of my test machine’s source repository list:
deb http://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware deb http://deb.debian.org/debian/ bookworm-updates non-free non-free-firmware contrib main deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
As observed in the above output, the sources.list
file has been successfully updated with the new Debian 12 repository links.
Next, update the repository lists by executing the following command in the terminal:
$ sudo apt update
This command will refresh the repository lists based on the updated configuration in the sources.list
file. It allows your system to retrieve the latest package information from the newly added Debian 12 repositories.
Step 5: Perform Minimal System Upgrade
In certain scenarios, performing a full system upgrade as explained in the next step may result in the removal of a significant number of packages that you wish to retain. Therefore, Debian developers recommend a two-part upgrade process consisting of a minimal upgrade followed by a full upgrade.
The minimal upgrade ensures the upgrade of all existing packages without installing or removing any additional packages. To initiate the minimal upgrade, use the following command:
$ sudo apt upgrade --without-new-pkgs
While the upgrade process is underway, carefully monitor the screen. You may encounter a series of questions that require your input, such as deciding the fate of a configuration file or whether to restart a particular service. The specific questions presented to you can vary based on the number of installed packages on your current Debian system.
It is crucial to pay attention and respond to these prompts appropriately to ensure a smooth upgrade experience. This allows you to retain desired packages and maintain the desired configuration during the minimal upgrade phase.
If you have the apt-listchanges package installed, it will display crucial information about upgraded packages in a pager after downloading them. To access the information, press ENTER to read through the details. If you wish to exit and return to the upgrade process, simply press the q key.
The minimal upgrade process will be typically completed within a few minutes.
Step 6: Upgrade to Debian 12
Now that your package sources have been updated, you can upgrade your system.
Execute the following command to perform a full system upgrade to Debian 12:
$ sudo apt full-upgrade
Once again, it is important to pay attention to the screen during the upgrade process and respond to any prompts or questions that may arise.
If you have the apt-listchanges package installed, it will display essential information about the upgraded packages in a pager after the packages are downloaded. After reading the information, you can exit the pager by pressing the q key. This allows the upgrade process to continue without any interruptions.
During the upgrade process, various services installed on your Debian system may require restarting when specific libraries like libpam, libc, and libssl are upgraded. Restarting these services may result in temporary interruptions of service.
To minimize these interruptions and avoid being prompted for each library upgrade, you have the option to choose a default action. If you prefer not to be asked about restarting services individually, you can select “Yes” and press ENTER to proceed. This choice ensures that the upgrade process continues without interruption and automatically restarts the necessary services as needed.
After completing the upgrade process to Debian 12 (bookworm), it is recommended to reboot your system to ensure that all changes take effect. Execute the following command to reboot your system:
$ sudo reboot
Once your system restarts and you log in, you can verify the Debian 12 bookworm version using either of the following commands:
To check the version by reading the contents of the /etc/debian_version
file, run:
$ cat /etc/debian_version 12.0
This command will display the version information, which should indicate “12.0” if the upgrade to Debian 12 (bookworm) was successful.
Alternatively, you can use the lsb_release
command to obtain detailed information about the Debian release. Execute the following command:
$ lsb_release -a
This command will provide comprehensive information, including the distribution ID, release number, codename, and more. Review the output to confirm that the Debian version is correctly identified as “bookworm.”
Sample Output:
No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 12 (bookworm) Release: 12 Codename: bookworm
Congratulations on successfully upgrading Debian 11 (bullseye) to Debian 12 (bookworm)!
To ensure a clean system and remove any packages that are no longer required, you can execute the following commands:
Remove all packages that are no longer needed, including their configuration files:
$ sudo apt --purge autoremove
This command will remove any unused packages from your system, freeing up disk space and eliminating unnecessary dependencies.
Clean up residual package files that are no longer required:
$ sudo apt autoclean
This command will remove cached package files from the system’s package cache directory, helping to free up additional disk space.
Step 7: Verify if Everything Works Fine
After logging in to your newly upgraded Debian 12 system, it is important to check if everything is functioning correctly. Take the time to open and/or run various installed applications and verify that they are working as expected.
Ensure that all essential functionalities and features are operational. If you encounter any issues or if something breaks your system, please share your issues in the comment section below or seek assistance from the Debian forum.
Keep in mind that Debian 12 has just been released (June 10, 2023), so minor glitches might occur. However, in my personal experience, the upgrade process was smooth, and all aspects of the system worked seamlessly.
Step 8: Restore the Backup (Optional)
If the upgrade process to Debian 12 (bookworm) is smooth and error-free, it should not delete any important files. However, as a precautionary measure, if you find any missing data or files, it is recommended to restore them from the backup you created before the upgrade.
Follow the appropriate procedure to restore your backup files, directories, and configuration settings. This step ensures that your system is set up exactly as it was before the upgrade, including any personalized configurations or data.
Additionally, you can take this opportunity to install new applications of your choice and start exploring the features and enhancements offered by the Debian 12 bookworm edition. Enjoy using Debian 12 and make the most out of its capabilities!
TL;DR
Here are the key steps to upgrade to Debian 12 (bookworm):
- Update and upgrade all currently installed packages using
sudo apt update
,sudo apt upgrade
,sudo apt dist-upgrade
,sudo apt autoremove
,sudo apt autoclean
, andsudo find /etc -name '.dpkg-' -o -name '.ucf-' -o -name '*.merge-error'
. - Backup all important personal files, directories, and configuration files, such as /etc, /var/lib/dpkg, /var/lib/apt/extended_states, and the output of
dpkg --get-selections "*"
command. - Copy the current software source list and sources.list.d directory using
sudo cp /etc/apt/sources.list ~/apt
andsudo cp -rv /etc/apt/sources.list.d/ ~/apt
. - Update the sources.list file and sources.list.d files to replace “bullseye” with “bookworm” using
sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list
andsudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list.d/*
. - Add the “non-free-firmware” repository if needed with
sudo sed -i 's/non-free/non-free non-free-firmware/g' /etc/apt/sources.list
andsudo sed -i 's/non-free/non-free non-free-firmware/g' /etc/apt/sources.list.d/*
. - Perform a minimal upgrade using
sudo apt upgrade --without-new-pkgs
and respond to any prompts or questions that may arise during the upgrade process. - Start the main upgrade using
sudo apt full-upgrade
to upgrade all packages and dependencies. - Reboot your system after the upgrade process is completed with
sudo reboot
. - Verify the Debian 12 bookworm version using
cat /etc/debian_version
orlsb_release -a
. - Optionally, remove packages that are no longer required using
sudo apt --purge autoremove
andsudo apt autoclean
. - Log in to your upgraded system, check if everything works fine, and report any issues.
- Restore the backup you took before upgrading the system.
- Install new applications of your choice and enjoy using Debian 12 bookworm edition!
Resource: