One of the side effects of switching to LineageOS 17.1 is that a different method for rooting the phone is required. The OS stores its updates at \data\lineageos_updates in the root directory. Since each update is of the order of 0.5 GB, these will eventually take up all of the available free space on the internal storage of the Moto G3. However, the amount of free space can be managed by deleting old updates or moving these onto the micro-SDcard. But, the file cleanup can only take place if the user has root access.
Previously, the LineageOS development team released the addonsu software package for rooting the phone. However, in developing LineageOS 17.1, the programmers were unable to port PrivacyGuard to the Android 10 code that forms the basis of the new software. PrivacyGuard had been used by the addonsu software package and its unavailability resulted in addonsu being discontinued. SuperSU, another rooting package I used previously, has not been recommended for use with LineageOS for some time. Consequently, the rooting software of choice at present appears to Magisk.
I found the primary instructions for using Magisk to be a little unclear. They indicate to run Magisk Manager and, if Ramdisk = Yes then a copy of boot.img is required “from official firmware packages or your custom ROM zip”. However, there was no further information as to how this image was to be extracted.
Fortunately, there is a second installation method using TWRP which, although not recommended, is available as legacy support. For me, the use of TWRP is preferable as I have used it successfully many times, both to create system backups and to flash custom-ROM’s.
This method also simplifies the process somewhat since the installation of MagiskManager is not actually required. Rather, just Magisk itself (i.e. the file Magisk-v21.3.zip) can be installed using TWRP.
The following steps can be used to root the Moto G3 smartphone with LineageOS 17.1 installed. (Note that the version number of the download was current at the time of writing.)
(1) Download Magisk-v21.3.zip from the Magisk v21.3 link on GitHub.
(2) Boot the Moto G3 into recovery mode
(3) Install the Magisk ZIP file
(4) Wipe Cache/Dalvik
(5) Select Reboot System
Run Root Checker Basic, grant SuperUser access, and verify that root access is enabled
LineageOS is dropping its own superuser implementation, making Magisk the de facto solution
Rooting the LineageOS 14.1 Custom ROM
Manually Updating LineageOS on a Moto G3 Smartphone
How to Install Magisk & Root with TWRP