Data Recovery - General Questions and Answers

Actually a few days back I was unlocking my bootloader of redmi note 6 pro phone and I didn't know of that fact that it does a factory reset during this and accidentally I lost all my data but the most important data which I lost were some videos and photos which were clicked recently like 2-3 days ago and some videos I really need help coz I need to recover those data so anyone please help me in doing that thing.

Ask authorized service center whether they have the forensic tool(s) to recover the data of interest, and if so, let them try to recover them.

jwoegerbauer said:
Ask authorized service center whether they have the forensic tool(s) to recover the data of interest, and if so, let them try to recover them.
Click to expand...
Click to collapse
actually i can't reach any authorized or non-authorized centers the only thing I can do is by my own

If phone is rooted, and if it's accessible by ADB, only then all you can do at your own is to create a 1:1 ( means: bitwise ) copy of the partitions you are interested in and store this image on your computer - what later on by forensic tools may get made readable.

jwoegerbauer said:
If phone is rooted, and if it's accessible by ADB, only then all you can do at your own is to create a 1:1 ( means: bitwise ) copy of the partitions you are interested in and store this image on your computer - what later on by forensic tools may get made readable.
Click to expand...
Click to collapse
Like Can You Share Any Video Or Something Which Explains This Set By Step

I don't have a video at hand and I won't search for such one.
These are the ADB commands you have to run - one by one
Code:
adb devices
adb su -c 'mount -o rw,remount /<NAME-OF-PARTITION-TO-GET-COPIED>'
adb reboot
adb devices
adb exec-out "dd if=/<PARTITIONS-BLOCK-DEVICE-NAME-TO-GET-COPIED> bs=4096" > C:\COPY_OF_PARTITION.img
adb su -c 'mount -o ro,remount /<NAME-OF-PARTITION-TO-GET-COPIED>'
adb reboot
where <NAME-OF-PARTITION-TO-GET-COPIED> & <PARTITIONS-BLOCK-DEVICE-NAME> are placeholders what you have to substitute by their real names.

jwoegerbauer said:
I don't have a video at hand and I won't search for such one.
These are the ADB commands you have to run - one by one
Code:
adb devices
adb su -c 'mount -o rw,remount /<NAME-OF-PARTITION-TO-GET-COPIED>'
adb reboot
adb devices
adb exec-out "dd if=/<PARTITIONS-BLOCK-DEVICE-NAME-TO-GET-COPIED> bs=4096" > C:\COPY_OF_PARTITION.img
adb su -c 'mount -o ro,remount /<NAME-OF-PARTITION-TO-GET-COPIED>'
adb reboot
where <NAME-OF-PARTITION-TO-GET-COPIED> & <PARTITIONS-BLOCK-DEVICE-NAME> are placeholders what you have to substitute by their real names.
Click to expand...
Click to collapse
Which partition should I choose for recovery

Look inside here:
Extract Android Userdata Partition for Recovery and Forensics - Root101 | Fundamentals of Linux Administration
Open Source and Linux. Guides and Ideas for Designing Highly Available and Scalable Production Environments
www.root101.net

.

Related

[GUIDE][ADB]Basic Linux/Unix Commands

