The Fairphone of Theseus

Note

The following method may not fully work on newer devices that use the Android Keystore System to manage app secrets like cryptographic keys. These secrets can not be extracted by conventional means and thus can not be copied to a second device.

Introduction

It should be common knowledge that you can get spare parts for pretty much every major component of a Fairphone. Broken camera? Just remove the old camera module and stick in a new one. Broken charger port? Same story. Even the display can be swapped without so much as a screwdriver (at least in case of the Fairphone 2).

But what about the main module? The one with the CPU and memory and storage where all the pictures and browser history, apps and contacts live? The soul of the phone? Surely that can't be easily replaced?

With the bootable recovery image from Lineage, we can boot the old module into a minimal recovery environment. There, we can enable ADB access. After attaching a usb cable, we can copy the complete memory from the old main module to the connected computer.

Step 1

adb pull /dev/block/mmcblk0 mmcblk0.img

This will take quite a while and require a lot of space on the computer. It should be possible (although I haven't tried this) to compress the image on the fly:

adb shell 'dd if=/dev/block/mmcblk0 2>/dev/null' | gzip > mmcblk0.img.gz

Now we have a complete copy of everything that was living on the old core module on our computer. It is in fact so complete that even the whole Android system is included.

Step 2

Now we do the whole thing in reverse with the new core module. We boot also put the new module into Lineage recovery, enable ADB access, attach the USB cable. Now we simply write everything that we copied from the memory of the old module into the new one.

pv mmcblk0.img | adb shell 'dd of=/dev/block/mmcblk0'

I use pv to get a nice progress bar. If you don't have it installed, you can use cat in its place but won't get a nice progress bar. Be prepared to wait a while.

If you have a compressed image, you have to decompress it on the fly, something like so:

gunzip mmcblk0.img.gz | pv | adb shell 'dd of=/dev/block/mmcblk0'

Done

Now we have successfully replaced the core module, keeping the Android system and all the memory contents, including pictures and browser history.


Pages linking here