[Huawei P20 Pro Guides, News, & Discussion] a500user2013:
P20 Pro with EMUI 9.1 (9.1.0.381 c782e11r1p11 clt-l29) and root!! But it only lasts until a reboot according to Magisk

Note with the latest Magisk I still cannot get root to persist after a reboot. (v20.4 20400)

Rooting without TWRP Recovery

Terms

Recovery Image= an image which runs on your phone to facilitate recovery, we are looking to patch it with a magisk binary

Stock Firmware = the OS installed on your phone by the manufacturer/network operator (branding). We aren't looking to replace this, but we do need to extract a file from the version you currently have

Stock Recovery = the recovery image installed with the P20 'eRecovery'

Recovery RAMdisk - This is where the recovery image is flashed. Alternative locations are the bootloader or the recovery partition. None of these work with EMUI 9.1

Commands are in italics

Prerequisites

adb binary

fastboot binary

Phone is backed up (unlocking the bootloader will factory reset and erase all data/apps)

Phone is plugged in and showing with 'adb devices'

You have a bootloader code

0. Unlock your bootloader

adb reboot bootloader

Once in fastboot mode type

fastboot oem unlock <unlock code>

Let the process finish.

1. Extract stock recovery image (RECOVERY_RAMDIS.img) from the Stock Firmware using Huawei Update Extractor

Get Stock Firmware for your version from :https://pro-teammt.ru/en/online-firmware-database/

Get Huawei Update Extractor from https://xdaforums.com/showthread.php?t=2433454

Get the RECOVERY_RAMDIS.img file using these instructions https://www.theandroidsoul.com/extract-huawei-firmware-update-app

Rename the RECOVERY_RAMDIS.img file something logical based on your EMUI version e.g. I've renamed mine RECOVERY_RAMDIS_9_1_0_381_STOCK.img

2. Using Magisk Manager app, patch the stock recovery image extracted in Step 1

Get Magisk Manager and install the APK (IT's NOT on the Play Store (despite being called the same name)

Magisk Manager is available here. I would suggest installing a stable version or you maybe risking a boot loop.

https://xdaforums.com/apps/magisk/official-magisk-v7-universal-systemless-t3473445

https://xdaforums.com/apps/magisk/dev-magisk-canary-channel-bleeding-edge-t3839337

or google for it. This forum blocks the URL for some reason.

Once you have installed the APK...

Tap 'Install' next to 'Magisk is not installed' .

Tap 'Install' again

Tap 'Select and Patch a File', then choose the file RECOVERY_RAMDIS_9_1_0_381_STOCK.img (or whatever you called it)

3. Copy the patched recovery image file Magisk just created to your PC

(Magisk will tell you where it put it, generally in your 'Downloads' folder)

4. Flash the Patched Recovery Image using fastboot mode

Note not possible to flash the boot or recovery with Magisk/TWP on EMUI 9+ you have to flash recovery_ramdisk

adb reboot bootloader

fastboot flash recovery_ramdisk RECOVERY_RAMDIS_9_1_0_381_PATCHED.img

(replace RECOVERY_RAMDIS_9_1_0_381_PATCHED.img file with whatever you called it)

NOW read step 5. Get ready and then...

fastboot reboot

5.This step is very important l!

As soon as you issue the reboot command and the screen goes blank, you will need to press and hold volume up and power buttons simultaneously for a few seconds.

When you're doing this, unplug the USB cable. As soon as you see the Huawei logo, release BOTH keys

You will see the unlock warning, but if you did it right, you will not see instructions on the screen telling you what to press to continue etc

If you see instructions telling you to press a key combination to continue, you didn't do it right and will need to start again at step 4 after the phone reboots.

6. Check Root with Magisk Manager/Another root tool

TWRP

You can also flash TWRP using the version at https://dl.twrp.me/charlotte/ or

Alternative: Install Magisk from TWRP? search google for "install-twrp-recovery-root-huawei-p20-pro" to find a link from the custom droid

Just replace the file in step 4 with the .img file from that URL

You can only flash TWRP or MAGISK. I've not been able to load the Magisk (optained from the Magisk Manager) through TWRP as the internal storage is not accessible

and OTG storage doesn't seem to be accessible either.

I am not 100% sure how this works as magisk occupies the recovery_ramdisk just like twrp:

Connect your phone to the PC (while it’s in TWRP) mode.

In TWRP, go to ‘Advanced’ and enable ‘ADB Sideload’.

Then, enter the following command on PC: adb sideload Magisk-v20.3.zip

Boot Lockup

If you experience a boot lockup (especially when trying to boot to recovery with power + vol up) you can do an adb reboot and boot with holding vol up

This will open EMUI erecovery and you can then choose reboot to boot normally to the system.