[MOD][AUGUST 1][Moto G 2015] MultiROM v33a [No Kexec Workaround]

GtrCraft

Recognized Developer
Jun 3, 2013
6,427
16,392
263
Introduction

MultiROM is one-of-a-kind multi-boot mod for Moto G 2015. It can boot any Android ROM as well as other systems like Ubuntu Touch, Plasma Active, Bohdi Linux or WebOS port, once they are ported to our device. Besides booting from device's internal memory, MultiROM can boot from USB drive connected to the device via OTG cable. The main part of MultiROM is a boot manager, which appears every time your device starts and lets you choose ROM to boot. You can see how it looks on the left image below and in gallery. ROMs are installed and managed via modified TWRP recovery. You can use standard ZIP files to install secondary Android ROMs, daily prebuilt image files to install Ubuntu Touch and MultiROM even has its own installer system, which can be used to ship other Linux-based systems.​

Features:
* Multiboot any number of Android ROMs
* Restore nandroid backup as secondary ROM
* Use for example Ubuntu Touch or Desktop alongside with Android, without the need of device formatting, once they are ported to the Moto X Play
* Boot from USB drive attached via OTG cable


Warning!

It _is_ dangerous. This whole thing is basically one giant hack - none of these systems are made with multibooting in mind. It is messing with boot sector and data partition. It is no longer messing with data partition or boot sector, but it is possible that something goes wrong and you will have to flash factory images again. Make backups. Always.​


Installation
1. Via MultiROM Manager app (We do not have Official Support, so this is not an option for us yet)
This is the easiest way to install everything MultiROM needs. Install the app (Not for Moto X Play) and select MultiROM and recovery on the Install/Update card. If the Status card says Kernel: doesn't have kexec-hardboot patch! in red letters, you have to install also patched kernel (If you want to use Kexec) - either select one on the Install/Update card or get some 3rd-party kernel here on XDA. You are chosing kernel for your primary ROM, not any of your (future) secondary ROMs, so select the version accordingly.
Press "Install" on the Install/Update card to start the installation.

2. Manual installation
Firstly, there are videos on youtube. If you want, just search for "MultiROM installation" on youtube and watch those, big thanks to all who made them. There is also an awesome article on Linux Journal.


MultiROM has 3 parts you need to install:

  • Modified recovery (TWRP_multirom_osprey_YYYYMMDD.img) - download the IMG file from second post and use fastboot, TWRP or Flashify app to flash it.
  • Patched kernel - you can find it in the second post. Download the ZIP file and flash it in recovery. You can use any 3rd-party kernel which include the patch.
  • MultiROM (multirom-YYYYMMDD-vXX-osprey-signed.zip) - download the ZIP file from second post and flash it in recovery.
You current rom will not be erased by the installation.
Download links are in the second post.



Adding ROMs

1. Android
Go to recovery, select Advanced -> MultiROM -> Add ROM. Select the ROM's zip file and confirm.​


Using USB drive (not tested yet)
During installation, recovery lets you select install location. Plug in the USB drive, wait a while and press "refresh" so that it shows partitions on the USB drive. You just select the location (extX, NTFS and FAT32 partitions are supported) and proceed with the installation.
If you wanna use other than default FAT32 partition, just format it in PC. If you don't know how/don't know where to find out how, you probably should not try installing MultiROM.
If you are installing to NTFS or FAT32 partition, recovery asks you to set image size for all the partitions - this cannot be easilly changed afterward, so choose carefully. FAT32 is limited to maximum of 4095MB per image - it is limitation of the filesystem, I can do nothing about that.
Installation to USB drives takes a bit longer, because the flash drive is (usually) slower and it needs to create the images, so installation of Ubuntu to 4Gb image on my pretty fast USB drive takes about 20 minutes.
Enumerating USB drive can take a while in MultiROM menu, so when you press the "USB" button in MultiROM, wait a while (max. 30-45s) until it searches the USB drive. It does it by itself, no need to press something, just wait.​



Updating/changing ROMs

1. Primary ROM (Internal)

  • Flash ROM's ZIP file as usual, do factory reset if needed (it won't erase secondary ROMs)
  • Go to Advanced -> MultiROM in recovery and do Inject curr. boot sector.
2. Secondary Android ROMs
If you want to change the ROM, delete it and add new one. To update ROM, follow these steps:

  • Go to Advanced -> MultiROM -> List ROMs and select the ROM you want to update.
  • Select "Flash ZIP" and flash ROM's ZIP file.
  • In some cases, you might need to flash patched kernel - get coresponding patched kernel version from second post and flash it to the secondary ROM sama way you flashed ROM's ZIP file.



