Installing Magisk on Android 11 for root control on Raspberry Pi
Rooting your device enables the use of important tools such as firewalls. However, access to root must be managed to avoid allowing untrustworthy apps or software that is ingested by otherwise trustworthy apps to take control of your system.
Because of this, root management is required. Several programs have been used over the years to manage root on Android. The ideal root management program is secure, routinely updated, and open source.
|SuperSU||This formerly open source root management program was the standard for years. Unfortunately, it is now closed-source software and therefore should not be allowed to control this most sensitive device configuration.|
|LineageOS root management||The LineageOS team developed its own root management system which is open source and works well. Unfortunately, Google changed the architecture of Android 10 (and up) so that LineageOS Privacy Guard and root control (which is closely related) could no longer be made to function (additional link).|
|Magisk||The death of LineageOS Privacy Guard made Magisk the de-facto open source root management solution for Android 10 and up. Magisk is also capable of performing various other tasks.|
As of today, Magisk remains the best available root management software for Android 10 and up.
These instructions are based on those written by rsaxvc, but provide more detail and fill in some gaps. This guide assumes that you have a computer that runs Linux.
|Linux computer with a microSD card reader|
|Mkbootimg and unpackbootimg|
|The Magisk app - currently on version 23.0|
Download and compile Mkbootimg and unpackbootimg. Lets assume that you have created a working directory called /workingdir
|Place a microSD card that already has Android installed in the reader and allow Linux to mount it. This guide will assume that the first partition on the card mounts to /mount/boot and that the fourth partition mounts to /mount/userdata.|
Use mkbootimg to create an artificial boot image that Magisk can later patch
|Unmount the microSD card, take the disk out of the reader and put it into the Raspberry Pi. Boot the Raspberry Pi.|
|Download the latest Magisk apk on your Pi and install it.|
Install magisk to the image using Install -> Select and Patch a File
There should be a new image called magisk_patched_(random text).img in the Download folder. Turn off the Raspberry Pi, remove the microSD card, and put it into your computer
Lets assume that your working directory is called /workingdir, the first (boot) partition of the microSD mounts as /mount/boot, and the fourth (userdata) partition mounts as /mount/userdata. Run the following commands
|Unmount the SD card, place it in the Raspberry Pi and boot|
|Load the magisk app. Configure the superuser settings as you wish.|