Magisk: Modules not loaded on VirtualBox Android x86

Created on 16 Mar 2020  路  12Comments  路  Source: topjohnwu/Magisk

I have a Android x86_64 on VirtualBox. I patched ramdisk.img and magisk 20.3 start without issue.
I tried to install some modules as riru core, riru xposed and others but after reboot the module is not loaded. In log I can't see nothing.

1|x86_64:/sbin # cat /cache/magisk.log                                                                                                                                                                            
--------- beginning of main
--------- beginning of system
03-16 08:47:12.128  1172  1172 I Magisk  : Magisk v20.3(20300) daemon started
03-16 08:47:12.128  1172  1172 I Magisk  : * Device API level: 27
03-16 08:47:12.139  1172  1173 I Magisk  : ** late_start service mode running
03-16 08:47:16.223  1172  1659 I Magisk  : ** boot_complete triggered
confirmed

Most helpful comment

I tested the script of @shakalaca and works on Android 8.1 r4 x86/x86_64, Android 9 r2 x86 (x86_64 not yet tested).

  • copy ramdisk.img and initrd.img from installation disk
  • clone repository https://github.com/shakalaca/MagiskOnEmulator
  • download latest version of magisk's zip and rename to magisk.zip
  • connect to device with adb
  • adb push initrd.patch process.sh magisk.zip update-binary /data/local/tmp
  • adb push ramdisk.img /data/local/tmp/ramdisk.img.gz
  • adb push initrd.img /data/local/tmp/initrd.img.gz
  • adb shell "sh /data/local/tmp/process.sh /data/local/tmp/"
  • adb pull /data/local/tmp/ramdisk.img
  • adb pull /data/local/tmp/initrd.img
  • restore new ramdisk.img and initrd.img to installation disk

I think the scripts prepare and installation are not usable with android x86, but process.sh is fantastic for installation and patching of magisk on android x86

All 12 comments

Before reporting bugs you need to try Magisk Canary to ensure that the bug exists or not on the current code.
Anyway, I believe that this problem has already been solved, as you can see in this report

I installed and tried canary version (debug), same result in the list of installed modules: No modules found.

Installation riru-core

