(This should have been part of the original post, but it was over the character limit)
Using MultiROM
The custom TWRP recovery is (almost) the same as the normal TWRP recovery, but for some fixes not included yet in the custom one, a SD card partitioner not included due to space constraints and a different visual appearance. Therefore, same considerations/problems as with the normal TWRP recovery apply: NEVER install an official Fairphone 1 update through TWRP, and NEVER update your system through the Fairphone Updater app when the recovery installed in the recovery partition is TWRP.While I said that MultiROM is composed by three elements that is not exactly true. There is a fourth element, MultiROM Manager, which is an Android app to manage MultiROM. However, I have not tested it, so I strongly recommend you to use only the custom TWRP recovery for MultiROM management on the Fairphone 1.
Adding an additional operating system (ROM, in MultiROM terminology) and performing any other MultiROM management task is done through the MultiROM entry in the main menu of the custom TWRP recovery.
As already explained, ROMs should be added in the external SD card, not in the internal memory. Therefore, after tapping on Add ROM you should select the rather cryptic /dev/block/mmcblk1p1 location.
The main way to add an Android ROM is with its .zip update file. For example, after building Android 5.0 for the Fairphone 1 (or the 4.2, 4.3 and 4.4 versions also available in those same repositories), you just have to copy cm_fp1-ota-<random letters and numbers>.zip to your phone (typically to the internal SD card) and then install it through the MultiROM section of TWRP. You can even skip copying it to your phone and serve it directly through ADB by using the sideload option.
Unfortunately, as stated above, you can not install an official Fairphone 1 update, neither as the main system nor as an additional operating system in the MultiROM section of TWRP. You can, however, install a backup of your main operating system made with TWRP as an additional operating system, even if the main one is an official Fairphone 1 operating system. To do that you must use a backup that includes at least the system partition, and you must ensure that the backups of all the partitions will fit inside the sizes that MultiROM will use for them.
Be very careful if you install it from a backup, though; as it would be a fully working system, including telephony, this may make a mess in the MediaTek-specific partitions and you may end needing to restore your IMEI or things like that… I have tested it and, although telephony did not work in the backup, I had no problems in the main operating system (but from being slower to connect to the telephony network after introducing the PIN). However, while researching the behavior of some MediaTek-specific elements I realized how brittle they were and it would not surprise me at all if using an additional operating system installed from a backup wrecked the main operating system. You have been warned (Ironically, not having support for the telephony system in the Android 5.0 version is in this case a good thing, as it is safe to use).
Besides additional Android operating systems, MultiROM also supports additional generic Linux based operating systems. In this later case they have to be installed through a special package built specifically for MultiROM. It is not ready to be released yet, but I have been working on porting certain Linux based operating system to the Fairphone 1; even if it is just partial support (like the Android 5.0 version), I think that it would be a nice touch, if you know what I mean
In any case, MultiROM installs each additional operating system on its own subdirectory of the multirom-fp1 directory of the external SD card (as that is the location selected to install the ROM to); the partitions of your main operating system will be left untouched. Moreover, when the multirom-fp1 directory belongs to a partition that uses the FAT file system (like the external SD card), MultiROM will use a disk image for each partition of the additional operating system, so each one will be just a single file (disk images are special files that internally act as a partition, but externally are just regular files, like a spreadsheet or a video).
A word of caution, though: it has happened to me that, when using an additional operating system, it suddenly failed due to being unable to read from the external SD card. Probably one of its disk images got corrupted or something like that, as I simply deleted the disk images, installed the ROM again, and everything went back to normal; yes, I should have investigated instead why it happened and how to fix the problem… but I did not, so I do not know if the data could be recovered in that situation or not, sorry So, if you have something important stored in one of the additional operating systems, always keep a backup of it (which is an advice that could be applied not only to MultiROM, but to any use of a smartphone or computer).
Adding large ROMs
If you intend to add an Android ROM whose .zip is larger than 200 MiB (which is the case for my Android 5.0 version) or a Linux based ROM whose .mrom file is larger than 400 MiB there is a "little" problem: the installation process will fill "all" the RAM memory and the device will reboot (well, it is not exactly all the RAM memory, but the tmpfs file system (which is backed by the RAM memory) mounted on /tmp... but anyway, it will reboot without finishing the installation).The solution? Trick the custom TWRP recovery to work on disk instead of on RAM memory. When a file system is mounted on a directory the file system is attached to that directory, and the contents of the file system become the contents of the directory; any other previous content in the directory is simply hidden until the file system is unmounted. Mounts can be stacked, so several file systems can be mounted on the same directory, and the contents of the directory will be the contents of the latest file system mounted and not unmounted yet. You can do just that: mount a disk-backed file system on /tmp to hide the original tmpfs; this way files will be created on the disk, lefting the original tmpfs, and therefore the RAM memory, untouched.
For the disk-backed file system a single disk image file stored in the internal or external SD card can be used. Supposing that you want to use the internal SD card and that you have 1 GiB free you can create it through ADB on the custom TWRP recovery with the following command (the name of the file is irrelevant, just ensure that it does not exist before running the command):
<path to ADB executable>/adb shell make_ext4fs -l 1000M /internal_sd/tmp.img
Now that the disk image was created it is simply a matter of mounting it on /tmp:
<path to ADB executable>/adb shell mount -o loop /internal_sd/tmp.img /tmp
Once mounted it will appear too in the MultiROM locations as /dev/block/loop0, but it does not matter; just keep using /dev/block/mmcblk1p1 as explained above.
When you have finished using the disk image (that is, when the installation of the additional operating system has finished) you can unmount and remove it to free the space from your SD card:
<path to ADB executable>/adb shell unmount /tmp && rm /internal_sd/tmp.img
Uninstalling MultiROM and the custom boot image
In the same way that installing MultiROM had to be done after installing the custom boot image, uninstalling MultiROM must be done before uninstalling the custom boot image.To uninstall MultiROM you have to install its uninstaller. I know, it sounds odd It is the same process as with the installer package, but this time with the uninstaller package. First, copy the MultiROM uninstaller (/home/$USER/MultiROM/out/target/product/fp1/multirom_uninstaller.zip) to your phone. It does not matter how you do it; if you have booted to TWRP you can copy it with the following command:
<path to ADB executable>/adb push -p /home/$USER/MultiROM/out/target/product/fp1/multirom_uninstaller.zip /internal_sd/multirom_uninstaller.zip
Now, in your phone, tap Install in the main menu of the custom TWRP recovery, select multirom_uninstaller.zip and then at the bottom of the screen swipe to install. The uninstaller removes the MultiROM files from /data/media/0/multirom and also modifies the boot partition to remove the MultiROM bootloader (so now the phone will boot directly in the main operating system). Note, however, that the additional operating systems installed on the multirom-fp1 directory of the external SD card will not be automatically removed; you will have to manually delete the subdirectories of multirom-fp1 (or even the multirom-fp1 directory altogether), or delete the installed ROMs using the custom TWRP recovery before uninstalling MultiROM.
Even if the phone boots directly in the main operating system the boot image is still the custom boot image, and it still has the already explained problems (no alarms and unresponsive charger mode). To restore the original boot image simply go back to the main menu of the custom TWRP recovery and restore the backup of the boot and system partitions you made (because you made it when I told you to, didn’t you? ).
Questions and answers
MultiROM wiki says that devices with a separate internal partition in /sdcard are not supported. Yet you claim that it can be used only with the original storage layout. What is going on here?
Well, the fact is that MultiROM can indeed be used on devices with a separate internal partition in /sdcard. However, MultiROM can not use that partition. Those devices with a separate internal partition in /sdcard usually have a small /data partition, which is the one that uses MultiROM (the internal memory), and most space is reserved for the /sdcard partition (like in the Fairphone 1 with the original storage layout, in which /data has 1 GiB and /sdcard has 13 GiB). Therefore, although MultiROM can be used in the device, an external storage device must be used to store the additional operating systems.Using an external USB drive would be possible, although not very practical, as it must be connected all the time while the additional operating system is used. The best option is to use an external SD card… even if the MultiROM wiki says that they are not supported due to how slow and awful they are. Well, in my experience, a class 10 SD card (45MiB/s read, 10 MiB/s write) works fine; it is not as fast as the internal memory (and it is specially noticeable during the boot of additional operating systems), but it is not the end of the world either
In conclusion: MultiROM works best on devices with a large /data partition, but it works too on devices with an internal /sdcard partition storing the ROMs on a external SD card, even if there are several things to take into consideration and its use is not as smooth as in the first case.
Would it be possible to isolate all the partitions instead of just cache, data and system?
Isolating the internal 13 GiB partition (where photos, music and general files are stored) would be relatively easy. Adding support for Fairphone 1 with the unified storage layout (and updating the device to use that storage layout) would be enough (and the proper way to use MultiROM, as explained above), because with the unified storage layout there is no internal 13 GiB partition (it is fused with the internal memory, the data partition, which is already isolated).On the other hand, isolating the external SD card and, more importantly, the MediaTek-specific partitions would require deep changes in MultiROM (and maybe even in the kernels of the operating systems used, specially for the MediaTek-specific partitions, although I have not given it much thought). Another approach would be to still share those partitions, but use the kernels to limit the write access to those partitions only to components known to be safe. Unfortunately, this comes back again to the problem explained in the Android 5.0 article of not having the source code of the MediaTek-specific components, and without that source code it is not possible to ensure that allowing certain component to write to the MediaTek-specific partitions will not cause a major problem (although, again, in my use of MultiROM I have not found any).
After installing an additional operating system I found that I installed it by mistake in the internal memory... but it works! What has happened?
Well, I have never said that you could not install them in the internal memory ;) (and if I did please tell me because it is a leftover from a previous draft :P ). It is indeed possible to install additional operating systems in the internal memory, but you must take into account that then the applications of your main operating system, its data, the additional operating system, its applications and its data will all have to fit in the same partition. A little crowded for just 1 GiB, specially if you take into account that only the base files of an Android system takes around 350 MiB and on the first boot up to 100 MiB of data could be generated.In any case, if you have enough free space in your internal memory and you install an additional operating system there you may want to know that it will end inside /data/media/0/multirom/roms/ and that, unlike those installed in the external SD card, uninstalling MultiROM will delete the additional operating systems installed in the internal memory.
This article is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. For the MultiROM license please check the source files themselves; those written by me are typically licensed under the GNU General Public License version 3 or later, but in some cases I had to use a different license (for example, in the case of kernel patches they have to be licensed under the GNU General Public License version 2).