3

I use ES File Explorer to modify /system/priv-app in the past with root permission given via magisk.

After upgrading to Android 10, ES File Explorer can no longer modify the /system/priv-app giving me an error message saying "operation failed."

What alternatives do I have if I like to modify /system/priv-app?

The output of running set -x; exec >>/sdcard/mount.log 2>&1; id; mount -o rw,remount /system; mount | grep 'on /system '; touch /system/test_file; cat /sys/block/dm-*/dm/name:

uid=0(root) gid=0(root) groups=0(root) context=u:r:magisk:s0
mount: '/system' not in /proc/mounts
touch: '/system/test_file': Read-only file system
vendor-verity

It turns out:

On some system-as-root (SAR) devices you can no longer mount the system partition as read-write and doing systemless modifications through Magisk is the only way. If you do want to do actual edits of the system, and if it is even possible (from Android 10 it's actually impossible on some devices), you need to mount the root directory, /, as rw and not /system. You can also try editing the partition mirrors that Magisk keeps in /sbin/.magisk/mirror.

So all I needed to do is to:

mount -o rw,remount /
Aero Windwalker
  • 1,024
  • 8
  • 15
  • 27

2 Answers2

0

You need to remount the partition as read-write. mount -wo remount / (change / to /system if you don't have system root enabled in my app). It should work then, though if not you probably have a read only filesystem like EROFS

Hack5
  • 144
  • 4
  • I don't think magisk supports remounting /system it returns '/system' not in /proc/mounts. – Aero Windwalker Jan 17 '20 at 03:43
  • Indeed, magisk doesn't actually mount the system partition at all. You will have to use an alternative. – Hack5 Jan 17 '20 at 07:06
  • '/system' not in /proc/mounts could mean that system partition is mounted as rootfs (/) and /system is just a directory inside it. Will have to look at mounted filesystems to be sure. – Irfan Latif Jan 17 '20 at 07:45
  • But if you're using magisk it makes no difference. Magisk does the craziest hacks (temporary workarounds) to modify /system – Hack5 Jan 17 '20 at 07:46
  • 1
    You can check reliably if system as root is used (regardless of magisk) in my app, kutt.it/trblchk – Hack5 Jan 17 '20 at 07:47
  • @AeroWindwalker please try to remount rw root / as Hack5 suggested – alecxs Jan 18 '20 at 09:15
  • @alecxs yes that works. Thanks. – Aero Windwalker Jan 18 '20 at 10:14
  • That "craziest hack (temporary workaround)" is called bind-mount. And you don't need necessarily Magisk to use this "hack". And to "check reliably if system as root is used" all that's needed is to see mounted filesystems using mount command. – Irfan Latif Jan 18 '20 at 14:28
  • @Irfan I know it's a bind mount. Except that it isn't. It's a large number of individual bind mounts. And why would you want to use this "hack"? The only advantage is that it helps magisk to hide root and add modules, and it's practically impossible unless you wrote some code to so that. – Hack5 Jan 18 '20 at 14:31
  • @Hack5 bind-mounts are not used to hide root. For that Magisk watches /proc (probably using Linux kernel's inotify framework) for newly created processes. And if it's an app (DVM) process which should not know about root, Magisk un-mounts /sbin in that app's mount namespace so that /sbin/su is not visible to that app. Plus there are other minor things to be taken care off to completely hide root presence. // Large number of bind-mounts are required to create a new file or directory (which doesn't exist already) systemlessly. To modify an existing file, only one bind mount is required. – Irfan Latif Jan 18 '20 at 14:38
  • 1
    Btw, original question has nothing to do with MagiskHide or Magic Mount. – Irfan Latif Jan 18 '20 at 14:47
  • 1
    @Irfan without the bind mount, magisk couldn't unmount /sbin. I think we should move to chat, but I know how the root hiding works. There are some props to set by magisk, as well as the bind mounts that are used to insert su. Of course, magisk could just insert itself to the system partition like a traditional root app, but it doesn't. This helps it to hide itself. And by the way, magisks way of finding out when an app launches it terrible. And magic mount is related to the question in that bind mounts can interfere with the remounting of /system and with the file management itself. – Hack5 Jan 18 '20 at 16:07
  • on Google Pixel (1st gen) any of these does not work. any ideas? – Paschalis Apr 11 '20 at 17:50
  • @Paschalis define does not work – Hack5 Apr 11 '20 at 17:54
  • I've actually created a question here: https://android.stackexchange.com/questions/223872/mount-system-on-android-10-with-magisk – Paschalis Apr 11 '20 at 17:54
0
> adb root

> adb shell avbctl disable-verification

Successfully disabled verification. Reboot the device for changes to take effect.

> adb disable-verity

using overlayfs
Successfully disabled verity
Now reboot your device for settings to take effect

> adb reboot

> adb root && adb remount
remount succeeded

> adb push ScreenCap.apk /system/app/
ScreenCap.apk: 1 file pushed. 33.1 MB/s (1640812 bytes in 0.047s)

> adb reboot