Skip to content

Instantly share code, notes, and snippets.

@ilhan-athn7
Created December 1, 2025 10:56
Show Gist options
  • Select an option

  • Save ilhan-athn7/460f984d12f584424ee560ed354eb41f to your computer and use it in GitHub Desktop.

Select an option

Save ilhan-athn7/460f984d12f584424ee560ed354eb41f to your computer and use it in GitHub Desktop.
Mount android partitions independently to desired path (thanks to reiryuki )
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