FORUMS

[RECOVERY][DUALBOOT][MAGISK][3.3.1-79][Unified]Unofficial TWRP for OnePlus 7/7 Pro/5G

3,941 posts
Thanks Meter: 6,435
 
Post Reply Email Thread
Team Win Recovery Project 3.x, or twrp3 for short, is a custom recovery built with ease of use and customization in mind. Its a fully touch driven user interface no more volume rocker or power buttons to mash. The GUI is also fully XML driven and completely theme-able. You can change just about every aspect of the look and feel.

Code:
#include <std_disclaimer.h>
/*
 *
 * We are not responsible for bricked devices, dead SD cards,
 * thermonuclear war, or you getting fired because the alarm app failed. Please
 * do some research if you have any concerns about features included in this ROM
 * before flashing it! YOU are choosing to make these modifications, and if
 * you point the finger at us for messing up your device, we will laugh at you.
 *
 */
Disclaimer
This is a DANGEROUS mod. Anything involving repartitioning is. If you fail to read and bad things happen, that's on you. Although I thoroughly tested this (managed to brick my phone once), there's always the possibility that something could go wrong with the worst case scenario resulting in a brick.
YOU'VE BEEN WARNED - Use at your own risk

What is this?
This is @mauronofrio's TWRP (see official thread here) that's been modified for true dual booting by splitting userdata into a/b slots (also does the same for metadata for encryption support). The installer script repartitions userdata for dualboot or stock based on your input.

This has only been tested on the Oneplus 7 Pro - 256gb. Although it should theoretically work on other OP7's I haven't formally tested it. So if you are on one of these devices, make a post with the output of this command:
Code:
su -c sgdisk /dev/block/sda --print
I'll take a look at it and give the go ahead or not (and if not I'll update this to fix it)

Features:
  • Same as mauronofrio's TWRP
  • Can choose between stock layout, a/b userdata, or a/b/c userdata where 'c' is a common data partition that'll show up in both roms - it's quite handy
  • Option to choose between ext4 and f2fs
  • Disables verity - fstabs are modified for dual boot and so this is a must unless you choose stock layout in which case it's optional
  • Option to disable forced encryption
  • Option to install magisk - this is mandatory with a/b/c layout

Common Data
I recommend the a/b/c layout which includes this common data partition
  • If you choose a/b/c layout - you'll have a/b userdata, but you'll also get a 3rd userdata partition I call 'Common Data'
  • The name 'Common Data' gives away its purpose - to store files that you'll access on both slots/roms. So stuff like zips, pictures, music, TWRP backups, etc.
  • In TWRP, this shows up as another storage option for backup/restore and on your pc as well - your phone will have 'Common Storage' and 'Internal Storage'
  • In order to be accessible when booted, some parts of the system are modified so that the it'll be accessible WITHOUT root by the following mechanisms:
    - The common data partition is mounted to /sdcard/CommonData
    - Furthermore, if your use case is like mine where my music files are in common data, all FOLDERS are mounted over top of sdcard. So for example:
    /datacommon/Music -> /sdcard/Music
    + This of course overwrites anything there so make sure that you don't have the same folder in both datacommon and regular data
    + Note that there are 3 exceptions to this folder mounting rule:
    1 )Android
    2) lost+found
    + The reasoning should be obvious - lost+found isn't something you should need to mess with and Android is for regular data partition only - that's OS specific and should be on separate slots

Flashing Instructions
  • You MUST be booted into TWRP already when flashing this zip. You can grab a bootable twrp img from here
  • Since this modifies data - the zip CANNOT be on sdcard or data at all.
    - If you flash from data, the zip will copy itself to /tmp and instruct you to flash it from there
    - You could do the above or copy it to a place like /dev or /tmp and flash it from there
    - Alternatively, you can adb sideload it
  • Read through ALL the prompts - there's lots of options
  • Note that if you change partition layout, THIS WILL WIPE ALL DATA INCLUDING INTERNAL STORAGE

How to Flash Roms - If you're NOT stock layout
  • Nothing changes here except ONLY FLASH IN TWRP
    - Roms always flash to the opposite slot. Keep that in mind and you'll be fine
    - So don't take an OTA while booted - boot into twrp, switch slots, reboot into twrp, flash rom
  • Normal flash procedure:
    1) Boot into twrp
    2) reboot into twrp selecting slot you do NOT want rom installed to
    3) Flash rom
    4) Flash this zip
    5) Reboot into twrp
    6) Flash everything else

Help! I Can't Boot!
  • Usually this is because you switched roms without formatting data first. This should be flashing 101 but we all forget sometimes. Plus this slot stuff can get confusing
  • If it only happens with a/b/c and not any other layout, there's a good chance it's selinux related. Try setting selinux to permissive at kernel level with this mod(source here). If this doesn't fix it, it could be because selinux can't be set to enforcing even with the mod depending on the rom

How to Manually Repartition Back to Stock
In the event any step in the repartioning fails, the entire installer aborts. The good news is that this prevents a potential brick. The bad is that you need to manually revert back. See the README on github for the procedure. Note that if the install went fine and you want to switch back to stock later, just flash the installer again and choose stock layout