Explanation of recovery menus

Main menu
- Add ROM - add ROM to boot
- List ROMs - list installed ROMs and manage them
- Inject boot.img file - When you download for example kernel, which is distrubuted as whole boot.img (eg. franco kernel), you have to use this option on it, otherwise you would lose MultiROM.
- Inject curr. boot sector - Use this option if MultiROM does not show up on boot, for example after kernel installation.
- Settings - well, settings.

Manage ROM
- Rename, delete - I believe these are obvious
- Flash ZIP (only Android ROMs) - flash ZIP to the ROM, for example gapps
- Add/replace boot.img - replaces boot.img used by this ROM, this is more like developer option.
- Re-patch init - this is available only for ubuntu. Use it when ubuntu cannot find root partition, ie. after apt-get upgrade which changed the init script.​


Source code



Donations (Please donate to the Creator @Tasssadar )

I'd be glad if you could spare a few bucks. You can use either paypal or Bitcoins, my address is 172RccLB2ffSnJyYwjYbUD3Nx4QX3R8Ris

 
Last edited:

GtrCraft

Recognized Developer
Jun 3, 2013
6,427
16,392
263
Last edited:

GtrCraft

Recognized Developer
Jun 3, 2013
6,427
16,392
263
FAQ and other notes
Device encryption
Since v32, MultiROM supports encryption on this device (it has to be added for each device separately). It works only with Android-based secondary ROMs and the secondary ROMs don't know the device is encrypted, so they would allow you to encrypt the device again - do not do that. If you're using password, pin or pattern for the encryption, MultiROM will ask you for the password on boot. If you're booting the primary ROM, then Android will ask you for the password _again_ - unfortunately, there is no way for me to pass the "unencrypted" status to Android. If you're booting secondary ROM, MultiROM will ask you for the password again after the reboot - that's because I have to unencrypt the /data partition after the ROM's kernel is loaded.

I could omit the second password prompt when booting secondary ROM by temporarily saving the password somewhere, but that's obviously unsafe. So is using encryption with unlocked device though, so I might add this later.​
I have not tested it yet, as i never used ENCRYPTION on my device, will try to see if there are issues and more users for this use case

About security
In order to make multi-booting possible, MultiROM has to sacrifice some security measures. Firstly, on secondary Android ROMs, /system is not mounted read-only. While there are other things preventing malicious software from messing with /system, this might potentialy make it easier for such software to attack that system.​

What do the ROMs share?
All ROMs are separate, except /sdcard, which is shared between all Android ROMs.​

How many ROMs can I have?/Where are the ROMs stored?
You can have as many ROMs as you can fit in your /sdcard. All the ROMs are stored in /sdcard/multirom/roms or on an USB drive. This folder is unaccessible in Android, to prevent mediascanner from scanning it. You can either in recovery, or obtain root and go to /data/media/0/multirom/roms.
By default /external_sd is mounted and is used to store the ROMs.

The menu with all the ROMs won't show up during boot, how to fix it?
Either re-flash the MultiROM zip or go to recovery, Advanced -> MultiROM -> Inject curr. boot sector.

The reason for this is that something rewrote your boot.img, which happens for example when you flash a kernel. MultiROM's boot menu is part of the boot image, so it has to be added into it again.

Can I flash secondary roms on Micro SD?
Yes but it's is very slow, internal storage is much better to flash secondary roms.

How do I flash Gapps in Secondary ROMs?
After AddRom and is done, go back and Click on the installed Secondary ROM, you will see one of the option to 'Flash Zip', click and install Gapps. Then you can reboot into secondary ROMs, do gapps installation before rebooting otherwise as usual need to deal with SetupWizard FC, at least thats what I observe in my device.
 

GtrCraft

Recognized Developer
Jun 3, 2013
6,427
16,392
263
Enabling no-kexec workaround
As of this version you need to manually enable the no-kexec workaround.

Go to TWRP -> MultiROM -> Settings


and enable the No-KEXEC workaround option


once you do you'll also have the option for ADVanced settings, please see below for a detailed description, though in most cases the default should suffice.​





Explanation of the no-kexec workaround advanced options

