1

I have a Samsung S10 5G device that is actually a system-as-root device. I have rooted it by following the instructions given here.

As the system-as-root devices have no ramdisk in boot.img but in recovery.img so, I have to always boot the device with a recovery combination to get the root access.

Is there any way to achieve the root on a normal reboot?

I have a full ROM image of the device so, I believe there should be some way. Please share your thoughts.

2

If you go through How Magisk works and How to manually root a phone it would be easy for you to figure out why it's impossible to achieve what you are looking for.

init is the very first process started by kernel, which at its early stage sets SELinux enforcing (if it's not already enforcing). Before that happens, we need to modify SELinux policy so that it doesn't restrict the root daemon (magiskd) from running. Also init.rc needs to be patched to inject magiskd service.

A simple option is to patch /sepolicy and modify /init.rc when rooting the device and save the files on device. But on system-as-root devices both files are on system.img (and possibly vendor.img), not on boot.img. So modifying them would break "systemless" approach and other related things, in particular dm-verity and OTAs.

Another option is to run a process even before init which patches SELinux policy and changes init.rc on the go. And the easy way to achieve this is to replace original init file with Magisk init so that kernel executes the latter. However on SAR devices init is also on system.img, so we can't replace it. But we can always boot to recovery mode which does have a ramdisk where Magisk's init can be placed and executed before any other process. On A/B SAR devices recovery ramdisk is in boot.img, so Magisk always boots to recovery by forcing kernel to ignore skip_initramfs cmdline parameter received from bootloader.

Is there any way to achieve the root on a normal reboot?

On non-A/B SAR devices (like yours) there is no ramdisk in boot.img, so the only option to retain systemless approach is to place Magisk init in recovery ramdisk on recovery partition, and always boot to recovery mode. From there system.img is mounted at /system_root by Magisk init, contents of ramdisk are then copied to / cleaning everything previously existing, files are added / modified in rootfs /, /system_root/system is bind-mounted to /system, and finally [/system]/init is executed for normal boot.

However things have changed with Android 10, now system.img is mounted at / but the files to be added / modified like /init.rc and /sbin are overlaid with bind mounts as tweeted by Magisk developer.

| improve this answer | |
  • You have mentioned "So modifying them would break "systemless" approach and other related things, in particular dm-verity and OTAs." so, Is it possible to root the device with the system-modify approach, disabling dm-verity and not updating the device with OTA updates? – Vatish Sharma Nov 6 '19 at 4:52
  • @VatishSharma yes definitely possible but manually, no automated way. – Irfan Latif Nov 6 '19 at 10:27
  • Also, Is patching only Magisk policies on system.img is enough for service with Magisk context to work? – Vatish Sharma Nov 6 '19 at 12:10
  • Not enough. Do allow magisk * * * and allow * magisk * *. – Irfan Latif Nov 6 '19 at 13:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.