Basic Linux/Unix Commands
[HIGHLIGHT] DISCLAIMER - You know the drill. I don't deem myself responsible in case you screw up your phone. Always make a backup if you don't trust yourself and if you know that you screwing up is your forte[/HIGHLIGHT]
Thanks -
mihir287 for his FAQ
sweetnsour for his extensively detailed thread
Shen - advice
Zayed from www.addictivetips.com
http://www.linuxtopia.org
This guide aims to give you a background on some of the linux commands available to you once you obtain an adb shell.
In order to obtain an ADB shell, you must have adb set up on your computer (all ADB really consists of in windows is adb + 2 dlls + adb drivers.
However it makes sense to fully set up the Android SDK if you plan on developing for Android.
You need to install adb or get Terminal Emulator. To install adb and get more info about it visit here.
NOTE = All commands in linux/unix are CASE SENSITIVE.
Shell Commands
These commands are to be typed after typing
Code:
adb shell
In the Command Prompt.
Or, you can proceed normally if you are using a Terminal Emulator.
1. cd - Change Directory
To change to any directory, simply type:
Code:
cd <dirname>
dir name is the path. For instance, to switch to system/etc, type:
Code:
cd /system/etc
'..' will allow you to go back one directory. In our example, typing:
Code:
cd ..
would take you back to /system
2. ls - List Files
To list all the files in whatever directory you're in, simply type:
Code:
ls
pressing enter after, of course. This will list all NON-HIDDEN files/directories.
Code:
ls /system/etc
will list the contents of system/etc
Code:
ls -l
will list all NON-HIDDEN files in your current directory with additional details
Code:
ls -a
will list all files/directories(including hidden) within your current directory
Code:
ls *.extension
will list all the files wit the specified extension in the directory
For example i wanna list all apps -
Code:
cd /system/app
ls *.apk
3. su - SuperUser
The standard adb shell (unless you're on an insecure kernel/ramdisk), will be a non-root shell ($)
To obtain root priviliges (if your phone is rooted), simply type:
Code:
su
on obtaining superuser priviliges, you will be presented with a # symbol, which represent a root shell.
4. chmod - Change Mode
The two most commonly used 'modes' you'll come across in Android are '777' and '755'
These numerical pemissions have different meanings, of course. This can be a little confusing, so I hope this explains it in a simple to understand way.
As you can see, there are three numbers in the following example; 'chmod 755'
So, to break that down: The first number in the sequence, '7', represents the USER (aka, you). The second number in the sequence, '5', represents the GROUP (users who are members of the file's group) and the third number, '5' represents OTHERS (aka, everyone else).
Now to explain why they are 755, and the significance of those numbers, see the following list:
7 Full
6 Read/Write
5 Read/Execute
4 Read Only
3 Write/Execute
2 Write Only
1 Execute
0 None
So in the instance of 777, you can see that USER, GROUP and OTHERS have FULL access to the file in question.
To change the permissions of one file (apns-conf.xml for example, type:
Code:
chmod 777 /system/etc/apns-conf.xml
To change the permissions of all files in a directory, use the -R (recursive)option:
Code:
chmod 777 -R /system/etc
5. pwd - Print Working Directory
Couldn't be more simple. if you want to find out which dirctory you're currently in, type:
Code:
pwd
and press enter.
6. cat - Concatenate (evolved from)
The cat command if used to list a file's contents on your screen; or pass via pipeline to use with other Linux commands.
cat /proc/mounts
will output the various mount points in your android OS.
Note that there are many other uses for the cat command.
7. mount - remount as r/w or r/o
The mount command is used to mount a directory as r/w[Read-Write which allows you to modify it] or r/o[Read-Only]
Mount info -
Code:
mount
To mount as r/w and r/o respectively use -
Code:
mount -o remount rw <dirname>
or
mount -o remount ro <dirname>
To mount /system i will use
Code:
mount -o remount rw /system
or
mount -o remount ro /system
8. cp, mv, rm - Copy, Move, Remove
Use the 'cp' and 'mv' commands to copy, move a file/directory respectively and 'rm' to remove one. They are equivalent to copy+paste and cut+paste and delete
If you are planning to copy/move/remove from your android to anywhere else or viceversa you need to mount as r/w prior to this and mount as r/o after it.
They can be used as
Code:
cp <source> <destination>
or
mv <source> <destination>
or
rm <source>
For example i wanna copy/move/delete my zip file to system/media [after mounting system]
Code:
cp /sdcard/bootanimation.zip system/media
or
mv /sdcard/bootanimation.zip system/media
or
rm /sdcard/bootanimation.zip
9. Auto - Install Applications To SDCard
Type the following -
Code:
pm setInstallLocation 2
10. logcat
A logcat is basically a command to view messages in one of the system logs.
Logcat is the command to view the internal log of the Android system.
Viewing logcat is often the best way - and sometimes the only way - to diagnose a problem.
Dev's always need proper and useful feedback. So if you are testing something, you can always obtain the errors an report back to the dev who in turn can solve your problem efficiently.
Code:
su
logcat > /sdcard/log.txt
Will obtain the logcat to your sdcard as log.txt
Googlers have a sense of humour so even 'lolcat' works identically as 'logcat'
Code:
lolcat
Some dev's require extensive logcat info. To know more about it continue reading here.
ADB Commands
The following commands are to be type in your adb folder directory.
For instance, mine is in C:\android-sdk-windows\platform-tools so i will type
Code:
cd C:\android-sdk-windows\platform-tools
and then proceed with the following code lines
Alternatively you can change your PATH variable
Setting Path on Windows
For Windows XP:
Start -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Close the window.
For Windows Vista/Windows 7:
Right click “My Computer” icon
Choose “Properties” from context menu
Click “Advanced” tab (“Advanced system settings” link in Vista)
In the Edit windows, modify PATH by adding the location of the class to the value for PATH. If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Click to expand...
Click to collapse
1. Check Connected Phone
To display list of available devices, type
Code:
adb devices
You will get the following output
Code:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 21342737ft6273
where the number indicates your devices serial number usually the one one the back of your phone[needs citation]
2. Login To Android Shell
Code:
adb shell
After pressing enter you will either see '$' or '#'
If you get ‘#’ after typing adb shell, you have already get root access on the phone, no need to type su. Otherwise if you get ‘$’ , type ’su’ to get root access (only for rooted device).
3. Install Application
This command installs the app whose directory is specified by you.
Code:
adb install appname.apk
Note that the name of the application should be without any blank spaces in between. Say i have an app called pes 12.apk, I rename it to pes_12.apk - Also don't miss out the .apk extension
example
Code:
adb install C:\programfiles\pes_12.apk
4. Files From Phone To PC And Vice Versa
For Phone - PC
Code:
adb pull <source> <destination>
For PC-Phone
Code:
adb push <source> <destination>
Example
Code:
adb pull /sdcard/bootanimation.zip C:\programfiles
Code:
adb push C:\programfiles\bootanimation.zip /sdcard
^Self Explanatory
5. Reboot To (Normal/Recovery/Bootloader)
Type the following to reboot normally or to recovery/bootloader respectively
Code:
adb reboot
Code:
adb reboot recovery
Code:
adb reboot bootloader
Some Useful Codes-
I do not know many. If you have any suggestions please do tell me
Type them in line by line and don't type in the '$' and '#'
1. Rooting
Code:
adb devices
adb shell
$ echo 1 > /data/local/lge_adb.conf
Then you can proceed onto using SuperOneClick
2. Installing Custom Recovery
The recovery.img and flash_image files must be in /sdcard
Code:
adb shell
$ su
# mount -o remount rw /system
# cat /sdcard/flash_image > /system/xbin/flash_image
# chmod 755 /system/xbin/flash_image
# flash_image recovery /sdcard/recovery.img
# mount -o remount ro /system
# exit
$ exit
adb reboot recovery
Will add FAQ later if needed
Ohh ! so much detail !
As far as i can see its very well written.
Will read tomorrow
Awesome guide! Thank you!
Sent from my LG-P500 using xda premium
MaKTaiL said:
Awesome guide! Thank you!
Sent from my LG-P500 using xda premium
Click to expand...
Click to collapse
Glad You Like It
Rutuj said:
Glad You Like It
Click to expand...
Click to collapse
I knew Half of this but the way you put it is basically noob written and easy to follow through. Thumbs up for this guide. I wish someone posted this when I first started playing with android. This would've made life easier for me >.<
Sent from my LG-P500 using XDA App
purple1 said:
I knew Half of this but the way you put it is basically noob written and easy to follow through. Thumbs up for this guide. I wish someone posted this when I first started playing with android. This would've made life easier for me >.<
Sent from my LG-P500 using XDA App
Click to expand...
Click to collapse
This doesnt make life easier, if one command wrong, bam! A fresh brick phone...
Sent from my Nexus One using Tapatalk
and how to uninstall app from adb ?
nice guide btw
Great guide. I would suggest you add details on how to get logcat as well, since many developers will find it useful if users post logs of bugs
Code:
su
logcat > /sdcard/log.txt
mihir287 said:
Great guide. I would suggest you add details on how to get logcat as well, since many developers will find it useful if users post logs of bugs
Code:
su
logcat > /sdcard/log.txt
Click to expand...
Click to collapse
Thanks !
Added !
Bump !
Thanks commands working perfect.
Tell me onething..how did you get time to type all of this?
royalflusher9 said:
Thanks commands working perfect.
Tell me onething..how did you get time to type all of this?
Click to expand...
Click to collapse
Compiling info takes time.
Type time = 30 mins
Nice thread for n00bs like me !!!! Thanks very much!!!1
Bumping this thread
very helpful guide ......
thanxxxx

[GUIDE] How to make a nandroid backup directly to your computer without using sdcard

INFORMATION
This guide is intended to make a full backup of your android phone (the entire memory block with all partitions) or a single partition (including sdcards, etc) directly to your computer, in either
Block level (with dd): for single partitions or whole memory block (all partitions in one piece). The backup always has the same size which is the size of the partition.
File level (with tar): only for individual partitions. This only includes files and folders, so occupies much less space, depending on how much filled is the partition.
It can be done with the phone powered on or from ClockWorkMod Recovery (from both ADB works, while in Fastboot doesn't so won't apply). Unless specified the commands meant to be used from Windows. For Linux and Unix is similar.
REQUIREMENTS
Rooted Android Phone
Busybox installed on your phone
If you are using Linux / OS X you have native tools, for Windows download Cygwin, and install with it netcat, pv and util-linux. Get them from Cygwin's setup.exe
ADB installed.
Make sure adb.exe is in your windows' path. See here and here, or use Path Manager.
Android phone with USB Debugging enabled, and the proper drivers installed on Windows so the phone is recognized. Typing 'adb devices' on a terminal should show your device.
PARTITION IDENTIFICATION
You now have to identify the partition or block device that you want to backup. For a single partition you can use either tar or dd, while for the entire memory block you can only use dd.
For example, on Galaxy Nexus you have the list of partitions here and for Galaxy S2 here.
Usually on android, the entire block containing all partitions is located at /dev/block/mmcblk0 and the data partitions is a subpartition of it. You can push parted with GPT support to your device and see all information on a partition or block.
Whole phone memory -> /dev/block/mmcblk0 (may vary, in some phones this is the sdcard)
Subpartitions -> depends on each device. Usually at /dev/block/platform/dw_mmc/by-name/ there are listed by name linking to the real device.
Back up of the whole memory block (via adb)
Connect the phone in ADB mode and unlock the screen.
Open one Cygwin Terminal and enter (replace mmcblk0 if needed):
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox dd if=/dev/block/mmcblk0
You will see the cursor blinking at the left. Now the phone is waiting to send the block over the network.
Open another Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw
You will see how the image size is growing until it finishes. Now you have the whole phone backed up in raw format. You can see the contents of the GPT partition with gptfdisk tool, available for windows, linux and such. See official website and sourceforge to get it. You can do it the same from ClockWorkMod Recovery but you have to mount first the /system partition since the busybox included with clockworkmod does not come with netcat and you have to use the one from the system partition.
With further linux tools you could edit or extract single partitions from the whole block.
You can use adb via wifi as well with applications like WiFi ADB.
Back up of the whole memory block (via wifi)
Original post: [Q] Nandroid directly to computer w/o sdcard
We need to install a FTP server on the computer or the other device, configure a user with a password if we want to, and set some port. It uses by default 21 but this example uses 40. We must set a home dir for the user with write permissions.
Usually is a good idea to put myfifo in /cache not in /data because we may overwrite sensitive data in case we want to use that raw image for data recovery.
Open one Cygwin terminal
Code:
adb shell
su
mkfifo /cache/myfifo
ftpput -v -u user -p pass -P 40 COMPUTER_IP block.raw /cache/myfifo
Open another Cygwin terminal
Code:
adb shell
su
dd if=/dev/block/mmcblk0p12 of=/cache/myfifo
Tips:
- Fifos only can be made on linux native filesystems, for example on a FAT partition is not possible.
- Reading from a partition does not modify it.
Now check on Filezilla Server the speed
Back up of the whole memory block (USB tethering, Wifi tethering)
To use tethering you have to disconnect the computer from all networks and connect it only to the phone with the type of connection you want.
Once you connect it, you can view the IP of the computer and the IP of the phone from connection properties. The ip is the computer ip and the gateway is the phone's ip.
Wifi Tethering: Computer <---Wifi---> Phone <---3G---> Internet
USB Tethering:
Computer <---USB---> Phone <---Wifi---> Internet
Conputer <---USB---> Phone <---3G---> Internet
This is exactly the same as via wifi, except that the transfer speed is much higher because the computer and the phone are directly connected, instead of using a router as a gateway. In this case, the gateway is the phone. USB tethering has the highest transfer rate.
Back up of a single partition (raw = every bit of the partition)
It is exactly the same as the the previous but replacing mmcblk0 by the corresponding partition. You can use in this particular case several software to read the partition from windows, depending on partition filesystem: DiskInternals Linux Reader, Ext2Read, Ext2 File System Driver for Windows, Ext4Explore, plugin for Total Commander and ImDisk Virtual Disk Driver. You can also use recovery software on individual partitions like Recuva in combination with VHD Tool or command line tools included with operating systems.
Back up of a single partition (tar = only files and folders)
In this case, you need the partition mounted. To see the list of mounted partitions type on Cygwin Terminal
Code:
adb shell mount
Now you need to know where is mounted the partition you want to backup, for example the firmware is mounted on /system, which is the ROM.
In this case you will have to open three terminals, because of android limitations:
Open one Cygwin terminal and create a fifo, in /cache, for example, and redirect the tar there
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox mkfifo /cache/myfifo
/system/xbin/busybox tar -cvf /cache/myfifo /system
We have to do it this way because redirecting the tar to stdout (with - ) is broken on android and will corrupt the tar file.
Open a second Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox cat /cache/myfifo
Open a third Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > system.tar
You can browse the tar file with Winrar, Total Commander, PeaZip and almost any compression tool. Note that you shouldn't extract files or edit it since the tar format saves the permission and owner data for each file, that is lost when extracted to FAT / NTFS partitions and you will mess things when restoring.
LINKS
[GUIDE] Internal Memory Data Recovery - Yes We Can!
How to Create and Attach a Virtual Hard Disk in Windows 7
[Guide] Types of Android backups
mohsyn said:
On newer android versions (Im on 7.2) data folder has a folder media which is link to sdcard and one ends up backing up entire sd card. I had a 64gb backup which wasn't necessary
In order to avoid skipping the media folder i had to do some trial and error because busybox tar command is not completely the same as GNU tar.
Would appreciate if you can mention it in the mail guide to use the following command to backup /data folder without copying sdcard files
In first terminal
tar cv --exclude data/media/0 -f /cache/myfifo /data
in 3rd terminal
nc 127.0.0.1 5555 | pv -i 0.5 > data.tar
no change in second terminal
Cheers
Click to expand...
Click to collapse
Umm...how to restore back from computer?
Sent from MARVEL
I am a little new to this, I have installed Android sdk and i am able to see my device by using "adb devices" , i have also installed Cygwin, now i want to backup whole phone memory block so i tried executing the first line on cygin "adb forward tcp:5555 tcp:5555" i get an error saying -bash: adb :command not found.
I am sorry if i am missing any thing, please guide me, and also what do you mean by "download Cygwin, and install with it netcat, pv and util-linux"
Thanx a ton !!
aunriz said:
I am a little new to this, I have installed Android sdk and i am able to see my device by using "adb devices" , i have also installed Cygwin, now i want to backup whole phone memory block so i tried executing the first line on cygin "adb forward tcp:5555 tcp:5555" i get an error saying -bash: adb :command not found.
I am sorry if i am missing any thing, please guide me, and also what do you mean by "download Cygwin, and install with it netcat, pv and util-linux"
Thanx a ton !!
Click to expand...
Click to collapse
You've done almost everything! But you skipped the section "make sure adb is in your path"
Probably you have adb.exe in the path
Code:
C:\Program Files (x86)\android-sdk\platform-tools\adb.exe
So you have to just add it to the Cygwin's path (would be better if you had added it earlier to the windows' path and cygwin will import it automatically but it is ok)
Code:
export PATH="/cygdrive/c/Program Files (x86)/android-sdk/platform-tools":$PATH
Remember to backup the path previously if you want.
Code:
echo $PATH > mypathbackup.txt
scandiun said:
You've done almost everything! But you skipped the section "make sure adb is in your path"
Probably you have adb.exe in the path
Code:
C:\Program Files (x86)\android-sdk\platform-tools\adb.exe
So you have to just add it to the Cygwin's path (would be better if you had added it earlier to the windows' path and cygwin will import it automatically but it is ok)
Code:
export PATH="/cygdrive/c/Program Files (x86)/android-sdk/platform-tools":$PATH
Remember to backup the path previously if you want.
Code:
echo $PATH > mypathbackup.txt
Click to expand...
Click to collapse
Thanks for replying but i cant seem to run the 3rd line , see this
[email protected] ~
$ adb forward tcp:5555 tcp:5555
[email protected] ~
$ adb shell
$ /system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox dd if=/dev/block/mmcblk0
reloc_library[1311]: 10182 cannot locate 'android_reboot'...
CANNOT LINK EXECUTABLE
i hav sucessfully installed busybox v1.14.3, i am not sure what is causing the problem
EDIT:
i found that my directory ws system/bin instead of xbin
so i changed it and first part worked correctly, now i cant seem to get the second part
[email protected] ~
$ adb forward tcp:5555 tcp:5555
[email protected] ~
$ cd c:/
[email protected] /cygdrive/c
$ nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw
-bash: nc: command not found
-bash: pv: command not found
aunriz said:
[email protected] /cygdrive/c
$ nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw
-bash: nc: command not found
-bash: pv: command not found
Click to expand...
Click to collapse
You don't have installed pv and netcat on cygwin. Run the setup.exe and install them.
If you run
Code:
whereis pv
whereis nc
should give you some path (in cygwin) but applies similar inside android.
scandiun said:
You don't have installed pv and netcat on cygwin. Run the setup.exe and install them.
If you run
Code:
whereis pv
whereis nc
should give you some path (in cygwin) but applies similar inside android.
Click to expand...
Click to collapse
Now i hav installed cv and nc and commands run sucessfully, but i get the raw file as just 1kb
First terminal:
[email protected] ~
$ adb forward tcp:5555 tcp:5555
adb shell
[email protected] ~
$ adb shell
$ /system/bin/busybox nc -l -p 5555 -e /system/bin/busybox dd if=/dev/block/mmcblk0
/system/bin/busybox nc -l -p 5555 -e /system/bin/busybox dd if=/dev/block/mmcblk0
$
second terminal:
[email protected] ~
$ adb forward tcp:5555 tcp:5555
[email protected] ~
$ cd c:/
[email protected] /cygdrive/c
$ nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw
55 B 0:00:00 [10.7kiB/s] [<=> ]
[email protected]
No idea what you may be doing wrong
Listen, I appreciate the guide, and it being basically the only one which popped up in google results, I can't gripe too much, but... you really, really need to make it more clear.
The point of a guide is to help a large group of people with varying degrees of knowledge (and if it's a guide targeted at a specific group of people, i.e tech savvy, then it needs to be indicated as such).
With that working definition in place, it follows that you should be as specific as possible; think of *everything*. By doing so, you not only avoid headaches for the people reading the guide, but for yourself as well since you don't have to reply to comments which might've otherwise been avoided.
I would post a question, but I'll probably have figured this out (with a good 1+ hours of searching no doubt) before anyone responds.
Here are some examples of what could be more specific:
"ADB installed." - what is ADB? Where's the link? It's not reasonable to assume people use these tools on a regular basis or remember them.
"You can push parted with GPT support to your device and see all information on a partition or block." - okay, so we know what it does but not how to install it or use it.
"ADB mode" - is this important? What is it? Not sure because it was glossed over.
These are just some examples. It's not the most horrendous trespass ever committed, but definitely annoying. Just spell it out from one step to the next, it works far better than topics with subheadings and unintuitive concepts being assumed as general knowledge on the behalf of noobs like me.
Edit: I'm just going to take everything off my SD card, use nandroid, and then copy the nandroid backup to computer as well. Please improve the guide, thanks.
Greatly appreciate this!
For me, a long-time UNIX and Linux administrator, this little guide was a breath of fresh air. Scandiun, *Thank You* for putting it together. It makes perfect sense to me -- just treat the phone as the linux machine it is. I'm becoming convinced that most of the more recent "developers" hanging around the android community have never used a linux machine before -- they don't seem to know what's going on, they go way out of their way to write overkill tools to do things clumsily that can already be done cleanly and quickly from the command line, and then they wrap those tools in so much mystery, black magic, and script-kiddie terminology that I can't figure out what they do either, and I certainly don't trust them doing things to my phone.
For example, I've got a new Galaxy S3, and just wasted a whole day digging around on xda, reviewing all of the "kewl rooting mods" until I got sick of it. Why the *heck* are people flashing entire partitions just to install a setuid /system/xbin/su on these devices? The rooting method I wound up using was dirt simple -- just find an rc exploit and use it to install an 'su' binary, by typing a few commands via adb. I used a variation of the exploit mentioned in http://seclists.org/fulldisclosure/2012/Aug/171, and elaborated in http://forum.xda-developers.com/showthread.php?t=1790104, http://forum.xda-developers.com/showthread.php?t=1792342, http://galaxys3root.com/galaxy-s3-root/how-to-root-u-s-canadian-dual-core-galaxy-s3-on-mac-osx/, and http://forum.xda-developers.com/showthread.php?t=1827518. If you are a UNIX person, you'll recognize what's going on with that exploit and be able to come up with something that suits your own needs. If you aren't a UNIX person, then you'll be completely lost. Sorta like this guide.
For anyone who doesn't yet know what adb is, or who's never used standard UNIX/Linux tools like dd, netcat, gparted, or busybox, I agree that this guide is not only not going to help you, but may actually aid you in shooting yourself in the foot with extreme efficiency. But please don't criticize or nag the OP in return for helpful advice freely given. You won't learn much about UNIX tools on an Android-related web site in any case. I recommend starting with a Linux systems administration book -- the Nemeth series is always good. But if you do take that route, you need to expect to take time to learn the basics.
Absolutely beautiful!
Thank you for this work. I was able to recover deleted files from my Galaxy Nexus' internal memory using this technique. I made a [GUIDE] using most of what you accomplished here: http://forum.xda-developers.com/showthread.php?p=34185439
Thank you, thank you, thank you! It can't be said enough. I had family photos that I would not have been able to reproduce. Much love to you and yours!
:good: :highfive: :victory:
so did anyone dare to restore the drive (all of storage, everything !)? without bricking the thing ?
mai77 said:
so did anyone dare to restore the drive? w.o bricking the thing ?
Click to expand...
Click to collapse
What drive? A partition?
scandiun said:
If you are using Linux / OS X you have native tools, for Windows download Cygwin, and install with it netcat, pv and util-linux. Get them from Cygwin's setup.exe
Click to expand...
Click to collapse
netcat is obsolete (mark to even find it) install net / nc instead
---------- Post added at 01:03 PM ---------- Previous post was at 01:03 PM ----------
scandiun said:
What drive? A partition?
Click to expand...
Click to collapse
all of storage I mean. the full monty ...
----------------------
parted seems to not work fully with Samsung galaxy Y = SGY proprietary rfs filesystem
on SGY mmcblk0 gives you the sd card, not internal storage with android.
backing up my sd card was a thing I could even do before I read this (lol)
mai77 said:
netcat is obsolete (mark to even find it) install net / nc instead
Click to expand...
Click to collapse
nc is an abbreviation for netcat. On Cygwin, you choose to install either, but for the original, written by the *Hobbit*, that allows direct execution of commands with -e and -t, you have to uncheck "Hide obsolete packages" on Cygwin's setup.exe.
The two of them are here:
Netcat 1.10 (netcat.traditional): http://www.netgull.com/cygwin/release-legacy/netcat/
Netcat 1.107 (netcat.openbsd): http://www.netgull.com/cygwin/release/nc/
mai77 said:
parted seems to not work fully with Samsung galaxy Y = SGY proprietary rfs filesystem
on SGY mmcblk0 gives you the sd card, not internal storage with android.
backing up my sd card was a thing I could even do before I read this (lol)
Click to expand...
Click to collapse
Can you post where is your whole memory block then or even the PIT file for that phone? You have an example here:
[Info] List of Samsung Galaxy S2 GT-I9100 devices and partitions
scandiun said:
Can you post where is your whole memory block then or even the PIT file for that phone? You have an example here:
[Info] List of Samsung Galaxy S2 GT-I9100 devices and partitions
Click to expand...
Click to collapse
I don't know where the "whole memory block" is or what it is. is it internal storage = NAND ?
here is the pit file:
mai77 said:
I don't know where the "whole memory block" is or what it is. is it internal storage = NAND ?
Click to expand...
Click to collapse
Yes it is the NAND. See your pit analysis here:
[INFO] Samsung Galaxy Y GT-S5360 PIT File Analysis
OK
scandiun said:
Yes it is the NAND. See your pit analysis here:
[INFO] Samsung Galaxy Y GT-S5360 PIT File Analysis
Click to expand...
Click to collapse
very interesting tool.
but how do I backup NAND in one piece on SGY ?
mmcblk0 = sd card
???blk0 = NAND
it must be somewhere ...
mai77 said:
but how do I backup NAND in one piece on SGY ?
mmcblk0 = sd card
???blk0 = NAND
it must be somewhere ...
Click to expand...
Click to collapse
Is almost sure that is under /dev/block. Please post the output of
Code:
ls -lR /dev/block

New root metod for NEW version : Sprint US 7.7.1Q-6_SPR-125_ASA-14

This is a work metod for root your not unlocked phone !
I find a solution after update to last new version
Download this : http://forum.xda-developers.com/showthread.php?t=2143437
After download and share fail with samba windows or mac sharing, you need to mount from file manage > remote storage
After fix permission go to adb folder and type :
"adb shell"
"cd /mnt/rfs0"
"./su"
"cd /"
"ln -s /mnt /storage"
Next step go to console and type :
adb kill-server
adb shell /storage/rfs0/pwn
Next : Install apk package from phone , Reboot Phone and now your phone is rooted!
Update from Play Market SuperSu and go.
Best regards,
m.
micron said:
This is a work metod for root your not unlocked phone !
I find a solution after update to last new version
Download this : http://forum.xda-developers.com/showthread.php?t=2143437
After download and share fail with samba windows or mac sharing, you need to mount from file manage > remote storage
After fix permission go to adb folder and type :
"adb shell"
"cd /mnt/rfs0"
"./su"
"cd /"
"ln -s /mnt /storage"
Next step go to console and type :
adb kill-server
adb shell /storage/rfs0/pwn
Next : Install apk package from phone , Reboot Phone and now your phone is rooted!
Update from Play Market SuperSu and go.
Best regards,
m.
Click to expand...
Click to collapse
lol if i saw this earlier i might not have unlocked my boot loader today. =) hope someone can try this
I gave this a try earlier today. I scoured through the forum to find that the new Ubuntu doesn't install ADB drivers by default, so you need to do this manually.
Anyway, I attempted to do it and got all the way to ./su. It then prompted me with the message "./su cannot execute - Permission denied". Obviously from there I can't link /mnt to /storage and I can't run pwn because it looks for the /storage folder.
If you have any suggestions how to get ./su running, let me know.
rykin said:
I gave this a try earlier today. I scoured through the forum to find that the new Ubuntu doesn't install ADB drivers by default, so you need to do this manually.
Anyway, I attempted to do it and got all the way to ./su. It then prompted me with the message "./su cannot execute - Permission denied". Obviously from there I can't link /mnt to /storage and I can't run pwn because it looks for the /storage folder.
If you have any suggestions how to get ./su running, let me know.
Click to expand...
Click to collapse
This method works but not all intructions are here.
First, you need to change permissions of su:
chown root:root su
chmod 6755 su
then run adb shell and remount / filesystem ro rw:
mount -o rw,remount /
now you can create symbolic link and run the exploit.
You can also perform rooting manually (without creating symlink and running pwn):
remount /system partition to rw: mount -o rw,remount /system
and copy su to /system/xbin, make sure that it has correct permissions (rwsr-sr-x) and that's it.
Now you can remount partitions back to ro.
Install supersu or superuser (whatever makes you happy, just check if it works correctly, superuser didn't work for me, it didn't prompt about root permission for any app, it just gave it, no matter how configured it was), Then install busybox, if you need one.
And you're done.
YES! Glad I waited!
Sent from my XT897 using xda premium
ujoty said:
This method works but not all intructions are here.
First, you need to change permissions of su:
chown root:root su
chmod 6755 su
then run adb shell and remount / filesystem ro rw:
mount -o rw,remount /
now you can create symbolic link and run the exploit.
You can also perform rooting manually (without creating symlink and running pwn):
remount /system partition to rw: mount -o rw,remount /system
and copy su to /system/xbin, make sure that it has correct permissions (rwsr-sr-x) and that's it.
Now you can remount partitions back to ro.
Install supersu or superuser (whatever makes you happy, just check if it works correctly, superuser didn't work for me, it didn't prompt about root permission for any app, it just gave it, no matter how configured it was), Then install busybox, if you need one.
And you're done.
Click to expand...
Click to collapse
Thank you. I just tried this and it worked. Confirmed with Root Checker. :>
micron said:
This is a work metod for root your not unlocked phone !
I find a solution after update to last new version
Download this : http://forum.xda-developers.com/showthread.php?t=2143437
After download and share fail with samba windows or mac sharing, you need to mount from file manage > remote storage
After fix permission go to adb folder and type :
"adb shell"
"cd /mnt/rfs0"
"./su"
"cd /"
"ln -s /mnt /storage"
Next step go to console and type :
adb kill-server
adb shell /storage/rfs0/pwn
Next : Install apk package from phone , Reboot Phone and now your phone is rooted!
Update from Play Market SuperSu and go.
Best regards,
m.
Click to expand...
Click to collapse
Thanks, I think this is exactly what I am looking for per this thread. Unfortunately, I don't quite have the knowledge (yet) to completely understand what you mean. I've rooted several phones, but never had to use ADB before so am unfamiliar with it. Also, what do you mean by this: "After download and share fail with samba windows..."?
cscotti said:
Thanks, I think this is exactly what I am looking for per this thread. Unfortunately, I don't quite have the knowledge (yet) to completely understand what you mean. I've rooted several phones, but never had to use ADB before so am unfamiliar with it. Also, what do you mean by this: "After download and share fail with samba windows..."?
Click to expand...
Click to collapse
By reading this link you will know hot to setup samba installation on a UBUNTU live cd. After doing that on your phone you should go to your FILE MANAGER --> remote storage and add the samba share to your phone. On the UBUNTU live cd, on your samba folder you should do this:
Code:
cd /path/to/share
wget http://vulnfactory.org/public/motoshare.tgz
tar xvf motoshare.tgz
sudo chown root:root pwn
sudo chmod 6755 pwn
After that you should put your phone in USB debugging mode and connect it to your PC. On your PC your should download the platform-tools folder of the Android SDK. The platform-tools folder contains adb (MAC) adb.exe (Windows) file. After you have adb, on your WIndows/MAC PC you should type:
Code:
./adb shell
cd /mnt/rfs0
./su
mount -o rw,remount /
cd /
ln -s /mnt /storage
exit (to exit the ADB shell)
adb kill-server
adb shell /storage/rfs0/pwn
Next you should copy eu.chainfire.supersu.apk on your phone storage and install it with file manager.
Reboot your device! Congratulations, your phone is rooted
desyncron said:
By reading this link you will know hot to setup samba installation on a UBUNTU live cd. After doing that on your phone you should go to your FILE MANAGER --> remote storage and add the samba share to your phone. On the UBUNTU live cd, on your samba folder you should do this:
Code:
cd /path/to/share
wget http://vulnfactory.org/public/motoshare.tgz
tar xvf motoshare.tgz
sudo chown root:root pwn
sudo chmod 6755 pwn
After that you should put your phone in USB debugging mode and connect it to your PC. On your PC your should download the platform-tools folder of the Android SDK. The platform-tools folder contains adb (MAC) adb.exe (Windows) file. After you have adb, on your WIndows/MAC PC you should type:
Code:
./adb shell
cd /mnt/rfs0
./su
mount -o rw,remount /
cd /
ln -s /mnt /storage
exit (to exit the ADB shell)
adb kill-server
adb shell /storage/rfs0/pwn
Next you should copy eu.chainfire.supersu.apk on your phone storage and install it with file manager.
Reboot your device! Congratulations, your phone is rooted
Click to expand...
Click to collapse
Wow, thanks for this. I was considering trying to condense down the instructions myself before I did this, but you beat me to it, and did a better job than I would have, considering I'm a novice at this stuff.
So your method uses a linux boot for samba, but then the rest is done on windows. Question: could you do the adb stuff on Linux? Seemed like some of the posts in the atrix threads were doing it that way, and I was just curious. I have mint 14-64 bit on a couple of my machines, as well windows, and was thinking this would be an opportunity to learn it a little better.
Sent from my XT897 using xda premium
Hello,
and what if I have unlocked bootloader? Is there any other way to root this phone?
desyncron said:
By reading this link you will know hot to setup samba installation on a UBUNTU live cd. After doing that on your phone you should go to your FILE MANAGER --> remote storage and add the samba share to your phone. On the UBUNTU live cd, on your samba folder you should do this:
Code:
cd /path/to/share
wget http://vulnfactory.org/public/motoshare.tgz
tar xvf motoshare.tgz
sudo chown root:root pwn
sudo chmod 6755 pwn
After that you should put your phone in USB debugging mode and connect it to your PC. On your PC your should download the platform-tools folder of the Android SDK. The platform-tools folder contains adb (MAC) adb.exe (Windows) file. After you have adb, on your WIndows/MAC PC you should type:
Code:
./adb shell
cd /mnt/rfs0
./su
mount -o rw,remount /
cd /
ln -s /mnt /storage
exit (to exit the ADB shell)
adb kill-server
adb shell /storage/rfs0/pwn
Next you should copy eu.chainfire.supersu.apk on your phone storage and install it with file manager.
Reboot your device! Congratulations, your phone is rooted
Click to expand...
Click to collapse
well that sounds a bit intimidating but thanks for spelling it out. I'll try to work up the nerve and make some time to give this a try.
Just curious, but why can't this be compressed into a one click batch file like before?
vangelm said:
Hello,
and what if I have unlocked bootloader? Is there any other way to root this phone?
Click to expand...
Click to collapse
If your bootloader is unlocked, you can easily root. You don't need any exploits etc.
Install TWRP, it will automatically root the device. Or, install CWM and then install SuperSU afterwards, which will root the device.
arrrghhh said:
If your bootloader is unlocked, you can easily root. You don't need any exploits etc.
Install TWRP, it will automatically root the device. Or, install CWM and then install SuperSU afterwards, which will root the device.
Click to expand...
Click to collapse
It works, thank you, have a nice day.
vangelm said:
It works, thank you, have a nice day.
Click to expand...
Click to collapse
Can you share what you did? Instructions seem to say that I need to install GooManager? The summary of GooManager says I need root to use it. TIA.
micron said:
This is a work metod for root your not unlocked phone !
I find a solution after update to last new version
Download this : http://forum.xda-developers.com/showthread.php?t=2143437
After download and share fail with samba windows or mac sharing, you need to mount from file manage > remote storage
After fix permission go to adb folder and type :
"adb shell"
"cd /mnt/rfs0"
"./su"
"cd /"
"ln -s /mnt /storage"
Next step go to console and type :
adb kill-server
adb shell /storage/rfs0/pwn
Next : Install apk package from phone , Reboot Phone and now your phone is rooted!
Update from Play Market SuperSu and go.
Best regards,
m.
Click to expand...
Click to collapse
**** I wish I saw this before i went to Motorola for my warranty voiding unlock code
---------- Post added at 05:01 PM ---------- Previous post was at 04:50 PM ----------
arrrghhh said:
If your bootloader is unlocked, you can easily root. You don't need any exploits etc.
Install TWRP, it will automatically root the device. Or, install CWM and then install SuperSU afterwards, which will root the device.
Click to expand...
Click to collapse
I like TWRP but CWM in my opinion is better (more supported).
amateurhack said:
Question: could you do the adb stuff on Linux? Seemed like some of the posts in the atrix threads were doing it that way, and I was just curious. I have mint 14-64 bit on a couple of my machines, as well windows, and was thinking this would be an opportunity to learn it a little better.
Sent from my XT897 using xda premium
Click to expand...
Click to collapse
Yes. This can be done in Linux. I did it entirely with a LIVE USB. However, adb might not be installed by default (on mine it was not). To install it, do the following:
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install android-tools-adb android-tools-fastboot
Click to expand...
Click to collapse
This will prevent you from running into errors when you start typing: adb shell
swintec said:
Can you share what you did? Instructions seem to say that I need to install GooManager? The summary of GooManager says I need root to use it. TIA.
Click to expand...
Click to collapse
Either use GooManager or the fastboot flash method. I think you do need to be rooted in order for GooManager to get the permissions it requires to flash recovery... So in that case, the only way initially to flash might be fastboot flash... Sorry.
alexwoellhaf said:
I like TWRP but CWM in my opinion is better (more supported).
Click to expand...
Click to collapse
Not even sure what this means. Any zip you can flash with CWM, you should be able to flash with TWRP. No?
They're both recoveries. One is touch-based, one isn't.
Having trouble with abd
Im running Ubuntu 12.04 full install (not live CD)
When I connect my phone, dmesg see the new device, and so does lsusb
dmesg
Code:
[ 290.617377] usb 2-1: USB disconnect, device number 2
[ 295.476023] usb 2-1: new high-speed USB device number 4 using ehci_hcd
[ 295.611624] scsi9 : usb-storage 2-1:1.0
[ 296.610626] scsi 9:0:0:0: Direct-Access motorola XT897 0001 PQ: 0 ANSI: 2
[ 296.611152] sd 9:0:0:0: Attached scsi generic sg3 type 0
[ 296.613548] sd 9:0:0:0: [sdc] Attached SCSI removable disk
lsusb:
Code:
Bus 002 Device 004: ID 22b8:2e36 Motorola PCS
However no matter what, when I run "adb devices", the phone does not show up.
51-android.rules
Code:
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
This is what I get with adb
Code:
[email protected]:/tmp/share# adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached
[email protected]:/tmp/share#
What else can I do???
desyncron said:
By reading this link you will know hot to setup samba installation on a UBUNTU live cd. After doing that on your phone you should go to your FILE MANAGER --> remote storage and add the samba share to your phone. On the UBUNTU live cd, on your samba folder you should do this:
Code:
cd /path/to/share
wget http://vulnfactory.org/public/motoshare.tgz
tar xvf motoshare.tgz
sudo chown root:root pwn
sudo chmod 6755 pwn
After that you should put your phone in USB debugging mode and connect it to your PC. On your PC your should download the platform-tools folder of the Android SDK. The platform-tools folder contains adb (MAC) adb.exe (Windows) file. After you have adb, on your WIndows/MAC PC you should type:
Code:
./adb shell
cd /mnt/rfs0
./su
mount -o rw,remount /
cd /
ln -s /mnt /storage
exit (to exit the ADB shell)
adb kill-server
adb shell /storage/rfs0/pwn
Next you should copy eu.chainfire.supersu.apk on your phone storage and install it with file manager.
Reboot your device! Congratulations, your phone is rooted
Click to expand...
Click to collapse
I am trying to run through these steps. For starters, when I enter the 'adp shell' I do not have a /mnt/rfs0 directory. The shared samba directory actually mounts at /storage/rfs0. No biggie. I go to that directory to run ./su. The su command runs, and I can see a pop up notification on my phone indicating the adb shell has been granted admin rights. The problem is that the ./su command never returns. As a matter of fact, if I just left it sit there, I get the admin rights pop up notification on my phone about once per minute so it seems like the su command is in some loop.
At this point I am stuck. I cant remount my file system as read/write without SU. I can run the ./su command in a different process, either in another adb shell or with the ./su& command but that does me no good as I cant execute any root commands in that same process.
Is there something that needs to change with the su command for the newer version my phone is running? I am running 9.8.2Q-122_XT897_FFW-5.
Thanks.
Use 'motochopper', search for it on xda then root is just one click away
Sent from my XT897 using xda app-developers app

What kind of information can be restored after the factory reset?

Hello,
The question is pretty straightforward - is it possible to restore the data on the phone that had existed before the factory reset was made?
If I sell my phone on ebay can someone get any glimpse on what has been done with my phone?
e2com said:
The question is pretty straightforward - is it possible to restore the data on the phone that had existed before the factory reset was made?
Click to expand...
Click to collapse
It is still possible to recover much data after an factory reset. Unless you cleaned the drive properly. Fact is that there are user data still accessible on almost 40% of all phones bought at pawn shops.
To clean a drive you basically overwrite every single bit of the storage with an binary zero. This an very hard process to do manually therefore I would recommend using an data eraser tool such as:
Jihosoft Mobile Privacy Eraser - $49 /One-time
MobiKin Eraser for Android - $49 /One-time
Dr.Fone Data Eraser - $14.95 /Year or $19.95 /One-time
Or just use ADB to wipe all partitions you made changes to. As jwoegerbauer suggested.
e2com said:
If I sell my phone on ebay can someone get any glimpse on what has been done with my phone?
Click to expand...
Click to collapse
So short answer yes, it is very much likely that they can recover your data. Therefore I recommend wiping before selling it.
A sequence of 3 ADB commands is enough to unrecoverably wipe Android's user-data, provided the /data partition is mounted as RW
Code:
adb devices
adb shell "dd if=/dev/null of=/dev/block/bootdevice/by-name/userdata bs=4096"
adb shell "dd if=/dev/zero of=/dev/block/bootdevice/by-name/userdata bs=4096"
jwoegerbauer said:
A sequence of 3 ADB commands is enough to unrecoverably wipe Android's user-data, provided the /data partition is mounted as RW
Code:
adb devices
adb shell "dd if=/dev/null of=/dev/block/bootdevice/by-name/userdata bs=4096"
adb shell "dd if=/dev/zero of=/dev/block/bootdevice/by-name/userdata bs=4096"
Click to expand...
Click to collapse
I learned something new today.
jwoegerbauer said:
A sequence of 3 ADB commands is enough to unrecoverably wipe Android's user-data, provided the /data partition is mounted as RW
Code:
adb devices
adb shell "dd if=/dev/null of=/dev/block/bootdevice/by-name/userdata bs=4096"
adb shell "dd if=/dev/zero of=/dev/block/bootdevice/by-name/userdata bs=4096"
Click to expand...
Click to collapse
Hello,
when I run adb shell "dd if=/dev/null of=/dev/block/bootdevice/by-name/userdata bs=4096"
I get this:
dd: /dev/block/bootdevice/by-name/userdata: Permission denied
even though I run the command as sudo and enter my admin password. Any idea what I am doing wrong?
Are you sure that /data is mounted as RW?
TrulyPain said:
Are you sure that /data is mounted as RW?
Click to expand...
Click to collapse
no. How do I check it please?
e2com said:
no. How do I check it please?
Click to expand...
Click to collapse
It is quite different whether which device and android version you have. But usually, you write cat /proc/mounts in ADB. Then you shall see whether /data are mounted as RO or RW.
TrulyPain said:
It is quite different whether which device and android version you have. But usually, you write cat /proc/mounts in ADB. Then you shall see whether /data are mounted as RO or RW.
Click to expand...
Click to collapse
Okay, just ran your command and could not find /data at all.
I can see /proc /dev /sys /run but not /data
Maybe it has not been mounted at all?
Sorry, I am not very experienced with this but I am familiar with the terminal
How do I mount /data partition ?
android smartphones are encrypted by default. simply factory reset is enough nowadays to render userdata unrecoverable. on factory reset, the encryption key is securely deleted. there is no way to recover encryption key, therefore no way to decrypt data.

Android 12 and Nandroid Backup.... ???

Using a Xiaomi Mi11 (rooted). Recently upgraded to MIUI 13 which is based on Android 12. Was going to do my usual TWRP backup before bringing the phone in to fix some minor problems with sticky volume keys, when I realized (!) my TWRP cannot even mount the /data partition, let alone decrypting and doing any backup.
So I started reading up on TWRP developments, and realized TWRP for now has lost its ability to see anything under /data if your phone is on Android 12.
Never a fan of things like Titanium backup where the backup is done on an app-by-app basis, so a lot of of settings like magisk modules / phone behavior, etc etc cannot be retained (at least that was my impression of it when I briefly tried those solutions). So when I decided to bring my phone in for repair anyway, I went ahead and wiped the phone clean, and had to live with losing 10 day's worth of my data - 10 days because fortunately I did a backup just before I upgraded from MIUI 12 to MIUI 13 10 days ago... (yeah could have done a lot of manual work to salvage some of the data before I wiped it clean, but I didn't bother with the tedious processes).
So I now have a fixed phone, no more sticky buttons, and restored my nandroid backup with the older MIUI 12 system (android 11 based), and not even considering moving back to MIUI 13 until there is a feasible way to do a TOTAL backup of the /data partition, in others words a nandroid backup on Android 12....
Question - is there any feasible method of doing a Nandroid Backup on an Android 12 system, with or without TWRP?
Thank you !!!
A NANDroid-backup is the bitwise 1:1 copy of existing Android system.
If phone's Anndroid OS is rooted then you always can launch a NANDroid-backup.
This can get achieved by pure ADB commands what of course requires ADB is enabled on phone.
xXx yYy said:
A NANDroid-backup is the bitwise 1:1 copy of existing Android system.
If phone's Anndroid OS is rooted then you always can launch a NANDroid-backup.
This can get achieved by pure ADB commands what of course requires ADB is enabled on phone.
Click to expand...
Click to collapse
Could you elaborate?
I can picture this issue -
if you do "adb shell" to enter terminal (or plain adb pull?) while your phone is switched on, a lot of files are being locked and/or being modified while the phone OS is running so how can someone just take a snapshot of everything under /data even with proper adb commands?
And if you go to recovery mode first, well at the present time no TWRP can access the data partition it seems. So again even with the appropriate adb commands, no copying is possible....?
Any clarification appreciated !
You would run
Code:
adb wait-for-device
adb root & adb shell "stop"
adb shell "mount -o rw,remount /data"
: run the backup command here
adb shell "start" & adb unroot
xXx yYy said:
You would run
Code:
adb wait-for-device
adb root & adb shell "stop"
adb shell "mount -o rw,remount /data"
: run the backup command here
adb shell "start" & adb unroot
Click to expand...
Click to collapse
Dear Android export @xXx yYy - wow ! This looks really promising !!
I just did a quick test by going straight to adb shell, "su", then "stop". My phone screen totally went blank, and I was amazed ! This is awesome !!! "start" and after a while the phone boots up again.
I then tried "top" while the phone is stopped. It seems to still have a few android related processes running, so I am not 100% sure if the whole system has been frozen. But you obviously know what you are talking about, and I have faith in you.
(by the way, I cannot "adb root", seems like after doing a quick search I will need to make my phone think it is a development build by patching the adbd daemon first on my phone.. suggestions on what to do appreciated)
You have just made me decide to spend the coming hours to test the following. Let me know if I should skip any of the steps below because you know it works so I don't need to waste time to validate:
1. Do a proper backup with TWRP first in case I screw up anything
2. start a terminal session with adb shell
3. "su", "stop"
4. "cd /data"
5. "tar -cvpzf /data/backup.tar.gz -C /data"
(If no error, this should be my nandroid backup...?)
6. flash phone and wipe everything clean, so it is back to brand new status, non-rooted
7. reboot phone, see if it is starting new as if I have just bought the phone
8. root the phone, then try and "stop", "delete everything under /data except /data/media", "delete everything under /data/media", "copy backup.tar.gz back to /data", "tar -xvzf /data/backup.tar.gz -C /"
9. If phone works and is back to the state immediately before backup, then restore successful
Take note that
Code:
adb root
is giving root access to adb ( adbd - read: adb daemon )
what has nothing to do with giving root access to current Android user with following shell command
Code:
adb shell "su"
Also take note that Android services aren't located in /data partition, the partition you want to back up.
With @xXx yYy 's help I think I am getting somewhere.
So essentially a "stop" command in android will stop Zygote (i.e. the mother of all app processes if I am not mistaken). Once you have stopped Zygote, I believe you are then free to make a duplicate of the entire /data environment.
So far that's exactly what I have done. Created a tar.gz file with a size of around 40GB. I believe I am halfway there in my quest to do Nandroid without TWRP, but what I still need to try is to restore the tar file after factory resetting the phone. Will be a time consuming process (as obviously I will also need to have a tried-and-true real backup created first in case I screw something up... I am doing everything on my main phone that I actually use everyday), so I will continue my experiment in the coming days.
One question I have already encountered however - I still cannot do "adb root", which would have allowed me to directly create the backup tar file AND pipe it to my PC all in one go. So far I have had to tar all within the phone, which means space will be a constraint, and it is more time consuming creating the backup file THEN think of a way to transfer that file out of the phone. Already posted a question here asking for help, and if anyone knows of a good way to get adbd to grant adb root request, please let me know.
Above all else, once I have a working method, and I have polished the process, I will be happy to share. I suspect many others are also yearning for a good backup / restore procedure on Android 12.
one can't backup /data partition this way, because tar is just a toybox applet not cabable of preserving secontext. get a gnu tar binary (for example from opengapps installer), set mount namespaces to global, set selinux permissive (if kernel allows it, important) and run from su
/storage/1234-5678 is exFAT and has enough free disk space
Code:
tar --selinux --xattrs --numeric-owner -vcpPf /storage/1234-5678/data.tar /data
/storage/1234-5678 is vfat or less free disk space
Code:
tar --selinux --xattrs --numeric-owner -vcpP /data | gzip | split -a 1 -b 1024m - /storage/1234-5678/data.tar.gz.
another approach would be loop mount some file and busybox cp -avc everything where the -c flag is responsible for secontext (proper busybox required)
--numeric-owner flag is recommended if you are planning to extract it on linux PC later
you could also exec-out straight to PC if no MicroSD Card available, but requires gzip or other compressed stream, otherwise windows will mess up linefeed with carriage return and render your file unreadable
Code:
adb exec-out "su -c 'tar --selinux --xattrs --numeric-owner -vcpP /data | gzip'" > data.tar.gz
restoring .tar.gz from TWRP is absolutely possible, it's just that TWRP can't handle encrypted userdata partition (yet)
Code:
cat /external_sd/data.tar.gz.* | gzip -d | tar --selinux --xattrs -vxpPC /
(where tar must called with full path to binary like /cache/tar or /tmp/tar, or unlink /sbin/tar applet and place binary /sbin, or just rename it gtar)
Note: bitwise 1:1 copy of apps is not possible/sufficient if you factory reset your device, because apps might save data in TEE TrustZone (which is flushed on factory reset)
Hi @seemebreakthis, very interesting discussion on Android 12 backup!
Did you reach a workable solution with this?
Since we can restore most apps from a Google backup, it seems the real issue is to recover the user settings etc. after the Google restore.
Interested in this. Any success thus far?
aIecxs said:
one can't backup /data partition this way, because tar is just a toybox applet not cabable of preserving secontext. get a gnu tar binary (for example from opengapps installer), set mount namespaces to global, set selinux permissive (if kernel allows it, important) and run from su
/storage/1234-5678 is exFAT and has enough free disk space
Code:
tar --selinux --xattrs --numeric-owner -vcpPf /storage/1234-5678/data.tar /data
/storage/1234-5678 is vfat or less free disk space
Code:
tar --selinux --xattrs --numeric-owner -vcpP /data | gzip | split -a 1 -b 1024m - /storage/1234-5678/data.tar.gz.
another approach would be loop mount some file and busybox cp -avc everything where the -c flag is responsible for secontext (proper busybox required)
--numeric-owner flag is recommended if you are planning to extract it on linux PC later
you could also exec-out straight to PC if no MicroSD Card available, but requires gzip or other compressed stream, otherwise windows will mess up linefeed with carriage return and render your file unreadable
Code:
adb exec-out "su -c 'tar --selinux --xattrs --numeric-owner -vcpP /data | gzip'" > data.tar.gz
restoring .tar.gz from TWRP is absolutely possible, it's just that TWRP can't handle encrypted userdata partition (yet)
Code:
cat /external_sd/data.tar.gz.* | gzip -d | tar --selinux --xattrs -vxpPC /
(where tar must called with full path to binary like /cache/tar or /tmp/tar, or unlink /sbin/tar applet and place binary /sbin, or just rename it gtar)
Note: bitwise 1:1 copy of apps is not possible/sufficient if you factory reset your device, because apps might save data in TEE TrustZone (which is flushed on factory reset)
Click to expand...
Click to collapse
You are a genius! That's excactly what i was searching for! Thank you!
This is a bit beyond me.. though I'm looking for a full ROM backup on Android 12. Does this work?
TWRP 3.7.0 is for Android 12 including Encryption Support (except for Samsung)

Categories

Resources