(the Info page is supposed to provide the same information as here, but I haven't added that yet)


1- Use no-kexec only when needed
This should be the default for most users, the other options are more intended for advanced uses (kernel debugging, and such).

If MultiROM detects a kexec-hardboot enabled kernel in primary slot, it will use the standard kexec method to boot the secondary. If on the other hand it does not detect that the kernel supports kexec-hardboot then it will use the workaround.​



2- ... but also ask for confirmation before booting
Same as option 1 above, but in addition you will be presented with a confirmation message, if the workaround is about to be used:



3- Ask whether to kexec or use no-kexec on booting
If the kernel in primary slot does support kexec-hardboot'ing then you will be presented with a choice of which method to use


If the kernel does not support kexec-hardboot then you'll be informed as in option 2 above​



4- Always force using no-kexec workaround
Forces the no-kexec workaround to be used, even if the kernel in primary slot has kexec-hardboot support​



Options 2 and 3, always present the user with a GUI confirmation, whereas option 1 and 4 will act as instructed without prompting the user.





Visual feedback provided by the Booting... card
Regular kexec-hardboot boot




Booting using no-kexec-workaround




Booting into primary, while the previous rom was using the no-kexec-workaround
(in which case the real primary needs to be restored first)



How does all this work, etc

The workaround:
  • MultiROM TWRP recovery works, and is able to flash ROMs to secondary
  • MultiROM in essence works (in particular, able to change the mount points during bootup)
  • what does not work is being able to use the secondary ROM's kernel (due to the lack of kexec-hardboot kernel and tools)

So how do we deal with booting any ROM if we can't use the proper kernel for the ROM?
Easy :eek: :
Upon selection of the ROM during MultiROM boot menu, we do the following:
  1. "flash" secondary boot.img to primary partition slot
  2. initiate a full reboot (secondary boot.img is in primary slot)
  3. let the ROM auto-boot up on second boot

The good part:
  • It works.... has been for quite some time, but I kinda kept it hidden
    .
  • Every secondary ROM has a boot.img file we can easily access to use the workaround; when you flash a ROM in MultiROM TWRP, not only are the "virtual" system, data, and cache partitions created, but also the boot.img.
    The secondary ROMs' boot.img will be found /data/media/0/multirom/<name of rom>/boot.img or if it's on your external ext4 in the appropriate rom folder
    We use that file and flash it to primary real boot partition and then upon second boot, the correct boot.img is in place for the correct ROM.

The bad part:
  • What we (yes, we) have come to affectionately call the "lingering primary_boot.img" this should now be taken care of, as much as possible
    .
  • Unlike secondary ROMs, the primary ROM does not have a boot.img file... since it is the primary ROM, the boot.img should always be in the real boot partition, since MultiROM expects the primary kernel to have kexec-hardboot capability, but it does not, so I just go ahead and mess with your primary boot partition.
    Since we have no "boot.img" file for the primary, my workaround makes a backup of the kernel and names it primary_boot.img
    This backup is created and/or used only under certain situations, for example (this is not an exhaustive list):
    • the last ROM was primary, and we want to boot a secondary ---> backup the primary boot.img, flash secondary one
      .
    • the last ROM was secondary, and we're booting another secondary ---> just flash the secondary boot.img
      .
    • the last ROM was secondary, and want to boot the primary ROM --> restore the primary_boot.img we backed up
      .
      ^^ and here lies the problem, we cannot actually say if the backup we created is actually correct for the primary ROM.... ideally it is, but there are easy ways to break that UPDATE: not so easy to break it all, anymore :)

      one very simple example (as mentioned in the FAQs) would be:
      ==> Reboot from secondary to recovery, flash new primary ROM/kernel ---> the backup of primary_boot.img will still be there, MultiROM will still think the last ROM was a secondary, and therefore restore the backup; which will result in a non-booting primary ROM since the backed up kernel doesnt actually belong to this ROM
      this is what I call a "lingering primary_boot.img"

      this is just one simple example, but it can happen for a variety of reasons... interrupted boots,
      some app/method flashed a new kernel, etc.

