[Moto G5 Plus Guides, News, & Discussion] manos78:
Hi,

I present here my last guide for OTA upgrades with rooted devices, in this case with Magisk.

Previous similar work:

http://xdaforums.com/g5-plus/how-to/guide-simple-ota-update-rooted-unlocked-t3610895

http://xdaforums.com/moto-g4/how-to/guide-simple-ota-update-rooted-unlocked-t3510126

This guide is tested by me for an upgrade from NPNS25.137-33-5 to NPNS25.137-33-11 using the incremental OTA (the official upgrade you get in the smartphone). Please, note that this guide is for advanced users!

Starting point:

- STOCK ROM with an

untouched

SYSTEM partition.

- Flashed custom TWRP as recovery.

- Flashed custom kernel with

disabled

Data encryption enforcement.

- MagiskSU installed, and any other changes that you like (i.e. Xposed) but

all

Systemless.

- USB Debug mode enabled in Developer Options and access granted from your PC.

- One SD card with almost 16GB of size.

Warning: If you use PIN or any other lock procedure, I recommend to disable it before backups and enable after restore!

PROCEDURE:

Step 1:

Backup your SD-Internal (to PC or SD-CARD). This is required because the TWRP backup doesn't backup this data.

Step 2:

Reboot to TWRP, Make backup of "Data", "Logo" & "Boot" (you will restore them after the upgrade).

Step 3:

Reboot to Bootloader and flash

ORIGINAL

partitions "Recovery", "Logo" & "Boot" using a PC:

# fastboot flash logo logo.bin
# fastboot flash boot boot.img
# fastboot flash recovery recovery.img

Or if you have a TWRP backup of these patitions, then you could restore them from TWRP (instead of using a PC).

Note:

If you have modified SYSTEM and/or OEM partitions, then also flash them (or restore them from a TWRP backup):

# fastboot flash system system.img
# fastboot flash oem oem.img

Step 4:

Reboot.

Note: from this point your "Data" partition is now

fully encrypted

, so not execute any relevant command as you will

lose

any update when restore the "Data"

after

the OTA update. At this point you have the smartphone in "pure" Stock mode.

Step 5:

Go to check "System Updates", download the update & install the OTA (the device reboots).

Step 6:

After rebooting the OTA file is executed. If it ends with an "ERROR" message, then something is erroneous (check your partitions!).

If the device reboots without an error check your new firmware.

The upgrade is completed!

Step 7:

From this point you would like to restore your previous state: data, root, Magisk, etc.

If you like to save a TWRP backup of current partitions (for the next OTA upgrade) then do this:

- Reboot to bootloader mode and boot a non-flashable TWRP (like then Multi-ROM version: "fastboot boot mr-twrp-3.1.1-potter-20170521.img") and complete a backup of the new "Recovery", "Boot", "Logo", "System" & "Oem" partitions to the SDCard.

NOTE: The Multi-ROM TWRP can't backup/mount the OEM partition! Use another method or complete the backup after (you can backup SYSTEM and OEM after).

ALTERNATIVE: Open Terminal and do a manual dump of "Recovery", "Boot", "Logo" and/or "System", "OEM":

# dd if=/dev/block/bootdevice/by-name/recovery of=/external_sd/recovery.img
# dd if=/dev/block/bootdevice/by-name/boot of=/external_sd/boot.img
# dd if=/dev/block/bootdevice/by-name/logo of=/external_sd/logo.img

# dd if=/dev/block/bootdevice/by-name/system of=/external_sd/system.img
# dd if=/dev/block/bootdevice/by-name/oem of=/external_sd/oem.img

Step 8:

a) Restore or Flash a recent version of TWRP: "fastboot flash recovery twrp-3.1.1-4-GtrCraft.img" (this version has support for backup/restore OEM!)

b) Reboot to the TWRP recovery and inside it...

c) I recommend first to make now a backup of SYSTEM and OEM paritions (for the next OTA).

d) Format your "Data" partion with "f2fs".

e) Restore your "Data" (and "Logo" & "Cache") from the backup at step #2.

f) Install the ZIP of your custom kernel (or as alternative apply "disable dm-verity").

g) Install the ZIP of Magisk for root.

Step 9:

Re-boot an enjoy your upgraded system!

Remeber to restore your Internal SD card data (from the step #1).

Enable your preferable security option.

:victory: