[Android Software Development] Zackptg5:
Hi all!

For the past couple of months, I've been looking into making a more universal solution to disable dm-verity and forceencrypt. Needing to take different zips, modify them for different devices, and then cross your fingers when you switch between custom and stock roms simply wasn't good enough for me. After lots of searching around, failed attempts, and some guidance by [MENTION=7874870]Xennet[/MENTION], [MENTION=4544860]osm0sis[/MENTION], and [MENTION=6842057]nathanchance[/MENTION] (thank you all for your help), I finally got a working solution. Ironically, it was under my nose the whole time.

[MENTION=4470081]topjohnwu[/MENTION] figured much of this out a while ago with his magiskboot binary - just modify the fstabs. Magiskboot only works for fstabs in the ramdisk though and dm-verity and forceencrypt are only disabled under certain conditions (when you create a .magisk file with the variables set to false and place it in the proper location). So I made an installker with AK3 by [MENTION=4544860]osm0sis[/MENTION] and used a combination of sed patches by [MENTION=5672995]jcadduono[/MENTION] in addition to others I found for fstabs not in the ramdisk, modified magiskboot with some extra entries I found need to be removed on some devices, and added some stuff of my own like the creation of .magisk and .supersu files in the right location with the proper contents.

The end result: a zip that will remove dm-verity and/or forceencrypt from all fstabs on your device

It can also remove disk quota if you choose. This may be needed if you have an older twrp and/or want to downgrade to Nougat. More info here: https://source.android.com/devices/storage/faster-stats

Instructions:

The zipname tells the installer what to do. Here are the current options:

Add 'enfec' or en'forceencrypt' to zipname to keep forceencrypt enabled if present

Add 'fec' or 'forceencrypt' to zipname to disable forceencrypt (zipname already has this so remove these if you want to keep it enabled)

Add 'quota' to zipname to disable disc quota

Note that verity is always disabled - it has to be for any modifications with this mod

If you're currently encrypted:

BACKUP YOUR INTERNAL STORAGE TO YOUR PC

Format data (this is NOT the same as Wipe data) (In TWRP: Wipe -> Format Data)

Reboot back into recovery

Follow the directions below for when you're not encrypted

If you're not encrypted: flash all of your stuff, then

FLASH THIS ZIP LAST

Some extra details for Slot devices:

Flash ROM

Flash TWRP Installer Zip

Reboot into TWRP

Flash everything else

Flash this zip

Only difference here is the twrp zip and the recovery reboot, main principle is the same - FLASH THIS ZIP LAST

Troubleshooting:

Take a recovery log after flashing this zip (thanks to [MENTION=7285913]aIecxs[/MENTION] for the imgs):

If the zip isn't patching any fstabs that it should be, then it's possible that the previous zip(s) didn't unmount system and/or vendor properly. Either unmount them in twrp, or just reboot back into recovery and flash this zip again

Compatibility: Any android device

Source: https://github.com/Zackptg5/Disable_Dm-Verity_ForceEncrypt

Download