Limitation
If you set a password, regardless of encryption status, it'll corrupt the other slot if it's also password protected.
Either don't use a password on one slot, or leave one slot (I'll use 'a' in this example) unencrypted and:
  • Setup rom, password, and everything on slot a
  • Boot back into twrp, choose common data as storage, and backup userdata (if not using a/b/c layout, backup TWRP folder to your computer)
  • Setup rom, password, and everything on the other slot (b)
  • Boot back into twrp, switch back to slot a (reboot back into twrp), and restore the twrp backup
If you messed this up and are unencrypted - delete the /data/system/locksettings.db file
If you messed this up and are encrypted - you lost the data on that slot:[LIST][*]Unmount metadata in twrp gui[*]Format metadata with this command:
Code:
mke2fs -t ext4 -b 4096 /dev/block/sda$metadata_partnum
where metadata_partnum is the partition number of the current metadata partition (you can find this with
Code:
sgdisk /dev/block/sda --print
). DO NOT FORGET THE PARTITION NUMBER. If you do, you'll format all of sda which results in a brick[*]Reboot into twrp and format data in gui

Download

Source Code

Credits
  • Mauronofrio
  • Teamwin
  • CosmicDan
  • TopJohnWu
The Following 50 Users Say Thank You to Zackptg5 For This Useful Post: [ View ]
14th March 2020, 07:22 PM |#2  
osm0sis's Avatar
Recognized Developer / Recognized Contributor
Flag Halifax
Thanks Meter: 31,002
 
Donate to Me
More
Very ****ing badass. 🤘
The Following 11 Users Say Thank You to osm0sis For This Useful Post: [ View ]
14th March 2020, 07:30 PM |#3  
Senior Member
Flag Mississauga
Thanks Meter: 144
 
Donate to Me
More
Wow, this is cool. Always wondered if something like this would be possible on AB partitioned devices.

Looking forward to testing it out
The Following 3 Users Say Thank You to NateDev For This Useful Post: [ View ] Gift NateDev Ad-Free
14th March 2020, 08:13 PM |#4  
Senior Member
Thanks Meter: 72
 
More
Does the dual boot mean I can boot two roms?
14th March 2020, 09:08 PM |#5  
Zackptg5's Avatar
OP Recognized Developer
Thanks Meter: 6,435
 
Donate to Me
More
Quote:
Originally Posted by jaggillararla

Does the dual boot mean I can boot two roms?

Ya. You can have a different rom on each slot
The Following User Says Thank You to Zackptg5 For This Useful Post: [ View ]
15th March 2020, 12:31 AM |#6  
Will it impact on my original data partition if I flashed this TWRP.( I means whether my original data being splitted into 2-individual-parition + 1-common-partition and I need to reinstall my data after entering system ?)
15th March 2020, 01:44 AM |#7  
Zackptg5's Avatar
OP Recognized Developer
Thanks Meter: 6,435
 
Donate to Me
More
Quote:
Originally Posted by Kris Chen

Will it impact on my original data partition if I flashed this TWRP.( I means whether my original data being splitted into 2-individual-parition + 1-common-partition and I need to reinstall my data after entering system ?)

The installer will tell you if it'll wipe internal storage or not.
Basically, if you choose to change the partition layout, data will all be wiped since it'll be repartitioned. If you choose to keep your partition layout at the beginning of the install, your data will be fine.
You could just use this zip as twrp, magisk, verity/fec modifer/installer to save you the extra steps and keep with stock layout
The Following 3 Users Say Thank You to Zackptg5 For This Useful Post: [ View ]
15th March 2020, 03:01 AM |#8  
Senior Member
Thanks Meter: 424
 
More
This is super cool. Will be testing soon. Just to confirm, this means I can have a custom rom on one slot and oxygen os on the other? Also f2fs should work fine with common data right?
15th March 2020, 03:36 AM |#9  
Zackptg5's Avatar
OP Recognized Developer
Thanks Meter: 6,435
 
Donate to Me
More
Quote:
Originally Posted by f41lbl0g

This is super cool. Will be testing soon. Just to confirm, this means I can have a custom rom on one slot and oxygen os on the other? Also f2fs should work fine with common data right?

Yup. You can do whatever you want with either slot. This mod formats all data partitions as ext4 since that's what oneplus does. You can always reformat userdata to f2fs in twrp gui later if you want though. Same goes for common data although I don't think there's a gui option for that
The Following User Says Thank You to Zackptg5 For This Useful Post: [ View ]
15th March 2020, 08:43 AM |#10  
How does this zip to allocate the each size of userdata ? Can be customized by ourself or automated by zip itself ?
15th March 2020, 11:16 AM |#11  
Senior Member
Thanks Meter: 424
 
More
Quote:
Originally Posted by Kris Chen

How does this zip to allocate the each size of userdata ? Can be customized by ourself or automated by zip itself ?

From what I see it can not be customized through the flasher (may be possible by editing values in the zip). In case you were wondering the size of the partitions, they are 96.7gb for the common storage and 62.4gb each for the individual storages.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes