In this guide, I’ll be showing you how to root your Samsung Galaxy M31 using Magisk. I’ll be providing two methods – one with TWRP recovery and one without TWRP recovery. By rooting your phone, you’ll be able to customize the software even further and remove any system apps you don’t want.
Additionally, rooting can also improve device performance by increasing RAM usage and overclocking the CPU frequency.

Install TWRP on Samsung M31
TWRP, or Team Win Recovery Project, is a custom recovery tool that allows you to flash custom ROMs, create full phone backups, and gives you a lot more options than the default recovery. With TWRP, you can reboot into the system, bootloader, or download mode, among other things.
If you want to learn more about installing TWRP on your Samsung Galaxy M31, please follow the link provided for the full installation guide.
Root Samsung Galaxy M31 with TWRP and Magisk
If you install a custom recovery such as TWRP, OrangeFox, or SHRP on your phone, you can easily root it with Magisk. To do this, simply follow the steps to install Magisk on your phone using TWRP recovery.
- Download Magisk Zip file and keep on internal storage.
- Reboot your phone to TWRP recovery mode. (Press Bixby, Volume Up and Power Button)
- Press install button on TWRP recovery.

- Select your downloaded Magisk Zip file.

- After select the file swipe to flash.

- After successfully flash reboot phone to system.

- After phone restart you found new Magisk App.

Root Samsung Galaxy M31 without TWRP
I’ve also included an option for rooting your Samsung Galaxy M31 without TWRP recovery, as not everyone may have access to TWRP for their device. Regardless of which method you choose, it’s important to follow each step carefully. Below, I’ve provided a step-by-step guide for both options, so be sure to follow it closely.
Unlock Developer Options on Samsung Galaxy M31
- Go to Phone Settings on your Samsung Galaxy M31.
- Scroll down and select About phone.
- Next, select Software information.
- Tap on the Build number multiple times.
- Enter your phone’s lock screen Password.
- You will now see the “Developer mode has been enabled!” toast message on the phone screen.
Enable is the OEM unlocking option on Samsung Galaxy M31
- Go to Phone Settings on your Samsung Galaxy M31.
- Scroll down and select Developer options.
- Toggle ON the OEM unlocking option.

Download Stock Firmware for Samsung Galaxy M31
You need a Samsung Galaxy M31 stock firmware, you can download from Samsung.com,
You need first your phone’s model number and second, and CSC/regional code.
- You can get your phone model number by going to Settings → About phone.
Download LZ4
- Download LZ4
- Extract Downloaded LZ4 File
Preparing Patched Boot Image file
- Extract the firmware package.
- Open the extracted folder and again Extract AP firmware file.

- Now you will find boot.img.lz4 file.

- Copy boot.img.lz4 to LZ4 Installed folder.

Next, we have to convert .img.lz4 to .img file.
- Open the lz4 extracted folder.
- Drag the boot.img.lz4 file to the lz4.exe program.

- This step converts the file to .img format.
Patch the boot.img Firmware File with Magisk App
- Download and install Magisk App on your phone.
- Open the Magisk App.
- Tap on the INSTALL button.

- Then Select and Patch a File.
- Choose the Boot.IMG File

- Once the file is selected, tap on LET’S GO.
- The patched file can be found in the Downloads folder.
- Connect your phone to the PC and copy the magisk_patched.img file on your PC.
Convert .IMG File to .TAR (For ODIN)
- Download and Install 1st 7zip software in your PC.
- Select magisk_patched.img and right click mouse and point to 7zip > Add to archive.

- Archive formats select tar and click OK.

- Finally, we are building the magisk-patched.tar file for ODIN (AP)
Boot your Samsung Galaxy M31 into Download Mode
- First, power off your phone.
- Connect your phone to your PC while holding the Volume Down and Power keys together.
- You will now see the Bootloader warning screen.
- Keep pressing more than 7 second volume up key to unlock bootloader.
- If you unlock already bootloader just press one time volume up key.
- Following this method, you will enter to downloader mode.

Flash Magisk_Patched.tar using Odin flash tool.
- Run Odin Tool.
- Connect your Samsung Galaxy M31 device to a PC/Laptop.
- You will see ID:COM section light up blue. It means the port is working.

- BL: Select the firmware file starting BL.
- AP: Select the Magisk Patched AP firmware file (magisk_patched.tar)
- CP: Select the firmware file starting CP.
- CSC: Select the firmware file starting HOME_CSC.

- Once done, click Start to begin the flashing process.
- The first boot will take some time.
After you’ve successfully rooted your Samsung Galaxy M31 using Magisk, you should see the Magisk app installed on your phone. This app will help you manage the root permissions on your device, allowing you to grant or deny access to root for specific apps. Remember to always be cautious when granting root access, as it can potentially harm your device if not done properly. With that said, enjoy your newly rooted device and all the customization possibilities it brings!
You converted the LZ4 into img file. But what did you do with it later? You haven’t used that at all…
I’m not understand, but when drag the boot.img.lz4 file to the lz4.exe program you get the boot.img file after that patch the boot.img file using magisk apk and use 7zip tool to make boot.tar file now odin support the .tar file select in ap in odin and flash.