The Fairphone 2's factory reset ... or the lack thereof

So…
My understanding of the whole system is (simplified):
Partitions:

  • boot (image made with mkbootimg) - contains the kernel and the initial ramdisk (initrd/initramfs)
  • recovery (same as boot)
  • system (normally ext4) - contains the complete android system + system apps
  • userdata (normally ext4) - contains user-installed apps, app data, etc

Android makes boot&system read-only and the running system only has write access to the userdata partition.

The thing that’s called “Internal storage” in most apps is actually a folder in the userdata partition (located at /data/media/0) that’s mounted with some magic that makes it look like its a FAT filesystem (so no fancy permissions etc)

Afaik a “Factory Reset” is just wiping the userdata partition = all apps, data, etc is gone. I don’t know what Android does exactly but I can say for TWRP, that when you wipe “Data” but not “Internal Storage” it just rm -rfs all folders and files except the media folder in the userdata partition. When you select the data partition and then press “Repair or Change File System”, then you can really “format” the partition instead of just removing the files on there.

I believe the behaviour with encryption is that when you mount an encrypted partition with TWRP (i.e. enter your passcode) and then wipe, the partition stays encrypted and TWRP wipes the content in the encrypted partition. If you don’t enter your passcode and then wipe, it can’t do anything else than just format the partition and then it’s unencrypted (and empty) again.

4 Likes