Created
December 1, 2025 10:56
-
-
Save ilhan-athn7/460f984d12f584424ee560ed354eb41f to your computer and use it in GitHub Desktop.
Mount android partitions independently to desired path (thanks to reiryuki )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| get_device() { | |
| PAR="$1" | |
| DEV="`cat /proc/self/mountinfo | awk '{ if ( $5 == "'$PAR'" ) print $3 }' | head -1 | sed 's/:/ /g'`" | |
| } | |
| mount_mirror() { | |
| SRC="$1" | |
| DES="$2" | |
| RAN="`head -c6 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9'`" | |
| while [ -e /dev/$RAN ]; do | |
| RAN="`head -c6 /dev/urandom | base64 | tr -dc 'a-zA-Z0-9'`" | |
| done | |
| mknod /dev/$RAN b `get_device "$SRC"; echo $DEV` | |
| if mount -t ext4 -o ro /dev/$RAN "$DES"\ | |
| || mount -t erofs -o ro /dev/$RAN "$DES"\ | |
| || mount -t f2fs -o ro /dev/$RAN "$DES"\ | |
| || mount -t ubifs -o ro /dev/$RAN "$DES"; then | |
| blockdev --setrw /dev/$RAN | |
| rm -f /dev/$RAN | |
| return 0 | |
| fi | |
| rm -f /dev/$RAN | |
| return 1 | |
| } | |
| mkdir -p /mnt/test | |
| mount_mirror /vendor /mnt/test | |
| mount -o rw,remount /mnt/test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment