How do I upgrade my server from Debian 11 to Debian 12?
You can follow the steps below to upgrade your server from Debian 11 to Debian 12:
- Make a snapshot or backup of your server to make sure no data is lost. You can find a guide on how to create a snapshot here and a guide on how to create a backup here.
- First you need to remove any non-Debian packages from your server, you can run the following command to find all of the non-Debian packages:
sudo apt list '?narrow(?installed, ?not(?origin(Debian)))'
sudo apt-forktracer | sort
- Next you need remove all packages with the hold status, you can run the following command to find all the packages with the hold status:
sudo apt-mark showhold | more
Then you can run the following command to delete all the packages with the hold status:
sudo apt-mark unhold [package_name]
Next you need to make sure all packages and repositories are up to date by running the following command:
sudo apt update && sudo apt upgrade
Next you will need to update the APT’s source list files. First change the directory to etc/apt with the following command:
cd /etc/apt
- Open the sources.list file using your preferred text editor. In the example we will use nano:
sudo nano sources.list
Using the text editor replace any sources that contain the word “bullseye” with “bookworm” for example “deb http://deb.debian.org/debian bullseye” main to “deb http://deb.debian.org/debian bookworm main”.
- Run the following command to update the system repositories:
sudo apt update
- When prompted to restart service packages, select Yes using the arrow keys and press Enter.
- Run the following command to restart the system to complete the upgrade process:
systemctl reboot
- After the reboot you can check the version by running this command:
cat /etc/debian_version