yashsingh1/xdaforums huggingface dataset:
[Magisk] sidg2:
I have reflashed the stock RETAIL 7.0 Nougat March security patched Rom on my rooted Moto Z Play Nougat India. Then I also update to latest April security OTA update. But now even after a clean install of stock Nougat ROM and then update to latest April security, My SafetyNet failed. I got a red error like this " SafetyNet failed: CTS profile mismatch " "Basic Integrity: true".

I had used following these commands to reinstalled my stock nougat ROM:

fastboot oem fb_mode_set

fastboot flash partition gpt.bin

fastboot flash logo logo.bin

fastboot flash boot boot.img

fastboot flash recovery recovery.img

fastboot flash dsp adspso.bin

fastboot flash system system.img_sparsechunk.0

fastboot flash system system.img_sparsechunk.1

fastboot flash system system.img_sparsechunk.2

fastboot flash system system.img_sparsechunk.3

fastboot flash system system.img_sparsechunk.4

fastboot flash system system.img_sparsechunk.5

fastboot flash system system.img_sparsechunk.6

fastboot flash system system.img_sparsechunk.7

fastboot flash system system.img_sparsechunk.8

fastboot flash system system.img_sparsechunk.9

fastboot flash oem oem.img

fastboot erase cache

fastboot erase userdata

fastboot oem fb_mode_clear

fastboot reboot

I have not install any root, twrp, kernel or anything. It is totally stock, clean and fresh. Why I got SafetyNet Failed: CTS Mismatch error?
[Magisk] tag68:
[MENTION=8251837]sidg2[/MENTION], you crossposted this question in several threads, some not even related. Therefore I will not try to answer your question and hope, others behave the same way. It would have been timesaving for you, not to speak of others, if you were searching for the solution instead of writing posts.
[Magisk] ViperX85:
I'm on stock 7.0 reteu, english TWRP is installed and have SR3-SuperSU-v2.79 flashed.

How do I proceed to install magisk on my current setup?
[Magisk] tag68:
[MENTION=5137392]ViperX85[/MENTION]

Depends if you want Hide. If you just flash Magisk, you get Magisk on top of SuperSU. Fully functional except Hide.

For Magisk Hide to work you need to uninstall SuperSU (keep or reinstall f2fs fix when doing this), then flash Magisk.
[Magisk] yuridarian:
I'm on android 6.0.1. I had preveously installed the chinese twrp and superSU and the only way to make Magisk work was to completely restore the phone to factory by downloading a stock img and flashing it using RSD Lite.

After that, it worked just fine!

Thank you!!!
[Magisk] red_phase:
confused....what do we need to do? Steps 0 - 11 or Install F2FS & Steps 1-3 ?
[Magisk] Yousvel:
Go with step 1-3 after installing F2FS patched kernel.
[Magisk] red_phase:
did that. however i am getting "this device can't be trusted" and SafetyNet Failed:CTS profile mismatch...what to do?:confused:
[Magisk] tag68:
Did you enable Magisk Hide and Core Mode? Since Google did an update, Magisk 12 only works in core mode giving green SafetyNet. Current 13 beta is capable of running most modules while preserving SafetyNet validation, but I assume you installed the 12 release.
[Magisk] red_phase:
Yeah, with core mode i am getting green safetynet. :good:

---------- Post added at 05:33 AM ---------- Previous post was at 05:31 AM ----------

How to get rid of the "this device can't be trusted " screen that comes with every boot
[Magisk] tag68:
Easy way: Don't boot ;)
[Magisk] midhunmanohar:
I am running Lineage OS and when I tried to install Magisks, I find the Magisk folder in the root directory missing files mainly .core. So Magisks hide is not working. Does this mean f2fs fix is needed?

Resolved: I updated TWRP to latest version and installed Magisk latest Beta. Now SafetyNet is passing
[Magisk] gbdlin:
In which versions of stock rom do we need F2FS fixed kernel? Does official rom from some version have built in fix?
[Magisk] Fábio Ferreira:
Hello, I own the Chinese variant of the phone, and it fails the safetynet check right out of the box. Will this enable me to use pass the safetynet check?

The app for the check show the wrong model
[Magisk] razorsbk:
Question: If i'm on latest 7.1.1 august security patch, i can just flash twrp and then magisk and have a functional rooted phone, right ?
[Magisk] tag68:
Right. Magisk Hide won't work, and modules also won't work, as the loopback device is readonly for unknown reasons. As Hide does not work, SafetyNet will not pass. But root is said to be fine.

Disclaimer: My phone is not using 7.1.1 by now, this is what I read from others.

Remark: It is not necessary to flash TWRP, you could also just boot it.
[Magisk] razorsbk:
I just did that and root works properly. Thanks.
[Magisk] tag68:
Nearly don't dare to ask: Does anyone successfully use Magisk Hide and pass SafetyNet on a Moto Z Play with current a ROM? How?

My hope: FUSE is history with Oreo, SDcardFS is the new star. Does someone know if there is a good chance that f2fs will be fully working on Oreo, including that mount bind read/write being used by Magisk, on Moto devices, especially Moto Z Play? My fear: If that loopback problem was implemented by purpose, it may have been ported to SDcardFS by Motorola.

Another question: I'm still using 6.0.1 from 12/2016 with f2fs fix kernel with Magisk 12.0. Is it expected to be safe to update Magisk to a current version using the internal updater? This would help me passing SafetyNet I guess.
[Magisk] VR25:
THE OP HAS BEEN UPDATED

I don't use a stock ROM nor MagiskHide, but you can try the new guide.

Unsure about this

You're good, as long as it is version 14.0 (stable branch). Don't update to 14.3+.

Edit: the OP has been updated once again. It now includes a workaround to install/update modules from Magisk Manager without F2FS-patched kernel.
[Magisk] VR25:
The latest guide might be useful. O Magisk loopback já não será montado em modo "só de leitura".

It is possible to "bypass" the "loopback read-only" issue without a patched kernel. The OP has been updated.
[Magisk] tag68:
Although it is usually not being done, the cache partition is intended to be cleared nearly at any time. If something on Android is not working, one frequent question is "did you clear caches?"

What happens if caches get cleared? In case of working phone, but problems using Magisk: How easy is it to restore lost Magisk functionality afterwards?

Edit: another question, will moving the magisk img break Magisk update functionality?
[Magisk] VR25:
If /cache gets cleared, only Magisk core functions will remain intact. You would have to reinstall all modules. In order to avoid that, you can add the following "on boot auto-backup" command to the file attached to the OP -- "cp /cache /magisk_img /data". Should you lose the original img file, simply restore the backup & run "ln -s /cache/magisk_img /data/magisk.img" afterwards.

No, but don't forget to create the symlink (ln -s command above) after moving the file.
[Magisk] sam00561:
i need to get a working safety net but all this is rather confusing. On the nougat 7.0 rom i was just flashing magisk 14.0 and then the patched kernel and i had saety net passing green on both counts. but witht his rom after i flash the kernel and universal fix the safetynet passes fine but camera and torch are broken. I s there any easier way i tried to follow instructions in updated post but getting errors in terminal.
[Magisk] Chydzim:
Hello. I installed magisk 14 yesterday, and tried to install modules without twrp. I can't use modified kernel (android 7.1.1), and I thought the f2fs error is already gone in official kernel (I read somewhere on xda that mentioned error has been fixed by motorola), but it's not. "/magisk/.core/service.d or /sbin/.core/img/.core/service.d" doesn't even exist, and if I create it, copy .txt there and the reboot - all created folders are gone. What should I do?

*symlink works, but only until flashing new module from twrp/reboot
[Magisk] Sam_kaks:
I am having issues with the terminal command workaround solution in magisk 15.0. It was working perfectly till I was in magisk 14.5 (beta). Can you please help
[Magisk] VR25:
For recent Magisk versions, replace all instances of /data/magisk.img with /data/adb/magisk.img. I'll update the whole OP soon.
[Magisk] Sam_kaks:
Thank you so much - will wait for your OP update
[Magisk] Sam_kaks:
This is to confirm that your updated procedure in OP works for magisk 15.0. I am able to flash any modules from TWRP. It works like charm. Thanks!

However, direct flashing of modules from magisk doesn't work consistently across all modules, e.g., enable dose for gms was a success, universal deep buffer remover& greenify4magisk failed. i have to use the TWRP route.

I have copied the mk_magisk_merge.sh.txt in service.d folder and set the permission to 755. I hope I am not doing something wrong here.
[Magisk] VR25:
Thanks for reporting. I'll fix the "flashing from Magisk Manager is inconsistent" issue.

Next time I update the OP, the entire procedure will turn into a module. You'll simply have to flash it in TWRP and forget everything else. How does it sound?
[Magisk] Sam_kaks:
Fantastic ! eagerly waiting..
[Magisk] VR25:
[MENTION=6899694]Sam_kaks[/MENTION], the guide turned into a Magisk module -- currently awaiting repo aproval. Meanwhile, it can be downloaded from the OP.
[Magisk] MeNoNoob:
Can someone explain me what is thid module and how it works ? Didn't understand the OP :crying: sorry for my fool
[Magisk] Sam_kaks:
Thank you - m delighted. Will try it right away
[Magisk] madbat99:
For devices that have f2fs /data partition on stock (like moto devices) and cannot install magisk modules. Usually gives "failed to mount magisk_merge.img" or something like that. Usually you need a custom kernel (or at least patched boot.img) to work. This module appears to fix it.
[Magisk] Sam_kaks:
Flashed it via twrp. Once I rebooted, for some reasons all modules disappeared. Guess I am doing something wrong!

Tried re-installing modules from twrp. However once I rebooted there were no installed modules.

Then I attempted direct install from magisk - and was surprised to see busybox getting installed while others like Magisk4Greenify, Viper4Android and a few others failed. Logs attached for your reference.

In the meantime, I need your terminal commands which were in the OP. I didn't save it. If you can it would help. I am in magisk 15.1

Btw thanks for your effort. At least I am workable solution. And greetings for the new year! you rock!!
[Magisk] VR25:
The failure may actually make sense, since you already had almost everything set up by following the instructions given before the module came into existence.

Now, do the following to solve the problem:

Before continuing, note that all installed modules will be removed.

1. Boot in recovery

2. Using terminal or TWRP file manager, remove /data/magisk.img, /cache/magisk_img and /data/adb/magisk.img.

3. Install f2fs-loopback*.zip

4. Install your previously installed modules

See if that works and happy new year! ;)
[Magisk] Sam_kaks:
Dude it works!!

Dalvik and cache cleanup did the magic. Guess what this might be applicable for others also who were earlier using the terminal command workaround. If not a fresh magisk install do a dalvik and cache swip before installing f2fs module via TWRP.

Everything works like charm including direct flash from magisk.

---------- Post added at 09:41 PM ---------- Previous post was at 09:20 PM ----------

Everything works!
[Magisk] showlyshah:
Data/magisk.img mount failure on xt 1676 android nogut.. cant install from twrp. Tried removing magisk.img from data, adb , even tried reformatting cache partition. Using stock kernel.

Using magisk 15.1 and 15.2 manager
[Magisk] madbat99:
It moves magisk.img to cache partition, so probably shouldn't format /cache.

Could be Moto's particular use of f2fs. Just a guess.

"Can't install in twrp"? It fails? Details
[Magisk] showlyshah:
Twrp image
[Magisk] showlyshah:
Su and basic modules working.
[Magisk] showlyshah:
Cache details
[Magisk] VR25:
Try removing /data/magisk.img, /data/adb/magisk.img and /cache/magisk_img once again. If the problem persists, a recovery log would be very useful. -- Thanks

[Edit]

**2018.1.1 (201801010)**

- Auto-remove $IMG symlink before installing -- people who followed the manual workaround no longer need to do anything prior to installing

