Last active
November 21, 2025 09:14
-
-
Save fredldotme/7bc4e5aee515d8b74a7b091599e67382 to your computer and use it in GitHub Desktop.
Recover encrypted /home from the device's recovery
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
| #!/system/bin/sh | |
| # To use this, do the following: | |
| # 1) With your device in recovery mode, enter "Advanced" and select "Mount/unmount system" | |
| # 2) Push this script to the device: adb push chroot-into-system /tmp/ | |
| # 3) Open a shell: adb shell | |
| # 4) Start a chroot: sh /tmp/chroot-into-system | |
| # 5) From here on you can unlock your encrypted home directory: fscrypt unlock /home/phablet | |
| # 6) Enter your PIN or password and hit enter | |
| # 7) Done! | |
| SYSTEM=/mnt/system | |
| [ $(getprop ro.build.version.sdk) -lt 30 ] && SYSTEM=/system_root | |
| function mount_all { | |
| # Mount a chrootable system | |
| mount -t sysfs none $SYSTEM/sys | |
| mount -o bind /proc $SYSTEM/proc | |
| mount -o bind /dev $SYSTEM/dev | |
| mount -o bind /dev/pts $SYSTEM/dev/pts | |
| # Data | |
| mount /data | |
| # Set up writable paths for accessing /home/phablet | |
| mount -o bind /data $SYSTEM/userdata | |
| mount -o bind $SYSTEM/userdata/user-data $SYSTEM/home | |
| mount -o bind $SYSTEM/userdata/system-data/var/lib/extrausers $SYSTEM/var/lib/extrausers | |
| touch /tmp/all_mounted | |
| } | |
| [ ! -f /tmp/all_mounted ] && mount_all | |
| PATH=/usr/sbin:/usr/bin:/bin:/sbin chroot $SYSTEM /bin/bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment