2024-02-12

Live Migrate Ubuntu 22.04.3 to Debian 12.5 on Raspberry Pi 4

I had a Ubuntu 22.04.3 on a Raspberry Pi 4. Recently I decided to switch it to Debian 12.5 in-place.

Mostly I was following this script: https://github.com/alexmyczko/autoexec.bat/blob/master/config.sys/ubuntu-deluxe 

It worked surprisingly well, however, the system was eventually broken (unsurprisingly) near the end, when I tried to upgrade the kernel.


I tried to fix initramfs by copying dtbs files, which seemed to work. Some references:

https://qiita.com/takasan/items/ef93be9e9d3f791eee66

https://bugs.launchpad.net/ubuntu/+source/flash-kernel/+bug/2012750


But the kernel did not load after reboot. Reverting /boot/config.txt didn't help.

Then I downloaded a Debian image and replaced only the boot partition of the micro SD card. This time the kernel was able to boot, but it couldn't load the filesystem.


I modified cmdline.txt, replaced "root=LABEL=RASPIROOT" with "root=/dev/mmcblk1p2", such that the kernel was able to load the filesystem. But a new error appeared: Cannot open access to console, the root account is locked.


At this point I found the process no longer fun, because it was such a pain to modify anything in the boot partition (power off Raspberry Pi, unplug the micro SD card and plug it into a PC, edit, unplug the micro SD card and plug it into Raspberry Pi, power on Raspberry Pi).


Eventually I just installed formatted the micro SD card, installed the Debian image and reconfigured the system. It was actually not slower than the in-place process.


I'd the say the ubuntu-deluxe script works pretty well. Most of the time I was just dealing with the difference between both distos (e.g. config files). Later I learned that the Ubuntu and Debian images used different methods for booting up Raspberry Pi. 

So theoretically it is possible to migrate from Ubuntu to Debian inplace. In fact there is a debtakeover script, which allows migrating to Debian from many other distros. On the other hand, normally it might make more sense to just reinstall the system.