- Enhanced magisk_merge.img creation service

- Updated reference
[Magisk] showlyshah:
Tried new version too.. same error.. btw.. can u create a normal twrp flashable zip.. its ok if it trips safety net or ota.. but i just want magisk to work.

Below is recovery log.
[Magisk] VR25:
Try the attached zip.

Procedure

1. Install from TWRP

2. Reboot system

3. Run su -c cp /sdcard/make_magisk_merge.sh /sbin/.core/img/.core/service.d or copy the file manually

4. Run su -c chmod 755 /sbin/.core/img/.core/service.d/make_magisk_merge.sh or set permissions manually
[Magisk] madbat99:
You can take screenshots in twrp also. Power + volume down.
[Magisk] showlyshah:
I tried it..

1)Cleaned all magisk files ( using twrp uninstaller)

2) reboot recovery and installed magisk 15.2 ( latest)

3) reboot and manual copied the file and set permissions to 755.

4) reboot.. checked if file was there in services.d folder , and it was there.

5) installed two modules.. installation was successful..

6) rebooted and checked modules .. non found..

7) checked if the file was there in seevices.d folder.. it was not there..!!! And so back again to mount problem.

8)Then i manually coppied your service.sh file from your latest magisk module.. (2018.1.1) to the same service.d folder and set permissions to 755.

9) rebooted. Checked service.sh file.. its there

10) installed a module.. installation was successful.. but module is not shown in "installed modules"

11) rebooted.. checked modules.. non was there

12) checked service.sh file.. again.. its missing.

Something is deleting the service.sh file from service.d folder. I dont know what is it.

May be if i copy the file to init.d folder to try if it stick after reboot?

Btw.. magisk.img and magisk_merge.img was there in cache .. but it lost links after reboot.. because the file is missing.

I will try some way to make it stick with editing .rc files..

Btw.. thanks for the great idea.. we just have one more step to overcome.. make the service file stick after reboot and magisk upgrades.

I will try my best to help you.

---------- Post added at 11:52 PM ---------- Previous post was at 11:41 PM ----------

If we can add this script to init.qcom.post_boot.sh.. it will stick and activate soon after reboot.

( Just an idea, dont know how much it will work, but this is an old idea from sony xperia z2 ages.. when i and my friend jackos implimented it to enable qc.2 on sony z2)
[Magisk] Sam_kaks:
[MENTION=5228676]VR25[/MENTION] updated to magisk 15.2 using direct install from magisk.. All worked seamlessly with all modules intact. Thanks to your F2FS module!
[Magisk] VR25:
Unfortunately, that implemention won't work either. At this point, I think the issue is -- your TWRP itself may actually have the F2FS bug too! So, any modifications to magisk.img won't stick or won't work at all. You have to get a patched twrp.img. By the way, which device are you trying the workaround on?
[Magisk] showlyshah:
I am on moto g5 xt1676 cedric.

Ya.. there is no kernel with f2fs patch implimented.. so no go for this device so far. Btw.. i have lil knowledge in kernel things.. else i would have tried.. :laugh:
[Magisk] tag68:
Isn't it possible to do a batch/shell script which checks if the f2fs works as expected?

- Mount testf2fsvol

- Check if testtestf2fsvol exists

- Write something on testf2fsvol

- Read if the written data could be written

- unmount (and log result)

This could be executed manually from terminal after Android is started.

This could be executed manually from twrp.

This could be executed (and logging) while Magisk module is activated.

Good idea?
[Magisk] VR25:
# Prepare working directory
mkdir /data/f2fs_test 2>/dev/null

# Create EXT4 image
make_ext4fs -l 8M /data/f2fs_test.img

# Mount EXT4 image
mount /data/f2fs_test.img /data/f2fs_test

# Go to the working directory & test whether we have read-write access
cd /data/f2fs_test
touch 1 2 3
mkdir 1 2 3
mkdir -p 4/5/6
echo test >test
cat test # output must be "test"
ls # output must be a list of all files & folders above

