[Magisk] Root for the Galaxy S10 Series

Search This thread

topjohnwu

Senior Recognized Developer / Inactive RC
Jan 31, 2012
1,849
61,320
Taipei
Here comes official Magisk support for the Galaxy S10!
Let's get Magisk to kick start the development of these Samsung devices!

Link to Instructions
Carefully read through everything in the page linked above! Follow the instructions closely so you don't end up bricking your device

Technical Details
Google enforces all devices that ships with Android 9.0 to use system-as-root in part of "Project Treble", so Samsung finally introduced their own "flavor" of the implementation. More details regarding system-as-root can be found in the official Google dev site. Samsung is using the A-only system-as-root setup, meaning that its boot image will only contain the kernel binary without ramdisk included. Similar setup has already been deployed on many new devices, and the solutions for those devices are rather simple: add a new ramdisk section into the boot image and hexpatch the kernel to always use ramdisk as rootfs. However in Samsung's case, the bootloader simply does not load anything other than the kernel binary to the memory, meaning no matter what we do the kernel will always use the system partition as root directory. This leaves us no option but to install Magisk onto the recovery partition.

Installing to the recovery partition have its own issues: first is that a service called "flash_recovery" will run when the system starts up, which will restore the recovery image back to stock on startup. This is unacceptable because not only does it uninstall Magisk in the process, the data encryption key will also be changed due to fact that Samsung's data encryption keys are tied to the bootloader status and boot/recovery image signatures, and thus causing the device unable to boot in following reboots unless factory reset. The solution to this problem is to simply repack the boot image to remove the binary integrity and also the signature of the partition. The second issue is that since Magisk and recovery shares the same partition, how can we actually boot into recovery? (e.g. to factory reset your device, or have custom recovery co-exist with Magisk) Fortunately a solution that detects button key presses is introduced, which details are already provided in instructions.

To make matters even worse, Samsung introduced a "VaultKeeper" service, which adds another "lock" on top of the OEM lock of the bootloader. By default the service will "relock" the bootloader after data is wiped. Only after the initial setup will it verify the OEM lock option and changes the bootloader state accordingly. If you are running custom firmware with stock system, DO NOT try to wipe data or else you might end up bricking your device due to vaultkeeper locking your bootloader up, which will eventually lead to bootloader refusing to boot because unofficial partitions are detected.

For custom ROM developers, the first few things you would want to remove is VaultKeeper to protect your users from bricking their devices. For stock ROM users, just make sure to always boot to Magisk after a data wipe, or never power off your device before finishing the initial setup and verify OEM lock is enabled.
 
Last edited:

chronzz

Senior Member
Yay.
 

Attachments

  • D3gYPjDUEAAvQJ9.jpg
    D3gYPjDUEAAvQJ9.jpg
    138.6 KB · Views: 42,279
Last edited:
  • Like
Reactions: origold and Enddo

pug1

Senior Member
Jun 16, 2012
647
192
Sheffield
Can I ask, when we install Magisk what sammy stuff will be broken? I understand Knox will be tripped but what 'features' will still be available.

Does the fingerprint still work for instance

Amazing work though, well done buddy
 
  • Like
Reactions: memocatcher

ooonea

Senior Member
Apr 19, 2015
68
21
Siena
S9 Exynos not install

On S9 the installation does not give error, but on restart Magisk is no longer installed.
 

baz1

Member
Oct 14, 2011
48
11
A couple of questions:
1. What will happen if I boot from boot partition after installing magisk? What steps will be needed to recover from that?
2. Why final wipe after installing magisk is needed?
 

Dark_Lion64

Member
Feb 2, 2014
11
2
I got some questions about Safetynet

1. Is Safetynet still passing with this method when you boot to system with magisk?
2. Also if you boot to system without pressing any button, so system without magisk, is Safetynet passing or failing?

Thanks for your hard work. :)
 