The solution for the "lingering primary_boot.img":
  1. Delete (if it's there): /data/media/0/multirom/last_rom_was_2nd no longer used
  2. Delete (if it's there): /data/media/0/multirom/primary_boot.img
  3. Reflash or restore the correct boot.img for your primary ROM


New safe guards to avoid a "lingering primary_boot.img":
  1. TWRP will restore the primary boot.img when entering recovery
  2. MultiROM identifies whether the boot.img currently in primary slot is secondary, by checking the boot.img itself;
    it no longer relies on a separate file (last_rom_was_2nd)
  3. If the boot.img in primary slot is not tagged as a secondary, it is considered a new primary boot.img

Long story short: the difference between kexec and no-kexec-workaround
Usual kexec-hardboot MultiROM
  1. Select secondary ROM
  2. MultiROM detects a boot.img
  3. MultiROM reads the secondary boot.img into memory
  4. MultiROM initiates a kexec second boot but into the secondary boot.img from above
  5. MultiROM continues
No-kexec-workaround MultiROM
  1. Select secondary ROM
  2. MultiROM detects a boot.img
  3. MultiROM flashes the secondary boot.img into the primary boot partition
  4. MultiROM initiates a full second boot but with the secondary boot.img in the real boot partition
  5. MultiROM continues as usual

so the difference is in point 3... whereas normal kexec'ing loads the secondary boot.img into memory and goes from there, the workaround, actually flashes it to the real primary boot partition... and continues normally from there


Small note regarding encrypted devices using the no-kexec workaround
Since I dont use encryption, I haven't tested this to much extent, but I believe that there is a BOOT PRIMARY ROM option, which you can choose to boot into Internal without decrypting the device first.

Please be aware that this should not be used, if: the last booted ROM was a secondary using the no-kexec workaround.

The reason is that the backup of the primary_boot.img, is stored in the multirom folder, so for the no-kexec to be able to restore it, it needs access to the /data partition:
Booting into primary, while the previous rom was using the no-kexec-workaround
(in which case the real primary needs to be restored first)
It's not too much of a big deal, because when the no-kexec workaround encounters an error, it reboots to recovery (and since recovery will restore the primary_boot.img), another reboot would be fine.

I do however (until I address this particular issue), encourage you not to use the BOOT PRIMARY ROM option, but instead decrypt the device, and then select the Internal ROM to boot.


Will this remain a "beta" version?
Most probably YES it will.... MultiROM is supposed to work with a kexec-hardboot enabled kernel; since that does not exist (at this time), on arm64 devices, I am using a workaround; since it doesn't exist and doesn't work, just work around it, if possible ... (call it "non-linear thinking" thinking if you wish)
until such time as the original author sees fit, or I decide to rename as "stable" (imho it is), it will remain called a "beta"

I have extensively tested this on the HTC One M7, the M8, and the M9 and have not found any side effects, so as of version 33b (2016-04-16), I consider this a stable release.


Devices using the no-kexec-workaround successfully
MultiROM threads for:
 

nkk71

Inactive Recognized Developer / Inactive Recognize
May 26, 2010
8,743
7,569
0
49
Beirut
Nice, congrats on the release. :good::good:

I need to fix up that text regarding the no-kexec workaround, since "lingering primary_boot.img" is no longer an issue... at worst a "lost/missing primary_boot.img" could be an issue, but I have not encountered / heard of it yet :)
 
Last edited:
  • Like
Reactions: GtrCraft

samirza692

Senior Member
Mar 1, 2016
51
0
0
awesome work guys
actaully i cant install rom on ext-sdcard (as formated internal ) as it says failed to fixup roms name while adding rom on ext-sdcard and second i cant install dirty unicorn rom
and last there is not showing all files on my internal and external storage in recovery even my roms for installing sorry for my bad english
again thank you all guys for doing a great job
 
Last edited:

GtrCraft

Recognized Developer
Jun 3, 2013
6,427
16,392
263
awesome work guys
actaully i cant install rom on ext-sdcard (as formated internal ) as it says failed to fixup roms name while adding rom on ext-sdcard and second i cant install dirty unicorn rom
and last there is not showing all files on my internal and external storage in recovery even my roms for installing sorry for my bad english
again thank you all guys for doing a great job
Dont install roms on ext sd card

Sent from my XT1562 using XDA Labs
 

GtrCraft

Recognized Developer
Jun 3, 2013
6,427
16,392
263
Nice, congrats on the release. :good::good:

I need to fix up that text regarding the no-kexec workaround, since "lingering primary_boot.img" is no longer an issue... at worst a "lost/missing primary_boot.img" could be an issue, but I have not encountered / heard of it yet :)
Yeah, pm me if you have anything new

Sent from my XT1562 using XDA Labs
 

pavanjadhaw

Senior Member
Sep 2, 2015
390
524
0
21
Nagpur
The testers told me touch does work

Sent from my XT1562 using XDA Labs
Touch is not working. I mean touch is working in multirom twrp but once you switch on the phone it gives option to chose which one we have to install there touch is not working I am able to choose only by using harware volume keys...
Anyone else facing similar problem. If I m only one who is facing this what is gone wrong help me fix it please.
 
  • Like
Reactions: androidbaba

androidbaba

Senior Member
Nov 19, 2008
1,203
359
103
Touch is not working. I mean touch is working in multirom twrp but once you switch on the phone it gives option to chose which one we have to install there touch is not working I am able to choose only by using harware volume keys...
Anyone else facing similar problem. If I m only one who is facing this what is gone wrong help me fix it please.
Yes +1
Touch not working while selecting which ROM to boot
Everything else works perfectly though
Thanks @grtcraft for your efforts

Sent from my MotoG3 using XDA-Developers mobile app