Following the great tutorial on magisk github trying to root a samsung phone, you will face the problem of samsung phones not being detected by fastboot.
Fastboot is the recommended method by magisk developers, but fastboot does not work with samsung devices.
On a standard e/os/ installation interact with the bootloader on samsung phones is only possible using odin or heimdall.
Heimdall is multiplatform and open source so in this Howto i will use it.
Get the boot.img file from the zip file containing the e/os/ build for your phone.
You can grab the zip file containing the right e/os/ build for your phone from
substituting yourphonename with (obviously) the name for your phone you can find on supported devices page. For example my S8+'s name is dream2lte so the builds page is
Follow the magisk tutorial “Getting started” section (ignore the specific samsung section, dedicated to samsung original firmware), until you will got a patched boot .img file.
Install heimdall (there are plenty of tutorials on the web, just search the right one for your OS).
Reboot in download mode.
heimdall print-pit --no-reboot > print-pit.txt
In print-pit.txt file search the right boot partition name, in my case it was like this:
— Entry #12 —
Binary Type: 0 (AP)
Device Type: 8 (Unknown)
Attributes: 5 (Read/Write)
Update Attributes: 1 (FOTA)
Partition Block Size/Offset: 14336
Partition Block Count: 10240
File Offset (Obsolete): 0
File Size (Obsolete): 0
Partition Name: BOOT
Flash Filename: boot.img
As root flash the boot image you previously patched with magisk app:
sudo heimdall flash --resume --BOOT magisk_patched-25200_XXXXX.img
Substitute “BOOT” with your boot partition name.
The --resume option is needed only if you previously used the --no-reboot flag printing PIT.
Note: on the latest version of heimdall sudo does not work, obtaining a root shell with su is needed.
Of course, adjust the .img file name.
I didn’t test flashing under Windows, anyway i suggest to use an elevated privileges command prompt or powershell.
Done, after flashing the system will reboot. Enjoy your rooted device.