Warning
Following these instructions, correctly or incorrectly, may leave you with a completely broken or bricked device. Furthermore, flashing your device may void your warranty - Samsung uses eFuses to permanently flag occurrences of a device running non-Samsung software, such as TWRP.I take no responsibility for what may come of using these instructions.
With the warning out of the way, I will say that I tested this process with the following environment:
- Android Device: Samsung Galaxy S3 (i9300)
- TWRP: 3.2.1-0
- Desktop OS: openSUSE Leap 42.3
Flashing and Booting into Recovery
- Download the official TWRP image for your device, and corresponding PGP signature
- https://dl.twrp.me
- Use gpg to verify your TWRP image
- Download and install Heimdall on your Linux or Windows PC
- Boot your Samsung device into Download Mode
- Simultaneous hold the Volume-down + Home/Bixby + Power buttons
- Using Heimdall on your desktop, flash the TWRP image to your device's recovery partition:
- heimdall flash --no-reboot --RECOVERY <recovery.img>
- Wait for Heimdall to output "RECOVERY upload successful"
- From Download Mode, boot your Samsung device into TWRP
- Simultaneous hold the Volume-up + Home/Bixby + Power buttons
- If you accidentally boot into regular Android, then you'll likely have to boot into Download Mode and reflash, as regular boot restores the recovery partition to its default contents
Exposing the Device as USB Mass Storage
- Unmount all partitions:
- From the TWRP main menu, select Mount, then uncheck all partitions
- Bring up a shell
- From the TWRP main menu, select Advanced -> Terminal
- adb shell could be used instead here, but the adb connection from the desktop to the device will be lost when all USB roles are disabled
- Determine which block device you wish to backup
# cat /etc/fstab
- In my case (i9300), all data is stored on /dev/block/mmcblk0 partitions
# cat /sys/devices/virtual/android_usb/android0/functions mtp,adb
# echo 1 > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun0/ro # echo /dev/block/mmcblk0 > /sys/devices/virtual/android_usb/android0/f_mass_storage/lun0/file
# echo 0 > /sys/devices/virtual/android_usb/android0/enable
# echo mass_storage,adb > /sys/devices/virtual/android_usb/android0/functions # echo 1 > /sys/devices/virtual/android_usb/android0/enable
- The attached device should appear as regular USB storage
Backup
Any Linux, Windows or macOS program capable of fully backing up a USB storage device should be usable from this point. The procedure below uses the dd command on Linux.- From your computer, determine which USB storage device to back up
ddiss@desktop:~> lsscsi ... [2:0:0:0] disk SAMSUNG File-Stor Gadget 0001 /dev/sdb
ddiss@desktop:~> sudo dd if=/dev/sdb of=/home/ddiss/samsung_backup.img bs=1M
Unfortunately, not all phones offer access to TWRP ;(
ReplyDeleteWhat's the point of using TWRP as a mere placeholder process to UNMOUNT all the OS drives, just to be able to run "dd" on them? TWRP has a single button to take a "backup" of existing system! AM i missing something here?
ReplyDeleteMy goal was to backup the entire device, including partition tables, etc. and have the ability to mount it locally. If TWRP's built-in backup suits your needs then by all means use it :-)
DeleteThank you. I used so far TeamWin to backup... and wasnt aware of this method. That fits me better. Thank you.
ReplyDelete