# Perform one more test
rm -rf /data/f2fs_test/*
ls # output should be null

There you have it -- a rough draft, but it should get the job done for now.

Put the code into a file & run it as follows:

0. su

1. source /path/to/file

You could run the test more than once, but that's unnecessary.

For TWRP, the procedure is the same, except you don't need the "su" command there.
[Magisk] nicolap8:
Hi [MENTION=5228676]VR25[/MENTION],

here Moto G5 Plus, potter reteu, XT1685 with F2FS bug!

I've two problems:

- with my device Magisk 15.0+ doesn't work (break fingerprint reader)

- when installing got ERROR 1 (and I wasn't able to find any reference :((( )

The actual TWRP for my device is Official but broken: unable to decrypt the data partition.

But Magisk installs correctly (both 14.0 and 15.0).

Tried also to clear all than install Magisk 15.0 then, without reboot, your module but every time I got error 1.

It's possible to install the module from a terminal, when Android is running?

Thanks

N
[Magisk] VR25:
I'll push an update soon, which may bypass that issue. Stay tuned.
[Magisk] tag68:
Magisk install process copies magisk.img to /data. How is that possible if data can't be decrypted?
[Magisk] Wolfcity:
I just bought a Moto G5 Plus and want to root it with magisk. Which version of your module I have to flash? And is it just for flashing through magisk manager or also for twrp?

What should be the order after unlocking the bootloader, flash,twrp, flash magisk and after rebooting to system flash your module through magisk manager? Anything else I need to take care of?
[Magisk] VR25:
Always stick with the latest version. However, there's an issue with the G5 Plus already discussed above. Current version of the module won't work. Wait for the next one -- coming up soon.

Pro tip: read the OP! ;)
[Magisk] Wolfcity:
Thx for your reply, will wait for your update.

I read the OP, I always do.;) Maybe I didn't see something like a "How to" because I'm using XDA Labs.
[Magisk] Nephiel:
For the record, I am experiencing the same issue as [MENTION=3783716]showlyshah[/MENTION] with a Doogee S60.

There is no custom kernel for this device, only a custom TWRP 3.1.1, so I'm trying workarounds.

Magisk 15.2 is installed and rooting, but fails to install any modules, and the Magisk log shows this:

mount /dev/block/loop0->/sbin/.core/img failed with 13: Permission denied

Flashing 2018.1.1 from TWRP: results in the same ERROR 1 as post 67.

Flashing 2018.1.1-NOMOUNT from TWRP: flashes OK, but...

...copying and chmodding /sdcard/make_magisk_merge.sh to /sbin/.core/img/.core/service.d/ does not survive a reboot.
[Magisk] VR25:
Everyone facing issues could you confirm whether your cache partitions aren't F2FS-formatted? If they are, you all have to reformat to EXT4 and use the NOMOUNT zip. You can see the file system in TWRP > Wipe > Advanced Wipe.
[Magisk] showlyshah:
Cache is formated in ext4 already.. even in stock os.

The only problem is.. this wont stick after reboot..
[Magisk] Nephiel:
Doogee S60 here. According to TWRP (Advanced > Terminal > "mount"):

/cache: ext4

/data: ext4

/system: ext4

/sdcard: ext4

/external_sd: vfat

No F2FS.
[Magisk] madbat99:
Then this is not your problem.
[Magisk] lalitjoshi06:
Using infinix x603 with f2fs cache and data partition .

Kernel 4.4.15 .

if i format its cache to ext4 then my phone stuck to bootloop always. So i think it will not work in that case f2fs cahe partation.

Any suggestion, Pls help.
[Magisk] Wolfcity:
Moto G5+ (Potter) Stock ROM:
[Magisk] zdoe:
me, 2. exactly the same phone. so did you get this VR25's module working? install via TWRP, or? results?
[Magisk] showlyshah:
Twrp installation failed. Even non magisk version of this hack wont stick after reboot
[Magisk] ldrolez:
Same problem as you, I have the same error in twrp
[Magisk] zdoe:
this worked for me now. moto 5G, 15.3 magisk, 5.5.5 magisk manager. you're a hero, [MENTION=5228676]VR25[/MENTION].
[Magisk] VR25:
**2018.1.14 (201801140)**

- Automatically backup (on boot) & restore (on install/update) /cache/magisk_img -- backup file: /data/magisk_img_bkp

- Better device compatibility, regardless of TWRP F2FS patching status

- Works with all Magisk versions currently in use
[Magisk] showlyshah:
Tried this version too.. with 15.3 magisk.. didn't survive reboot though twrp flashing was successful
[Magisk] VR25:
I suppose you use Magisk already (with limited functionality).

Remove all instances of magisk.*.img, then try installing the module again.

Known targets are:

/data/magisk.img

/data/adb/magisk.img

/data/magisk_merge.img

/data/adb/magisk_merge.img
[Magisk] dawnc:
Since there's no twrp for my phone( honor v10), can you point how to integrate your work into magisk-patched-boot.img? And i'll test if it can make magisk work on my phone.

Thanks a lot
[Magisk] showlyshah:
I mean.. magisk is there.. but magisk in cache is not.
[Magisk] VR25:
I can upload my /cache/magisk_img and give you the details on how to get it set up.

Before I do that, though -- you can do the following:

1. Patch your boot.img with Magisk Manager (no root needed)

2. Use fastboot or such to flash the patched boot.img

3. Use FlashFire app to install Magisk zip, this module and anything else that you would otherwise flash in TWRP

If all of the above works, then you're all set.
[Magisk] dawnc:
I've patched my stock boot.img in Magisk Manager, and fastboot flash the patched boot.img. But it ends with bootloops.So i can't use flashfire app to install magisk.zip/thismodule.zip

There's no twrp ported to Honor V10, so i can't use a custom recovery to flash magisk.zip.

So , i'm looking for a way to make magisk patched boot.img work, and thought maybe your work can do it.

BTW, I've made a pre-rooted boot.img with supersu inside before. so i know how to unpack/repack boot.img, and i know the basic theory about how magisk works(it patched boot.img by replace init with magiskinit, when booted up, it put back the stock init, then patch sepolicy and other files by magisksepolicy/ mount magisk.img...)

But i dont't know how to integrate your work into magisk-patched-boot.img, maybe i should modify the init/init.rc and someothers files?
[Magisk] Wolfcity:
I'm using magisk 14 with limited functionality on my Moto G5 Plus since today too.

I have a magisk.img and magisk_merge.img in data.

If I move these files to another location and flash your module is this procedure reversible if the module doesn't work (maybe by moving back the magisk.img files to their original location) or any other method ?
[Magisk] VR25:
For this to work, you don't modify boot.img. Instead, you do the following prior to flashing Magisk patched boot.img:

1. mv magisk.img /cache/magisk_img

2. rm /data/magisk.img /data/adb/magisk.img 2>/dev/null

2. ln -s /cache/magisk_img /data/magisk.img

3. ln -s /cache/magisk_img /data/adb/magisk.img

4. Flash Magisk patched boot.img & reboot

5. unzip -o $ModuleZip/common/service.sh -d /sbin/.core/img/.core/service.d

Yes, you can simply move back magisk.img to it's original location. Just recall that you must run rm /data/magisk.img /data/adb/magisk.img 2>/dev/null (in TWRP) prior to installing the module (only needed once) to remove conflicting files.
[Magisk] Wolfcity:
This one worked for me after a fresh install of stock rom and magisk 15.2 , even I couldn´t run

su -c cp /sdcard/make_magisk_merge.sh /sbin/.core/img/.core/service.d
su -c chmod 755 /sbin/.core/img/.core/service.d/make_magisk_merge.sh

(the file was not present) or was it meant to run from TWRP?

It was ok but after installing the 4th module (Dolby Atmos) and reboot all modules were gone again.

Should I remove magisk.img /magisk_merge.img and run

rm /data/magisk.img /data/adb/magisk.img 2>/dev/null

from TWRP?

Or won´t it stick anyway?