├── README.md
└── emulator.sh
/README.md:
--------------------------------------------------------------------------------
1 | # Magisk on VphoneGaga
2 |
3 |
4 |
5 |
6 |
7 | Set up a proper minial Magisk on VphoneGaga virtual machine without patching boot image
8 |
9 | VphoneGaga 32bit and 64bit now supported!
10 |
11 | Good news for anyone who want to run Magisk on VMOS: Vphone have proper system and can run Magisk properly thanks to [emulator.sh](https://github.com/topjohnwu/Magisk/blob/master/scripts/emulator.sh) script by **topjohnwu**.
12 |
13 | ### Installation
14 |
15 | 1. Download `vmostool_magisk.zip`
16 | 2. Import to VphoneGaga. You can find it at `/sdcard/Documents`, extract to any folder. For example here `/sdcard/Documents/vmostool_magisk`.
17 | 3. Open Terminal app, grant superuser first by `su` command then run `sh /vphonegaga.sh`.
18 |
19 | For example run:
20 | ```
21 | su
22 | sh /sdcard/Documents/vmostool_magisk/vphonegaga
23 | ```
24 | 4. Reboot the virtual machine.
25 |
26 | If you want to load Magisk then run this command:
27 | ```
28 | su
29 | magisk_root enable
30 | ```
31 |
32 |
33 | Also reboot to make it work...
34 |
35 | Only install Magisk Manager v8.0.0
36 | Newer Magisk doesn't work
37 |
38 | ## Limitations
39 | - **Only MagiskSU works:** it can prompt Superuser request when app excute `su` binary
40 | - **MagiskHide:** Android's kernel on this virtual machine was too old and didn't support Mount Namespace which is used by MagiskHide to hide itself by unmount /sbin/su from other app
41 | - **MagiskModule** `/dev/tmp` issue so module failed to install
42 | - VphoneGaga blocks Magisk from running on post-fs-data stage so if Magisk Module is installed, it won't work
43 |
44 |
45 |
46 | ## Download
47 |
48 | Download link: https://link1s.com/MagiskVphoneGaGa
49 | VPhoneGaGa link: https://link1s.com/VphoneGaga
50 |
--------------------------------------------------------------------------------
/emulator.sh:
--------------------------------------------------------------------------------
1 | ## Magisk emulator.sh by topjohnwu
2 |
3 | abort() {
4 | echo "$@"
5 | exit 1
6 | }
7 |
8 | mount_sbin() {
9 | mount -t tmpfs -o 'mode=0755' tmpfs /sbin
10 | $SELINUX && chcon u:object_r:rootfs:s0 /sbin
11 | }
12 |
13 | if [ ! -f /system/build.prop ]; then
14 | # Running on PC
15 | cd "$(dirname "$0")/.."
16 | adb push native/out/x86_64/busybox native/out/x86_64/magiskinit \
17 | native/out/x86_64/magisk scripts/emulator.sh /data/local/tmp
18 | adb shell sh /data/local/tmp/emulator.sh
19 | exit 0
20 | fi
21 |
22 | cd /data/local/tmp
23 | chmod 777 busybox
24 | chmod 777 magiskinit
25 | chmod 777 magisk
26 |
27 | if [ -z "$FIRST_STAGE" ]; then
28 | export FIRST_STAGE=1
29 | export ASH_STANDALONE=1
30 | if [ `./busybox id -u` -ne 0 ]; then
31 | # Re-exec script with root
32 | exec /system/xbin/su 0 ./busybox sh $0
33 | else
34 | # Re-exec script with busybox
35 | exec ./busybox sh $0
36 | fi
37 | fi
38 |
39 | # Remove previous setup if exist
40 | pgrep magiskd >/dev/null && pkill -9 magiskd
41 | [ -f /sbin/magisk ] && umount -l /sbin
42 | [ -f /system/bin/magisk ] && umount -l /system/bin
43 |
44 | # SELinux stuffs
45 | SELINUX=false
46 | [ -e /sys/fs/selinux ] && SELINUX=true
47 | if $SELINUX; then
48 | ln -sf ./magiskinit magiskpolicy
49 | ./magiskpolicy --live --magisk
50 | fi
51 |
52 | BINDIR=/sbin
53 |
54 | # Setup bin overlay
55 | if mount | grep -q rootfs; then
56 | # Legacy rootfs
57 | mount -o rw,remount /
58 | rm -rf /root
59 | mkdir /root
60 | chmod 750 /root
61 | ln /sbin/* /root
62 | mount -o ro,remount /
63 | mount_sbin
64 | ln -s /root/* /sbin
65 | elif [ -e /sbin ]; then
66 | # Legacy SAR
67 | mount_sbin
68 | if ! grep -q '/sbin/.magisk/mirror/system_root' /proc/mounts; then
69 | mkdir -p /sbin/.magisk/mirror/system_root
70 | block=$(mount | grep ' / ' | awk '{ print $1 }')
71 | [ $block = "/dev/root" ] && block=/dev/block/dm-0
72 | mount -o ro $block /sbin/.magisk/mirror/system_root
73 | fi
74 | for file in /sbin/.magisk/mirror/system_root/sbin/*; do
75 | [ ! -e $file ] && break
76 | if [ -L $file ]; then
77 | cp -af $file /sbin
78 | else
79 | sfile=/sbin/$(basename $file)
80 | touch $sfile
81 | mount -o bind $file $sfile
82 | fi
83 | done
84 | else
85 | # Android Q+ without sbin, use overlayfs
86 | BINDIR=/system/bin
87 | rm -rf /dev/magisk
88 | mkdir -p /dev/magisk/upper
89 | mkdir /dev/magisk/work
90 | ./magisk --clone-attr /system/bin /dev/magisk/upper
91 | mount -t overlay overlay -olowerdir=/system/bin,upperdir=/dev/magisk/upper,workdir=/dev/magisk/work /system/bin
92 | fi
93 |
94 | # Magisk stuffs
95 | cp -af ./magisk $BINDIR/magisk
96 | chmod 755 $BINDIR/magisk
97 | ln -s ./magisk $BINDIR/su
98 | ln -s ./magisk $BINDIR/resetprop
99 | ln -s ./magisk $BINDIR/magiskhide
100 | mkdir -p /data/adb/modules 2>/dev/null
101 | mkdir /data/adb/post-fs-data.d 2>/dev/null
102 | mkdir /data/adb/services.d 2>/dev/null
103 | $BINDIR/magisk --daemon
104 |
--------------------------------------------------------------------------------