My base system is Debian and came with ftp.debian.org in the sources.list file. I have since added the latest Ubuntu repositories to my sources.list file and taken out the original Debian one.

Unfortunately all the packages I installed with the Debian repository that also exist in the Ubuntu repositories do not get replaced with an apt update, upgrade, dist-upgrade or full-upgrade.

So how can I force the reinstallation of currently installed packages from the old and removed repository with ones that exist in the new repositories?

  • Debian is not Ubuntu, and vice versa. If you want to switch from Debian to Ubuntu, you should re-install your system. – Stephen Kitt Oct 26 '20 at 16:44

A safer alternative would be to save the output of dpkg --get-selections, reinstall the machine with Ubuntu, and then use dpkg --set-selections to install the same set of packages on Ubuntu.

It's possible to get apt to do what you want. But first a warning: this type of change can easily leave you with a system that won't boot or is broken in other subtle or not-so-subtle ways. You should be fully prepared to either fix difficult problems or do a reinstall and restore data from backups.

You need to create an apt pin for Ubuntu packages with a priority at least 1000. This allows apt to install the Ubuntu version even if it means downgrading. Create /etc/apt/preferences.d/ubuntu with this content:

Package: *
Pin: release o=Ubuntu
Pin-Priority: 1001

You should update /etc/apt/sources.list, install the ubuntu-keyring package manually, and run apt update. (Sounds like you've already done these steps.) Then you can try an apt full-upgrade to move all packages to the Ubuntu versions.

Remove /etc/apt/preferences.d/ubuntu when you're done.

Note that Debian and Ubuntu use different naming for the Linux kernel meta-package, so you'll need to manually uninstall the Debian one (e.g., linux-image-amd64), install the Ubuntu one (e.g., linux-image-generic), and maybe manually remove the Debian linux-image-*-amd64 packages.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.