Skip to content

Instantly share code, notes, and snippets.

@Arkanosis
Last active May 3, 2021 19:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arkanosis/25a65bd2248cc0dd46323aecfe2ab1c9 to your computer and use it in GitHub Desktop.
Save Arkanosis/25a65bd2248cc0dd46323aecfe2ab1c9 to your computer and use it in GitHub Desktop.
Upgrading from Kubuntu 18.04 (Bionic) to Debian 10 (Buster) using Arch

Upgrading from Kubuntu 18.04 (Bionic) to Debian 10 (Buster) using Arch

The following describes how you can upgrade a running Kubuntu 18.04 to Debian 10 without having to format the root partition (which usually also contains /home).

This might sounds complicated at first, but it really isn't. Note that this is using Arch because why not, but you only need a distro on a bootable drive which is not the one being upgraded; Ubuntu or Debian would work as well.

Also, obviously:

  • only a fool would try that without proper backups;
  • this comes with no guarantee of any kind (if it breaks and you lose all your data, it's your own fault).

Important notice: while Kubuntu 18.04 was initially released with version 4.15 of the Linux Kernel, subsequent point released have been introducing newer versions. For example, Kubuntu 18.04.5 comes with version 5.4 of the Linux Kernel. If your install of Kubuntu 18.04 is dependant of this version of the kernel (for, eg., some harware support or filesystem feature), you might want to jump directly to Debian 11 (Bullseye) which comes with version 5.10 of the kernel instead of Debian 10 which comes with version 4.19.

Installing Kubuntu 18.04 with qemu

The following sections assume you have a system running Kubuntu 18.04 to upgrade. But if you want to try the upgrade in a VM first, here's how to start a VM running Kubuntu 18.04:

$ wget https://cdimage.ubuntu.com/kubuntu/releases/18.04/release/kubuntu-18.04.5-desktop-amd64.iso
$ qemu-img create -f qcow2 /mnt/hdd/vm/kubuntu_to_debian.img 10G
$ qemu-system-x86_64 -enable-kvm -hda kubuntu_to_debian.img -cdrom kubuntu-18.04.5-desktop-amd64.iso -m 8192 &
$ vncviewer localhost:5900

Proceed to the installation, then restart the VM:

$ rm kubuntu-18.04.5-desktop-amd64.iso
$ qemu-system-x86_64 -enable-kvm -hda kubuntu_to_debian.img -m 8192 &
$ vncviewer localhost:5900

Installing Debian 10 in a chroot from within Ubuntu with debootstrap

Within your running Ubuntu, do the following:

# apt install binutils debootstrap
# mkdir /debian
# debootstrap --arch amd64 buster /debian http://deb.debian.org/debian
# cp /etc/{fstab,hostname,hosts,resolv.conf} /debian/etc
# mount --bind /boot /debian/boot
# mount --bind /dev /debian/dev
# mount --bind /proc /debian/proc
# mount --bind /sys /debian/sys
# chroot /debian
# apt update && apt upgrade
# apt install linux-image-amd64 grub-pc
# grub-install /dev/sda
# update-grub
# passwd
  • FIXME copy SSH server keys

Replacing Ubuntu with Debian

Boot on Arch (or whatever live distro you want), then mount the Ubuntu filesystem:

# mkdir /ubuntu_to_debian
# mount /dev/sda1 /ubuntu_to_debian
# cd /ubuntu_to_debian
# for dir in bin etc lib lib64 sbin usr var; do mv $dir $dir.ubuntu && mv debian/$dir $dir; done
# rm -r debian

Booting on Debian

Nothing special: just boot your system. It's running Debian now:

$ lsb_release -a

What could go wrong

Lots of things, actually. But most likely, the problems you'll have to deal with are the following:

  • the programs you had installed / configured on Ubuntu need to be reinstalled / reconfigured on Debian (if you use some configuration management system like Saltstack or Ansible, that's an easy problem);
  • the version of the programs in Debian 10 are not compatible with the user configurations created with Ubuntu 18.04 (there is no way around that: fix the configurations manually or delete them).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment