Hi, I’m Eric. I’m technical director @enginsightcom with deep interest in it security.
Eric Range

Upgrade to Debian 12 (Bookworm)

Eric Range
Eric Range
Aug 29, 2024
Hi, I’m Eric. I’m technical director @enginsightcom with deep interest in it security.
# Update package list and upgrade installed packages
sudo apt update && sudo apt upgrade -y

# Replace "bullseye" with "bookworm" in sources.list
sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list

# Update package list again and upgrade to match Bookworm
sudo apt update && sudo apt upgrade -y

# Reboot to apply changes
sudo reboot
# Update non-free component to include non-free-firmware
sudo sed -i 's/non-free/non-free non-free-firmware/g' /etc/apt/sources.list

# Perform full upgrade
sudo apt full-upgrade -y

# Reboot again to apply full upgrade
sudo reboot
# Clean up unnecessary packages
sudo apt --purge autoremove -y

Upgrading your Debian system to the latest stable release is an essential task to keep your system secure, up-to-date, and running smoothly. With the release of Debian Bookworm, you might be looking for a straightforward way to upgrade from Bullseye. This guide provides a concise script that handles the entire upgrade process efficiently, ensuring your system is fully updated with minimal effort.

Why Upgrade to Debian Bookworm?

Debian Bookworm comes with numerous updates, security patches, and new features that improve the overall performance and functionality of the system. Staying on an outdated release like Bullseye can leave your system vulnerable to security risks and prevent you from accessing the latest software.

The Upgrade Script: A Step-by-Step Guide

Here’s a streamlined script that will walk you through upgrading from Debian Bullseye to Bookworm. This script is designed to be as concise as possible while ensuring a complete and safe upgrade.

1. Update Your Package List and Upgrade Installed Packages

Before diving into the release upgrade, it’s crucial to ensure that all your current packages are up-to-date.

sudo apt update && sudo apt upgrade -y

This command updates your package list and upgrades all installed packages to their latest versions. It’s a good practice to start any system maintenance with this step to avoid conflicts during the upgrade process.

2. Modify the APT Sources List for the New Release

Next, you need to modify the APT sources list to point to the new Debian Bookworm repositories.

sudo sed -i 's/bullseye/bookworm/g' /etc/apt/sources.list

This command replaces all instances of “bullseye” with “bookworm” in your sources list, effectively switching your system’s package sources to the new release.

3. Update and Upgrade to Bookworm

With your sources list now pointing to Bookworm, you need to update the package list again and upgrade all packages to their Bookworm versions.

sudo apt update && sudo apt upgrade -y

This ensures that all your packages are now sourced from the Bookworm repositories and upgraded accordingly.

4. Reboot to Apply Changes

A reboot at this stage helps apply any changes, particularly those affecting the kernel or other critical system components.

sudo reboot

Rebooting ensures that the new Bookworm packages are correctly loaded and any kernel updates are applied.

5. Handle the Non-Free Component Change

Starting with Debian Bookworm, the non-free component has been split into non-free and non-free-firmware. You need to update your sources list to reflect this change.

sudo sed -i 's/non-free/non-free non-free-firmware/g' /etc/apt/sources.list

This command updates the non-free component in your sources list to include the new non-free-firmware section, ensuring you continue to receive updates for firmware packages.

6. Perform a Full Upgrade

To fully align your system with Debian Bookworm, perform a full upgrade. This step may involve installing new packages or removing obsolete ones to match the new release’s package dependencies.

sudo apt full-upgrade -y

A full upgrade ensures your system is entirely in sync with Bookworm, resolving any package dependencies and removing obsolete software.

7. Reboot Again

Another reboot ensures that all changes from the full upgrade are fully applied, especially if critical system components were affected.

sudo reboot

Rebooting here finalizes the upgrade process.

8. Clean Up Unnecessary Packages

Finally, clean up any unnecessary packages that are no longer required by your system.

sudo apt --purge autoremove -y

This command removes packages that were automatically installed as dependencies but are no longer needed, freeing up disk space and keeping your system tidy.

Conclusion

Upgrading from Debian Bullseye to Bookworm is a straightforward process with the help of this concise script. By following these steps, you can ensure your system is up-to-date with the latest Debian release, taking advantage of improved security, new features, and enhanced performance. Regular upgrades are essential to maintain a secure and efficient operating system, and this guide makes the process as simple as possible.

With this script, you can upgrade your system in a matter of minutes, keeping it running smoothly and securely on the latest stable release of Debian.