Lineage OS 18.1 root

Kim Il
3 min readApr 20, 2021

How to root LineageOS 18.1, as it is not pre-rooted anymore.

It has to be done with Magisk, the old super su does not work anymore.

So the first step is to download and install the latest Magisk apk:
https://github.com/topjohnwu/Magisk/releases

adb install Magisk-v22.1.apk

Start the Magisk app on your phone and then read which method you have to use, depending on your device:
https://topjohnwu.github.io/Magisk/install.html#patching-images

For in-depth info on how android boots on different devices, especially if you have Ramdisk: NO or SAR: NO or A/B: NO, then you should definitely read:
https://topjohnwu.github.io/Magisk/boot.html

I am doing this on a Sony Xperia 10 plus, so i need the boot.img file from the Lineage OS zip, for other models read the following carefully:
https://wiki.lineageos.org/extracting_blobs_from_zips.html#extracting-proprietary-blobs-from-payload-based-otas

I don’t have the Lineage zip anymore, start the download and make a coffee:
https://download.lineageos.org/mermaid

Unzip the lineage zip and get the boot.img:

❯ unzip lineage-18.1-20210414-nightly-mermaid-signed.zip 
Archive: lineage-18.1-20210414-nightly-mermaid-signed.zip
signed by SignApk
extracting: META-INF/com/android/metadata
extracting: care_map.pb
extracting: payload.bin <-- this is what contains the boot.img
extracting: payload_properties.txt
inflating: META-INF/com/android/otacert
❯ sudo pacman -S python-protobuf
❯ git clone https://github.com/LineageOS/scripts
❯ mkdir payload-bin
❯ python ./scripts/update-payload-extractor/extract.py payload.bin --output_dir ./payload-bin
Extracting boot
Extracting system
Extracting vendor
❯ la payload-bin
total 3862543
drwxr-xr-x 2 kim kim 3488 20. Apr 09:43 .
drwxr-xr-x 6 kim kim 3488 20. Apr 09:41 ..
-rw-r--r-- 1 kim kim 23384064 20. Apr 09:42 boot.img --> this
-rw-r--r-- 1 kim kim 3036676096 20. Apr 09:43 system.img
-rw-r--r-- 1 kim kim 891289600 20. Apr 09:43 vendor.img

Now that you have the boot.img you need to copy it to the phone and let Magisk patch it:

adb push payload-bin/boot.img /sdcard/Download/

In the Magisk app press Install — Select and Patch a File — Menu, Downloads — boot.img — Let’s Go

The Magisk app will patch the image to [Internal Storage]/Download/magisk_patched_[random_strings].img

The result should look like:

Flash the patched img:

❯ adb pull /sdcard/Download/magisk_patched-22100_fXXTr.img 
/sdcard/Download/magisk_patched-22100_fXXTr.img: 1 file pulled, 0 skipped. 22.8 MB/s (23672104 bytes in 0.990s)
❯ adb reboot bootloader
❯ fastboot devices
CQ3001WHMU fastboot
❯ fastboot flash boot ./magisk_patched-22100_fXXTr.img
Sending 'boot_a' (23117 KB) OKAY [ 0.591s]
Writing 'boot_a' OKAY [ 0.178s]
Finished. Total time: 0.792s
❯ fastboot reboot
Rebooting OKAY [ 0.000s]
Finished. Total time: 0.300s

Magisk should now show status ‘Installed’

Test if you can get root:

❯ adb shell 
shell@I4213:/ $ su
root@I4213:/ # id
uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0

Congratz

--

--