Upgrading LineageOS 16 to 20

In 2019 I installed LineageOS 16 on a Xiaomi Mi8 smartphone, and now in 2023 I wanted to upgrade to LineageOS 20 - skipping multiple major versions.

Installing the update to the system partition worked, but the system was broken afterwards.

When booting the first time, it tried to apply migrations: System databases and files in the old format need to be modified so they are structured as the new operating system version expects it. Unfortunately, the LineageOS 20 firmware is not able to upgrade from version 16 - my guess is that the migrations for such "old" versions are missing.

The phone booted to the lock screen, the screen flickered a couple of times and then it rebooted. Repeat forever.

The LineageOS developers do not keep older versions around; so I did not have the chance to first flash version 17, then 18, 19 and at last 20. The only downloadable firmwares were 19 and 20.


In preparation for the update I made two backups:

  1. Partition backup with TWRP
  2. Data files backup with "adb pull"

Partition backup

I booted into the TWRP 3.7.0_9-0 recovery partition with adb reboot recovery. Then I opened the backup settings, selected the boot, system and data partitions and ran

$ adb backup --twrp

Then it took some time while the backup was directly stored on my PC.

fastboot image Partition backup in progress

Data file backup

While I was in TWRP recovery mode, I pulled all the user files from the phone:

$ adb pull /sdcard

Later I learned that I should have used pull -a to backup the file timestamps as well.

Backup restoration

After the upgrade from 16 to 20 failed, I wanted to restore my partition backup so that the phone would be back on Lineage 16. I booted into recovery, probably selected "restore" and then executed this on my PC:

$ adb restore backup.ab

Boot and system partitions got restored, but the data partition failed:

extractTarFork() process ended with ERROR: 255

Running the restoration twice did not make it better. It turned out many other people had the same problem: Team-Win-Recovery-Project #964.

In the end we had to install LineageOS 20 freshly and manually install and setup all the apps that were previously on the phone :( Very big suck.

Restoration aftermath

The failed system restore led to other problems:

partition size 0

Updating the system partitions with files from the official firmware updates with fastboot fails now for some partitions:

$ fastboot flash abl_ab abl.elf
Warning: skip copying abl_ab image avb footer (abl_ab partition size: 0, abl_ab image size: 155648).
Sending 'abl_ab' (152 KB)                          OKAY [  0.014s]
Writing 'abl_ab'                                   OKAY [  0.007s]
Finished. Total time: 0.032s

This did not change even after I installed and setup the official MIUI firmware.

TWRP: No operating system installed

When booting into recovery TWRP and selecting "reboot" there, it warns me that No OS Installed! Are you sure you wish to reboot? (even though the OS boots fine).

TWRP: No data decryption

TWRP does not ask me to unlock the data partition anymore.

I guess this began when I once cancelled the unlock process when TWRP was booted up, but I am not sure.

This means no data recovery with TWRP anymore :(

Written by Christian Weiske.

Comments? Please send an e-mail.