HuskyDG / magic_overlayfs

Make system partition become read-write (it is also possible without Magisk)
657 stars 144 forks source link

Temp Root #35

Closed diabl0w closed 11 months ago

diabl0w commented 11 months ago

I am trying to run magic_overlayfs in a temp-root environment that utilizes magisk running in /dev/.magisk on a Samsung Galaxy Z Fold 3. After running from root terminal: /data/local/tmp/overlayfs_system /data/overlayfs, I get no functioning overlay and the following /cache/overlayfs.log:

07-28 03:07:13.944  8286  8286 I : * Mount OverlayFS started
07-28 03:07:13.946  8286  8286 I : Switched to init mount namespace
07-28 03:07:13.950  8286  8286 D : mountinfo: device (253:4)/system/carrier/VZW on /system/carrier type ext4 (ro,seclabel,i_version)
07-28 03:07:13.951  8286  8286 D : mountinfo: device (259:1) on /vendor/dsp type ext4 (ro,seclabel,i_version)
07-28 03:07:13.951  8286  8286 D : mountinfo: device (259:2) on /vendor/firmware-modem type vfat (ro,context=u:object_r:firmware_file:s0,gid=1000,fmask=0337,dmask=0227,codepage=437,iocharset=iso8859-1,shortname=lower,errors=remount-ro)
07-28 03:07:13.952  8286  8286 D : mountinfo: device (259:7) on /vendor/firmware_mnt type vfat (ro,context=u:object_r:firmware_file:s0,gid=1000,fmask=0337,dmask=0227,codepage=437,iocharset=iso8859-1,shortname=lower,errors=remount-ro)
07-28 03:07:13.952  8286  8286 D : mountinfo: device (253:9) on /optics type ext4 (ro,seclabel,i_version)
07-28 03:07:13.952  8286  8286 D : mountinfo: device (253:8) on /prism type ext4 (ro,seclabel,i_version)
07-28 03:07:13.952  8286  8286 D : mountinfo: device (253:7) on /odm type ext4 (ro,seclabel,i_version)
07-28 03:07:13.952  8286  8286 D : mountinfo: device (253:6) on /product type ext4 (ro,seclabel,i_version)
07-28 03:07:13.952  8286  8286 D : mountinfo: device (253:5) on /vendor type ext4 (ro,seclabel,i_version)
07-28 03:07:13.953  8286  8286 D : getenv: [OVERLAY_MODE]=[2]
07-28 03:07:13.953  8286  8286 D : getenv: [OVERLAY_LEGACY_MOUNT]=[false]
07-28 03:07:13.953  8286  8286 D : getenv: [OVERLAYLIST]=[/dev/.magisk/.magisk/modules/module_a:/dev/.magisk/.magisk/modules/module_b]
07-28 03:07:13.953  8286  8286 D : getenv: [MAGISKTMP]=[/dev/.magisk]
07-28 03:07:13.953  8286  8286 D : Kernel version: 5.4
07-28 03:07:13.953  8286  8286 D : Magisk mirrors path is /dev/.magisk/.magisk/mirror
07-28 03:07:13.956  8286  8286 D : mount: /dev/.worker_pvqylujhqjrcrykjbnhq <- tmpfs (tmpfs) [rw]
07-28 03:07:13.956  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/master failed with 2: No such file or directory
07-28 03:07:13.956  8286  8286 I : ** Prepare mounts
07-28 03:07:13.957  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/system failed with 22: Invalid argument
07-28 03:07:13.957  8286  8286 W : Unable to add [/system], ignore!
07-28 03:07:13.957  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/vendor failed with 22: Invalid argument
07-28 03:07:13.958  8286  8286 W : Unable to add [/vendor], ignore!
07-28 03:07:13.958  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/product failed with 22: Invalid argument
07-28 03:07:13.958  8286  8286 W : Unable to add [/product], ignore!
07-28 03:07:13.959  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/odm failed with 22: Invalid argument
07-28 03:07:13.959  8286  8286 W : Unable to add [/odm], ignore!
07-28 03:07:13.959  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/vendor_dlkm failed with 22: Invalid argument
07-28 03:07:13.959  8286  8286 W : Unable to add [/vendor_dlkm], ignore!
07-28 03:07:13.960  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/odm_dlkm failed with 22: Invalid argument
07-28 03:07:13.960  8286  8286 W : Unable to add [/odm_dlkm], ignore!
07-28 03:07:13.960  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/prism failed with 22: Invalid argument
07-28 03:07:13.960  8286  8286 W : Unable to add [/prism], ignore!
07-28 03:07:13.961  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/optics failed with 22: Invalid argument
07-28 03:07:13.961  8286  8286 W : Unable to add [/optics], ignore!
07-28 03:07:13.961  8286  8286 E : mount: overlay -> /dev/.worker_pvqylujhqjrcrykjbnhq/oem failed with 22: Invalid argument
07-28 03:07:13.961  8286  8286 W : Unable to add [/oem], ignore!
07-28 03:07:13.963  8286  8286 I : ** Loading overlayfs
07-28 03:07:13.963  8286  8286 I : ** Loading overlayfs mirrors
07-28 03:07:13.963  8286  8286 I : mount done!
07-28 03:07:13.963  8286  8286 I : clean up
07-28 03:07:13.963  8286  8286 D : umount: /dev/.worker_pvqylujhqjrcrykjbnhq

dmesg output:

[15940.494740] [0:overlayfs_syste: 9908]  overlayfs: failed to resolve '/dev/.magisk/.magisk/modules/module_a': -2
[15940.495698] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/system' not supported
[15940.496226] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/vendor' not supported
[15940.496793] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/product' not supported
[15940.497359] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/odm' not supported
[15940.497875] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/vendor_dlkm' not supported
[15940.498399] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/odm_dlkm' not supported
[15940.499065] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/prism' not supported
[15940.499606] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/optics' not supported
[15940.500127] [0:overlayfs_syste: 9908]  overlayfs: filesystem on '/data/overlayfs/upper/oem' not supported
HuskyDG commented 11 months ago
  1. Overlayfs must be mounted before zygote start so system modifications can have effect, overwise it is meanless. Unless you restart zygote again after mounting.
  2. /data f2fs is not allowed to be used directly on some Kernel

Please try:

dd if=/dev/zero of=/data/adb/overlay bs=1024 count=100
mkfs.ext4 /data/adb/overlay
e2fsck -pf /data/adb/overlay
resize2fs /data/adb/overlay 2000M
mkdir /mnt/overlayfs
mount -o rw -t ext4 /data/adb/overlay /mnt/overlayfs
/data/local/tmp/overlayfs_system /mnt/overlayfs
stop; start
diabl0w commented 11 months ago
mount -o rw -t ext4 /data/adb/overlay /mnt/overlayfs

@HuskyDG , thank you for your assistance

yes, restarting zygote was the plan, although I am sure that will come with more issues to be solved, I will have to take it one step at a time.

running your commands, the mount -o rw -t ext4 /data/adb/overlay /mnt/overlayfs results in:

mount: can't setup loop device: No such file or directory

EDIT: I apologize , it was a busybox mount issue, let me continue now that i used the proper mount binary

The test mount command runs fine, but running overlayfs_system mounting to /mnt/overlayfs results in the device locking up and rebooting

I tried

setprop ctl.stop media
setprop ctl.stop zygote

before running the command, but that did not result in any difference. The system freezes before there is any meaningful output in dmesg or logcat

diabl0w commented 11 months ago

is there a reason why this is closed? whether it is believed to be useful or not after android boot i dont believe should be the reason. if it just not possible under this environment, that would be a good reason, but im not sure we've proven that