Top Liked Posts

  • There are no posts matching your filters.
  • 2
    i was asking about the simple reboot (not to bootloader or recovery). i read it needs a combo to be performed, correct?
    If Magisk is installed in recovery, then to reboot Android and have Magisk active you go through the motions of booting to recovery -- to run the code in which Magisk has been embedded -- but you need to release the buttons at the right time, so that when Magisk "becomes aware" and checks the button status, it will conclude that you are no longer holding down the buttons, and so it will choose to boot the Android system. (If Magisk decides that you are still holding down the buttons, Magisk will turn control over to the "recovery".)

    Having said all that, I will now tell you that after installing Magisk in the recovery of my SM-T290, and after booting many times until I hit that magic spot where I got the tablet to try to boot recovery, but I got Magisk to realize that I didn't really want recovery, so I got Android running with Magisk active -- since that time, I can shut down my tablet, and then reboot by holding the power button, and when Android boots, Magisk is active.

    I don't know if something special was done to Magisk between the time the installation instructions were written and the time I downloaded a copy of Magisk.apk. I don't know if different devices behave differently. As I said, I think I've seen people report being able to boot Android with Magisk active without the tricky key-combo-and-release dance. I tried to describe what I remember. I tried to describe where I probably read it.

    TL;DR The tricky key combo always works. The tricky key combo may not be necessary.
    2
    Hi Guys, I have S10 plus rooted via Odin3 for at least 3 years, everything was alright, safety net check, Magisk hide, etc.

    But unfortunately I ended up clicking up on the APP update button(only) and got the 25.2 version installed, the app worked well after that but then I realised that Magisk hide was gone on that version.

    After that, I pressed uninstall and then installed the version 23 with the same apk I had from the original root and now I can't make it work, even turning phone off, plugging the cable at my laptop and using holding bixby, vol down and power button as I used to do before.

    Did I **** the root somehow?

    Do I have to do all root process again?

    Am. I going to lose data?

    If a good soul can help me this would be much appreciated as I don't have much knowledge at this...

    Thank you 😊
    Yes, you screwed up something.
    You do not say what version of Magisk you had when everything was fine.

    You need to explain in detail how you tried to fix it: Did you still have the magisk-patched-AP.tar from 3 years ago? Is that what you flashed? Have there been any system updates during the 3 years?

    If, by uninstalling, you mean you uninstalled the Magisk Manager app and reinstalled the 3y old manager apk, you did not uninstall the Magisk embedded in your [boot, recovery, I don't know which]. I expect a new Magisk to be unhappy with an old manager.

    Please confirm that the updated Magisk was working fine before you tried to revert the update. Then explain exactly what you did to revert.

    Maybe hold off on trying the next six random things that pop into your head until someone has a chance to advise you.

    I think it would be safe to see if adb can recognize your device, and if adb shell gives you the ability to list ("ls") any files.
    1
    I've lost track of what you've been told. You need to read a substantial amount of this and other threads. What I've seen was probably in the T290 and T295 threads, but I'm not sure.

    I think some people said using adb to boot to recovery triggers Magisk.

    It might be that having a USB cord plugged into the device (not necessarily connected to a PC) helped.

    The most useful thing would be learning what signal to respond to by releasing the buttons. It's not random, and somebody described it well enough for me to do it.

    What kind of reboot are you talking about? If from a running system with Magisk, there's an option in the Manager to reboot -- that ends with Magisk again. If Magisk is not active, maybe there's a "boot to recovery" option in the Power menu. (Maybe there's a Developer option that adds Recovery to the power menu.

    Mostly, you have to read a lot and try a lot of things.

    Do you expect to have to reboot a lot?
    1
    Sorry, I forgot to give more details...

    I had Magisk 23 and everything was fine, then I hit the update button at the APP section only and installed the version 25.2, after the update the root was still working with the root at version 23 and app at 25.2, but as I mentioned, I realised the version 25.2 doesn't have magisk hide and decided to install 23 again😅.


    Then I went to the app and pressed uninstall/restore image and then complete uninstall. After that I went to the 23 version apk and installed it again but now the root is gone.

    I still got the "AP_G975FXXSBFUF3_CL21644994_QB41014117_REV01_user_low_ship_meta_OS11.tar.md5"
    In my ad card and all files I have used to root it 3y ago and I have never updated the phone.

    Thanks mate.
    Now you say "the root is gone". Does that mean Android boots fine but you no longer have Magisk installed?

    That makes sense, you hit "uninstall / restore images".

    I don't know if you are going to lose your data. Back up what you can, or what you care about.

    If you really have all the files from 3y ago -- AP, BL, CP, CSC, magisk-patched.tar -- the easiest thing to try is run Odin, giving it magisk-patched.tar, BL, CP, and one of the CSCs. Please READ SOMEWHERE ELSE to figure out which CSC will NOT wipe your data -- I don't trust my memory.

    With luck, that will put you back where you were.

    A lot of things can go wrong. Some versions of Magisk downloaded the latest as part of the "more setup", you have to set the update channel in the manager, and for a "custom" version -- meaning not the current version -- you need a URL to a JSON file that then points to the right archived files. I think more recent versions of Magisk are self-contained, but I don't remember the version number.

    Maybe disable your internet connection before booting to download mode to run Odin.

    Maybe wait to hear from someone who has done this more recently than I have.
  • 246
    Here comes official Magisk support for the Galaxy S10!
    Let's get Magisk to kick start the development of these Samsung devices!

    Link to Instructions
    Carefully read through everything in the page linked above! Follow the instructions closely so you don't end up bricking your device

    Technical Details
    Google enforces all devices that ships with Android 9.0 to use system-as-root in part of "Project Treble", so Samsung finally introduced their own "flavor" of the implementation. More details regarding system-as-root can be found in the official Google dev site. Samsung is using the A-only system-as-root setup, meaning that its boot image will only contain the kernel binary without ramdisk included. Similar setup has already been deployed on many new devices, and the solutions for those devices are rather simple: add a new ramdisk section into the boot image and hexpatch the kernel to always use ramdisk as rootfs. However in Samsung's case, the bootloader simply does not load anything other than the kernel binary to the memory, meaning no matter what we do the kernel will always use the system partition as root directory. This leaves us no option but to install Magisk onto the recovery partition.

    Installing to the recovery partition have its own issues: first is that a service called "flash_recovery" will run when the system starts up, which will restore the recovery image back to stock on startup. This is unacceptable because not only does it uninstall Magisk in the process, the data encryption key will also be changed due to fact that Samsung's data encryption keys are tied to the bootloader status and boot/recovery image signatures, and thus causing the device unable to boot in following reboots unless factory reset. The solution to this problem is to simply repack the boot image to remove the binary integrity and also the signature of the partition. The second issue is that since Magisk and recovery shares the same partition, how can we actually boot into recovery? (e.g. to factory reset your device, or have custom recovery co-exist with Magisk) Fortunately a solution that detects button key presses is introduced, which details are already provided in instructions.

    To make matters even worse, Samsung introduced a "VaultKeeper" service, which adds another "lock" on top of the OEM lock of the bootloader. By default the service will "relock" the bootloader after data is wiped. Only after the initial setup will it verify the OEM lock option and changes the bootloader state accordingly. If you are running custom firmware with stock system, DO NOT try to wipe data or else you might end up bricking your device due to vaultkeeper locking your bootloader up, which will eventually lead to bootloader refusing to boot because unofficial partitions are detected.

    For custom ROM developers, the first few things you would want to remove is VaultKeeper to protect your users from bricking their devices. For stock ROM users, just make sure to always boot to Magisk after a data wipe, or never power off your device before finishing the initial setup and verify OEM lock is enabled.
    21
    OK guys, @PillowCake[/MENTI[SIZE="3"][/SIZE]ON] [MENTION=5902940]bininga59 @Norup58
    In the interests of accuracy for everyone, afterall this what XDA is all about isn't it, I am scrubbing previous post and re-worded a new one.

    ---------- Post added at 06:24 PM ---------- Previous post was at 06:14 PM ----------

    Firmware updates and keeping your data,
    for phones Magisk rooted without TWRP.

    Just download new firmware, copy the AP file of the new firmware to your phone.
    Open Magisk Manager, ensure Magisk is up to date, if not, update it.
    When Magisk is up to date, if you have any Magisk Modules running, go into Modules and disable them (no need to uninstall them). Then reboot and go back into Magisk Manager.
    Hit the top INSTALL, select INSTALL again then select 'Select and Patch a File'
    Locate the new AP file from your new firmware and patch it. Then copy the magisk_patched.tar back to your computer, preferably with ADB to minimize corruption during transfer.
    Power off phone and reboot to Download mode.
    Open Odin 3.13.1 on your computer, and
    deselect Reboot under Options tab. Now use the new magisk_patched file in the AP slot, the BL and CP from your new firmware into their respective slots and importantly HOME_CSC into the CSC slot. Press start and let Odin do it's stuff.

    When flashed, do not wipe. Press and hold Vol-down and Power, when screen goes off, quickly change to Vol-up, Bixby button and Power. As soon as screen appears, let go of all buttons.
    Within moments without any further user intervention your phone will reboot into your updated Magisk rooted mode, data intact.
    Just re-enable your previously disabled Magisk modules.
    16
    Hi guys!!
    Got a S10, rooted with magisk, no TWRP installed.
    I want to update to the latest Firmware with magisk, but without wipe everything , is it possible?
    What are the steps please?

    Galaxy S10 Firmware update.
    The Galaxy S10 May firmware update has started to appear and users will be wanting to update their firmware without losing their data and keep their Magisk root.

    For phones with Magisk root only without TWRP.
    The process is similar to when you first rooted your phone but you need all the firmware files and DO NOT wipe.
    Download your new firmwware using Frija or Samfirm, making absolutely sure it is the correct version for your phone model and region (csc), you can use an app such as 'Phone INFO' to help here.
    Unzip the downloaded file to an easy place to find on your computer.
    From this unzipped folder locate the file name beginning AP and copy this file to your phone.
    On your phone open Magisk Manager and hit INSTALL against Magisk, prompt will come up, hit INSTALL, Select Method - Select and Patch a File, then choose the AP file you have just copied to your phone. Let Magisk process complete.
    Copy the new magisk_patched file on your phone back to your computer, preferably the same folder you copied the AP from.
    Open Odin (use Odin3_v3.13.1) On Odin Option tab untick Auto Reboot.
    Power off your phone and connect it to your computer. Press and hold volume-down until Download screen appears then volume-up to continue. On Odin the box below ID:COM should turn blue.
    For the AP option select the magisk_patched file, then select the BL file and the CP file, then the HOME_CSC file.
    Click Start and let the process complete - several minutes.
    Now the nimble fingers bit, remember NO WIPE. Press and hold Bixby button, (Bixby is superfluous but convenient at this first point) Vol-down and Power, when screen goes off, quickly change to Vol-up button whilst still holding Bixby and Power. As soon as screen appears, let go of all buttons.
    Your phone will now reboot into Magisk rooted mode with all your data intact.
    14
    Hi John (@topjohnwu),

    Great job with this find & guide for it. It works flawlessly if all the steps are followed 100%. Thanks!

    I've made a full video tutorial (including ROM downloading and everything), maybe it'll help others who have had problems or just want to see the process while or before they perform it.

    Feel free to post it in the OP if you think it helps in any way.

    The video link is as follows: https://youtu.be/o3a8YnWT3yk

    Thanks!
    12
    Last night, I used Magisk Manager to patch the AP file from the ASD5 firmware. This is actually the first time I have upgraded in this way, and I must say that John has made life extremely easy for all of us.

    I just wanted to give a tip for anyone who is already running TWRP on their device at the time they need to update their firmware.

    Using John's procedure, you'll have to enter download mode a second time to re-install TWRP and re-disable encryption. Since I screw up getting into download mode once in a while, I find it a nerve-racking experience, since failing to boot into download mode at this juncture could initiate a system reboot that would re-encrypt /data.

    So, before you flash the patched AP, you can make a copy of your existing Magisk-rooted TWRP recovery. For example, a quick way to do it is by typing this in a root shell:

    Code:
    # dd if=/dev/block/sda15 of=recovery.img

    Next, replace the stock recovery image in the AP file that you patched using Magisk Manager. On Linux, that would look something like this. Adapt these commands for whichever platform you use.

    Code:
    $ tar f magisk_patched.tar --delete recovery.img
    $ tar rf magisk_patched.tar recovery.img

    Now, when you flash the resulting file in Odin and reboot, all you have to do is hold the recovery combo down until you reach TWRP. Then, simply disable encryption again (e.g. by flashing my own multidisabler zip) and reboot.

    I followed the above procedure myself last night and it worked like a charm.