x86_64:/ # cat /cache/magisk.log                                                                                                                                                                                  
--------- beginning of main
--------- beginning of system
03-18 11:39:54.863  1074  1074 I Magisk  : Magisk v72f6770d(20307) daemon started
03-18 11:39:54.863  1074  1074 I Magisk  : * Device API level: 27
03-18 11:39:54.873  1074  1075 D Magisk  : resetprop: getprop [ro.crypto.state]: [unsupported]
03-18 11:39:54.874  1074  1075 D Magisk  : resetprop: getprop [init.svc.vold]: [running]
03-18 11:39:54.884  1074  1075 I Magisk  : ** post-fs-data mode running
03-18 11:39:54.886  1074  1075 I Magisk  : * Initializing Magisk environment
03-18 11:39:55.096  1074  1075 I Magisk  : * Mounting mirrors
03-18 11:39:55.096  1074  1075 E Magisk  : stat /dev/loop0 failed with 2: No such file or directory
03-18 11:39:55.097  1074  1075 E Magisk  : mount /sbin/.magisk/block/system->/sbin/.magisk/mirror/system failed with 2: No such file or directory
03-18 11:39:55.097  1074  1075 I Magisk  : mount: /sbin/.magisk/mirror/system <- /sbin/.magisk/block/system
03-18 11:39:55.097  1074  1075 I Magisk  : mount: /sbin/.magisk/mirror/data <- /sbin/.magisk/block/data
03-18 11:39:55.097  1074  1075 I Magisk  : link: /sbin/.magisk/mirror/vendor <- /sbin/.magisk/mirror/system/vendor
03-18 11:39:55.097  1074  1075 I Magisk  : * Setting up internal busybox
03-18 11:39:55.170  1074  1075 I Magisk  : * Running post-fs-data.d scripts
03-18 11:39:55.170  1074  1075 I Magisk  : Upgrade / New module: riru-core
03-18 11:39:55.171  1074  1075 E Magisk  : mount /sbin/.magisk/mirror/data/adb/modules->/sbin/.magisk/modules failed with 2: No such file or directory
03-18 11:39:55.172  1074  1075 I Magisk  : * Running module post-fs-data scripts
03-18 11:39:55.172  1074  1075 I Magisk  : riru-core: exec [post-fs-data.sh]
03-18 11:39:55.232  1074  1075 I Magisk  : * Loading modules
03-18 11:39:55.534  1074  1133 I Magisk  : ** late_start service mode running
03-18 11:39:55.534  1074  1133 I Magisk  : * Running service.d scripts
03-18 11:39:55.534  1074  1133 I Magisk  : * Running module service scripts
03-18 11:40:47.265  1074  1627 I Magisk  : ** boot_complete triggered
03-18 11:40:59.029  1074  2006 D Magisk  : su: request from pid=[2003], client=[6]
03-18 11:40:59.029  1074  2006 D Magisk  : su: request from uid=[10071]
03-18 11:40:59.259  1074  2006 D Magisk  : su: waiting child pid=[2012]
03-18 11:40:59.259  2012  2012 D Magisk  : su: fork handler
03-18 11:40:59.259  2012  2012 D Magisk  : su: use global namespace
03-18 11:41:27.381  1074  3582 D Magisk  : su: request from pid=[3581], client=[7]
03-18 11:41:27.381  1074  3582 D Magisk  : su: request from uid=[2000]
03-18 11:41:37.631  1074  3582 D Magisk  : su: waiting child pid=[3708]
03-18 11:41:37.633  3708  3708 D Magisk  : su: fork handler
03-18 11:41:37.634  3708  3708 D Magisk  : su: pts_slave=[/dev/pts/1]
03-18 11:41:37.634  3708  3708 D Magisk  : su: use namespace of pid=[3581]

Installation riru-edxposed

x86_64:/ # cat /cache/magisk.log                                                                                                                                                                                  
--------- beginning of main
--------- beginning of system
03-18 11:45:03.036  1074  1074 I Magisk  : Magisk v72f6770d(20307) daemon started
03-18 11:45:03.036  1074  1074 I Magisk  : * Device API level: 27
03-18 11:45:03.047  1074  1075 D Magisk  : resetprop: getprop [ro.crypto.state]: [unsupported]
03-18 11:45:03.047  1074  1075 D Magisk  : resetprop: getprop [init.svc.vold]: [running]
03-18 11:45:03.058  1074  1075 I Magisk  : ** post-fs-data mode running
03-18 11:45:03.060  1074  1075 I Magisk  : * Initializing Magisk environment
03-18 11:45:03.250  1074  1075 I Magisk  : * Mounting mirrors
03-18 11:45:03.250  1074  1075 E Magisk  : stat /dev/loop0 failed with 2: No such file or directory
03-18 11:45:03.250  1074  1075 E Magisk  : mount /sbin/.magisk/block/system->/sbin/.magisk/mirror/system failed with 2: No such file or directory
03-18 11:45:03.250  1074  1075 I Magisk  : mount: /sbin/.magisk/mirror/system <- /sbin/.magisk/block/system
03-18 11:45:03.251  1074  1075 I Magisk  : mount: /sbin/.magisk/mirror/data <- /sbin/.magisk/block/data
03-18 11:45:03.251  1074  1075 I Magisk  : link: /sbin/.magisk/mirror/vendor <- /sbin/.magisk/mirror/system/vendor
03-18 11:45:03.264  1074  1075 I Magisk  : * Setting up internal busybox
03-18 11:45:03.336  1074  1075 I Magisk  : * Running post-fs-data.d scripts
03-18 11:45:03.348  1074  1075 I Magisk  : Upgrade / New module: riru_edxposed
03-18 11:45:03.348  1074  1075 E Magisk  : mount /sbin/.magisk/mirror/data/adb/modules->/sbin/.magisk/modules failed with 2: No such file or directory
03-18 11:45:03.363  1074  1075 I Magisk  : * Running module post-fs-data scripts
03-18 11:45:03.363  1074  1075 I Magisk  : riru-core: exec [post-fs-data.sh]
03-18 11:45:03.393  1074  1075 I Magisk  : riru_edxposed: exec [post-fs-data.sh]
03-18 11:45:11.326  1074  1075 I Magisk  : * Loading modules
03-18 11:45:11.326  1074  1075 I Magisk  : riru_edxposed: loading [system.prop]
03-18 11:45:11.327  1074  1075 D Magisk  : resetprop: Parse prop file [/data/adb/modules/riru_edxposed/system.prop]
03-18 11:45:11.343  1074  1075 D Magisk  : resetprop: New prop [dalvik.vm.dex2oat-filter]
03-18 11:45:11.344  1074  1075 D Magisk  : resetprop: setprop [dalvik.vm.dex2oat-filter]: [quicken] by modifing prop data structure
03-18 11:45:11.344  1074  1075 D Magisk  : resetprop: New prop [dalvik.vm.dex2oat-flags]
03-18 11:45:11.344  1074  1075 D Magisk  : resetprop: setprop [dalvik.vm.dex2oat-flags]: [--inline-max-code-units=0] by modifing prop data structure
03-18 11:45:11.344  1074  1075 I Magisk  : riru_edxposed: constructing magic mount structure
03-18 11:45:11.344  1074  1075 E Magisk  : opendir: /sbin/.magisk/mirror/system/framework failed with 2: No such file or directory
03-18 11:45:11.344  1074  1075 E Magisk  : opendir: /sbin/.magisk/mirror/system/lib failed with 2: No such file or directory
03-18 11:45:11.344  1074  1075 E Magisk  : opendir: /sbin/.magisk/mirror/system/lib64 failed with 2: No such file or directory
03-18 11:45:11.344  1074  1075 E Magisk  : mount /sbin/.magisk/modules/riru_edxposed/system/bin/app_process32->/system/bin/app_process32 failed with 2: No such file or directory
03-18 11:45:11.344  1074  1075 I Magisk  : bind_mount: /system/bin/app_process32 <- /sbin/.magisk/modules/riru_edxposed/system/bin/app_process32
03-18 11:45:11.344  1074  1075 E Magisk  : mount /sbin/.magisk/modules/riru_edxposed/system/bin/app_process64->/system/bin/app_process64 failed with 2: No such file or directory
03-18 11:45:11.344  1074  1075 I Magisk  : bind_mount: /system/bin/app_process64 <- /sbin/.magisk/modules/riru_edxposed/system/bin/app_process64
03-18 11:45:11.766  1074  1215 I Magisk  : ** late_start service mode running
03-18 11:45:11.767  1074  1215 I Magisk  : * Running service.d scripts
03-18 11:45:11.944  1074  1215 I Magisk  : * Running module service scripts
03-18 11:45:55.156  1074  1704 I Magisk  : ** boot_complete triggered

installation MagiskHidePropsConf

x86_64:/ # cat /cache/magisk.log                                                                                                                                                                                  
--------- beginning of main
--------- beginning of system
03-18 11:51:56.139  1074  1074 I Magisk  : Magisk v72f6770d(20307) daemon started
03-18 11:51:56.139  1074  1074 I Magisk  : * Device API level: 27
03-18 11:51:56.150  1074  1075 D Magisk  : resetprop: getprop [ro.crypto.state]: [unsupported]
03-18 11:51:56.150  1074  1075 D Magisk  : resetprop: getprop [init.svc.vold]: [running]
03-18 11:51:56.162  1074  1075 I Magisk  : ** post-fs-data mode running
03-18 11:51:56.163  1074  1075 I Magisk  : * Initializing Magisk environment
03-18 11:51:56.399  1074  1075 I Magisk  : * Mounting mirrors
03-18 11:51:56.400  1074  1075 E Magisk  : stat /dev/loop0 failed with 2: No such file or directory
03-18 11:51:56.400  1074  1075 E Magisk  : mount /sbin/.magisk/block/system->/sbin/.magisk/mirror/system failed with 2: No such file or directory
03-18 11:51:56.400  1074  1075 I Magisk  : mount: /sbin/.magisk/mirror/system <- /sbin/.magisk/block/system
03-18 11:51:56.400  1074  1075 I Magisk  : mount: /sbin/.magisk/mirror/data <- /sbin/.magisk/block/data
03-18 11:51:56.400  1074  1075 I Magisk  : link: /sbin/.magisk/mirror/vendor <- /sbin/.magisk/mirror/system/vendor
03-18 11:51:56.413  1074  1075 I Magisk  : * Setting up internal busybox
03-18 11:51:56.478  1074  1075 I Magisk  : * Running post-fs-data.d scripts
03-18 11:51:56.486  1074  1075 I Magisk  : Upgrade / New module: MagiskHidePropsConf
03-18 11:51:56.486  1074  1075 E Magisk  : mount /sbin/.magisk/mirror/data/adb/modules->/sbin/.magisk/modules failed with 2: No such file or directory
03-18 11:51:56.553  1074  1075 I Magisk  : * Running module post-fs-data scripts
03-18 11:51:56.553  1074  1075 I Magisk  : riru-core: exec [post-fs-data.sh]
03-18 11:51:56.593  1074  1075 I Magisk  : riru_edxposed: exec [post-fs-data.sh]
03-18 11:52:04.506  1074  1075 I Magisk  : MagiskHidePropsConf: exec [post-fs-data.sh]
03-18 11:52:04.518  1074  1075 I Magisk  : * Loading modules
03-18 11:52:04.518  1074  1075 I Magisk  : riru_edxposed: loading [system.prop]
03-18 11:52:04.518  1074  1075 D Magisk  : resetprop: Parse prop file [/data/adb/modules/riru_edxposed/system.prop]
03-18 11:52:04.528  1074  1075 D Magisk  : resetprop: New prop [dalvik.vm.dex2oat-filter]
03-18 11:52:04.528  1074  1075 D Magisk  : resetprop: setprop [dalvik.vm.dex2oat-filter]: [quicken] by modifing prop data structure
03-18 11:52:04.528  1074  1075 D Magisk  : resetprop: New prop [dalvik.vm.dex2oat-flags]
03-18 11:52:04.528  1074  1075 D Magisk  : resetprop: setprop [dalvik.vm.dex2oat-flags]: [--inline-max-code-units=0] by modifing prop data structure
03-18 11:52:04.528  1074  1075 I Magisk  : riru_edxposed: constructing magic mount structure
03-18 11:52:04.528  1074  1075 I Magisk  : MagiskHidePropsConf: loading [system.prop]
03-18 11:52:04.528  1074  1075 D Magisk  : resetprop: Parse prop file [/data/adb/modules/MagiskHidePropsConf/system.prop]
03-18 11:52:04.553  1074  1075 I Magisk  : MagiskHidePropsConf: constructing magic mount structure
03-18 11:52:04.553  1074  1075 E Magisk  : opendir: /sbin/.magisk/mirror/system/framework failed with 2: No such file or directory
03-18 11:52:04.553  1074  1075 E Magisk  : opendir: /sbin/.magisk/mirror/system/lib failed with 2: No such file or directory
03-18 11:52:04.553  1074  1075 E Magisk  : opendir: /sbin/.magisk/mirror/system/lib64 failed with 2: No such file or directory
03-18 11:52:04.553  1074  1075 E Magisk  : opendir: /sbin/.magisk/mirror/system/bin failed with 2: No such file or directory
03-18 11:52:04.867  1074  1221 I Magisk  : ** late_start service mode running
03-18 11:52:04.868  1074  1221 I Magisk  : * Running service.d scripts
03-18 11:52:04.886  1074  1221 I Magisk  : * Running module service scripts
03-18 11:52:04.886  1074  1221 I Magisk  : MagiskHidePropsConf: exec [service.sh]
03-18 11:52:49.517  1074  2167 I Magisk  : ** boot_complete triggered
03-18 11:53:03.411  1074  2635 D Magisk  : su: request from pid=[2632], client=[6]
03-18 11:53:03.411  1074  2635 D Magisk  : su: request from uid=[10071]
03-18 11:53:03.704  1074  2635 D Magisk  : su: waiting child pid=[2663]
03-18 11:53:03.704  2663  2663 D Magisk  : su: fork handler
03-18 11:53:03.706  2663  2663 D Magisk  : su: use global namespace
03-18 11:56:47.317  1074  4682 D Magisk  : su: request from pid=[4681], client=[7]
03-18 11:56:47.317  1074  4682 D Magisk  : su: request from uid=[2000]
03-18 11:56:47.365  1074  4682 D Magisk  : magiskdb: query policy=[2] log=[1] notify=[1]
03-18 11:56:47.368  1074  4682 D Magisk  : su: waiting child pid=[4685]
03-18 11:56:47.369  4685  4685 D Magisk  : su: fork handler
03-18 11:56:47.370  4685  4685 D Magisk  : su: pts_slave=[/dev/pts/1]
03-18 11:56:47.370  4685  4685 D Magisk  : su: use namespace of pid=[4681]

directory modules is empty

x86_64:/sbin/.magisk/modules # ls -l
total 0

So the problem is not in the loading of the modules, it is in the installation. There is a new commit on the modules installation code, wait for the next update of the Magisk Canary to see if it solves your problem or wait for some response from topjohnwu

@KaMyKaSii sorry for wrong informations, but while the installation of modules I can't see errors on screen, so I thought the issue was on loading.
I tested the new version and continue with the same issue

x86:/sbin/.magisk/modules # cat /cache/magisk.log                                                                                                                                                                 
--------- beginning of main
--------- beginning of system
03-19 16:27:57.883  1075  1075 I Magisk  : Magisk vf7142e69(20308) daemon started
03-19 16:27:57.883  1075  1075 I Magisk  : * Device API level: 27
03-19 16:27:57.909  1075  1076 I Magisk  : ** post-fs-data mode running
03-19 16:27:58.837  1075  1076 I Magisk  : * Initializing Magisk environment
03-19 16:27:59.046  1075  1076 I Magisk  : * Mounting mirrors
03-19 16:27:59.047  1075  1076 E Magisk  : stat /dev/loop0 failed with 2: No such file or directory
03-19 16:27:59.047  1075  1076 E Magisk  : mount /sbin/.magisk/block/system->/sbin/.magisk/mirror/system failed with 15: Block device required
03-19 16:27:59.047  1075  1076 I Magisk  : mount: /sbin/.magisk/mirror/system
03-19 16:27:59.047  1075  1076 I Magisk  : mount: /sbin/.magisk/mirror/data
03-19 16:27:59.048  1075  1076 I Magisk  : link: /sbin/.magisk/mirror/vendor
03-19 16:27:59.048  1075  1076 I Magisk  : * Setting up internal busybox
03-19 16:27:59.104  1075  1076 I Magisk  : * Running post-fs-data.d scripts
03-19 16:27:59.105  1075  1076 I Magisk  : Upgrade / New module: riru-core
03-19 16:27:59.105  1075  1076 E Magisk  : mount /sbin/.magisk/mirror/data/adb/modules->/sbin/.magisk/modules failed with 2: No such file or directory
03-19 16:27:59.106  1075  1076 I Magisk  : * Running module post-fs-data scripts
03-19 16:27:59.106  1075  1076 I Magisk  : riru-core: exec [post-fs-data.sh]
03-19 16:27:59.158  1075  1076 I Magisk  : * Loading modules
03-19 16:27:59.567  1075  1132 I Magisk  : ** late_start service mode running
03-19 16:27:59.567  1075  1132 I Magisk  : * Running service.d scripts
03-19 16:27:59.567  1075  1132 I Magisk  : * Running module service scripts
03-19 16:28:39.028  1075  1606 I Magisk  : ** boot_complete triggered

I followed this guide and I convert android x86 8.1 from one partition to 3 partitions (boot, /system and /data), works only with 20.1 after update to 20.3 the previous working modules disappear.

2594 might help. You'll have to test again after the next build with it merged.

The filesystem layout is kind of weird ..
Screen Shot 2020-03-28 at 11 51 24 AM

I put the init file (inside initrd.img) here: https://gist.github.com/shakalaca/68020f29a75b816bed8245761c746f34

Looks like some of the entries in /proc/mounts came before chroot, so Magisk could not mount /system and /data partition properly and the module system failed because of that ..

Sounds like it was pure luck that it ever worked at all. Does the emulator.sh work for this use case?

Modules never worked because the emulator.sh can't be ran on boot (excl modifying the ramdisk)

If we can do the hack on Android x86 project, I think it's better to keep the complexity there and leave Magisk clean and simple, so here's the hack : (for AVD we still need the patch https://github.com/topjohnwu/Magisk/pull/2594):
https://github.com/shakalaca/MagiskOnEmulator

@etmatrix please have a look and see if it works for you :)

@shakalaca thank you for you work.
The script prepare_image.sh doesn't work properly and I don't know if will never work.
mount /dev/block/sda1 return Device busy.

mount -o ro -t ext4 /dev/block/sda1 /data/local/tmp/root/
mount: '/dev/block/sda1'->'/data/local/tmp/root/': Device or resource busy

I got ramdisk.img and initrd.img with:

  • power off android x86
  • modprobe nbd max_part=16
  • qemu-nbd -c /dev/nbd0 Android8.vdi
  • mount /dev/nbd0p1 /mnt/tmp/

I think the correct script to run for vbox is patch_vbox.sh, doesn't matter, I pulled all files and executed process.sh as root, after this operation I pushed the new ramdisk.img and initrd.img and copied, but after I poweron the virtual machine, it's stuck on boot.
I debugging it, maybe the loop while true which check the directory /sbin/.magisk/

EDIT
Sorry my fault, I execute the entire process another one and now works, module are loaded on boot with magisk 20.4

I tested the script of @shakalaca and works on Android 8.1 r4 x86/x86_64, Android 9 r2 x86 (x86_64 not yet tested).

  • copy ramdisk.img and initrd.img from installation disk
  • clone repository https://github.com/shakalaca/MagiskOnEmulator
  • download latest version of magisk's zip and rename to magisk.zip
  • connect to device with adb
  • adb push initrd.patch process.sh magisk.zip update-binary /data/local/tmp
  • adb push ramdisk.img /data/local/tmp/ramdisk.img.gz
  • adb push initrd.img /data/local/tmp/initrd.img.gz
  • adb shell "sh /data/local/tmp/process.sh /data/local/tmp/"
  • adb pull /data/local/tmp/ramdisk.img
  • adb pull /data/local/tmp/initrd.img
  • restore new ramdisk.img and initrd.img to installation disk

I think the scripts prepare and installation are not usable with android x86, but process.sh is fantastic for installation and patching of magisk on android x86

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ThiefMaster picture ThiefMaster  路  3Comments

auanasgheps picture auanasgheps  路  4Comments

Madis0 picture Madis0  路  3Comments

ananjaser1211 picture ananjaser1211  路  4Comments

georgekav2 picture georgekav2  路  3Comments