1. Home
  2. Linux
  3. How to run unstable packages on debian stable

How to run unstable packages on Debian Stable

Debian Stable is a rock-solid base. It’s reliable and slow to update, so nothing will break. However, you may find yourself needing a few newer packages than Debian Stable can provide. In this guide, we’ll show you how you can install certain Debian Unstable packages while keeping Debian 12’s packages intact.

How to enable the Debian Unstable repository

To install unstable packages (packages that are frequently updated on Debian), you need to enable the Debian Sid repository. To enable this software repository, open up the /etc/apt/sources.list file in the Nano text editor as root.

su

nano -w /etc/apt/sources.list

Once the file is open, you must add the following code to the bottom of the file. This file will tell Debian to add “Unstable” packages to your software sources.

deb http://deb.debian.org/debian unstable main contrib non-free
deb-src http://deb.debian.org/debian unstable main contrib non-free

After adding the software sources, DO NOT UPDATE. Updating right now will upgrade every single Debian Stable package to Debian Unstable. Instead, follow the next section of the guide to pin packages.

How to pin packages to the Debian Unstable repository

Pinning packages in Debian will allow you to specify that you only want certain packages provided by the Debian Unstable repository, rather than every package. To start, create a new file in /etc/apt/ called preferences.

su

touch /etc/apt/preferences

After creating the new file, open it up in the Nano text editor.

nano /etc/apt/preferences

Paste the following code into the Nano text editor. Unless specified otherwise, this code will ensure that your packages stay pinned to Debian Stable.

Package: *
Pin: release a=bookworm
Pin-Priority: 500

Package: *
Pin: release a=unstable
Pin-Priority: 100

Once the pin is added to the /etc/apt/preferences file, save it in the Nano text editor using the Ctrl + O keybinding on the keyboard. Then, close the Nano text editor by pressing Ctrl + X on the keyboard.

When you’ve exited the Nano text editor and saved everything, it is safe to update. Using the sudo apt update command, update your software sources on Debian.

sudo apt update

Installing specific unstable packages

Package pinning is how we can tell Debian Stable we want specific packages to be installed via Unstable, rather than Stable. For example, if you wish to keep your Debian Stable packages on the stable repository, but aren’t happy with what version of the Linux kernel you are using, you can pin the Linux kernel package to the Unstable.

To pin the Linux kernel to the Debian Unstable repo, open up /etc/apt/preferences in Nano with the following command.

sudo nano -w /etc/apt/preferences

Once the file is open, ensure it looks like the code below.

Package: *  
Pin: release a=bookworm
Pin-Priority: 500  
  
Package: linux-image-amd64  
Pin:release a=unstable  
Pin-Priority: 1000  

Package: linux-headers 
Pin:release a=unstable  
Pin-Priority: 1000  

Package: *  
Pin: release a=unstable  
Pin-Priority: 100

Save your edits by pressing Ctrl + O, and exit by pressing Ctrl + X. When you’ve closed Nano, run the sudo apt update and sudo apt upgrade commands.

sudo apt update

sudo apt upgrade

When you’ve finished updating, Debian will download the Linux kernel from the Debian Unstable repositories, upgrading the Debian kernel version to the absolute latest available version.

Keep in mind, you can specify any package you wish in the /etc/apt/preferences file, not just the Linux kernel. Just follow the following example:

Package: *  
Pin: release a=bookworm
Pin-Priority: 500  
  
Package: MY_PACKAGE_NAME
Pin:release a=unstable  
Pin-Priority: 1000  

Package: MY_OTHER_PACKAGE
Pin:release a=unstable  
Pin-Priority: 1000  

Package: *  
Pin: release a=unstable  
Pin-Priority: 100

Things to keep in mind

Having a hybrid Debian system can be beneficial, as it allows you to install software from various versions of the operating system. However, you should also know that doing this can be dangerous, as “Unstable” packages can break sometimes.

How to revert the changes

If you wish to revert packages you’ve installed from Unstable and return your Debian Linux system to normal, do the following. First, uninstall the packages from your Debian system as is. You can re-install these packages later once the “Unstable” repo is removed.

Once you’ve uninstalled the packages, open up a terminal window. Once it is open, remove the following code from the /etc/apt/sources.list file.

sudo nano -w /etc/apt/sources.list

Remove:

deb http://deb.debian.org/debian unstable main contrib non-free
deb-src http://deb.debian.org/debian unstable main contrib non-free

After removing the code, save the file in Nano by pressing Ctrl + O, and exit using Ctrl + X. Then, use the rm command to delete the /etc/apt/preferences file.

sudo rm /etc/apt/preferences

With the file deleted, run the apt update command. Then, re-install your packages. Everything will be back to normal.

sudo apt update

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.