What kind of information can be restored after the factory reset? - General Questions and Answers

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.

Related

[Q] Mounting userdata partition on PC

Hello all,
Last night I ran the following command (with the phone in recovery and everything unmounted) to back up my Nexus 5's userdata partition to my computer:
Code:
adb pull /dev/block/platform/msm_sdcc.1/by-name/userdata
My phone is encrypted, so I use "cryptsetup --type=plain open" to obtain a plaintext version on /dev/mapper/my-nexus-backup. But I cannot mount the mapped device using "mount"! It complains that iit can't find the filesystem.
So, how would I mount such an image? Or, even better, what's the best way to dd it back to the userdata partition on the device?
And yes, next time I will just use a Nandroid, even if it means having to erase things to make room.
See if @rootSU or @bitdomo can help. They're gurus at this type of stuff
Sent from my Nexus 5 using XDA Free mobile app
Sorry, where are you mounting exactly? Are you trying to mount an image on a Linux box after the pull?
If not can you please share the full step of commands and what you expect to happen please?
Sent from my Nexus 5 using Tapatalk
rootSU said:
Sorry, where are you mounting exactly? Are you trying to mount an image on a Linux box after the pull?
If not can you please share the full step of commands and what you expect to happen please?
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
Hey rootSU. I pulled the image from my phone, decrypted it, and tried to mount it:
Code:
$ adb pull /dev/block/platform/msm_sdcc.1/by-name/userdata
$ su
# losetup /dev/loop1 userdata
# cryptsetup open --type plain /dev/loop1 nexus
Enter passphrase:
# mount /dev/mapper/nexus /mnt/tmp
mount: wrong fs type, bad option, bad superblock on /dev/mapper/nexus,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so.
I'm not sure why that doesn't work. It's just ext4, right? I'd still find it instructive to figure out how to mount it; hopefully you can shed some light?
As far as getting the image back on the device's partition, I was a bit stuck, because there's obviously no room on the device to copy it to. I finally figured out a method involving netcat. Essentially I forwarded a local TCP port to my device (in recovery) using adb, then used netcat to feed dd the image.
Code:
$ adb forward tcp:4444 tcp:4444
$ adb shell
# nc -l -p 4444 -e dd of=/dev/block/platform/msm_sdcc.1/by-name/userdata
This will hang as it waits for an inbound connection. From a second shell:
Code:
$ dd if=userdata | nc localhost 4444
My 28GiB image took around 6 hours (!) to complete. Nandroid is probably the way to go.
Nandroid won't backup sdcard but you can use foldersync to back that up.
Yes it is just ext4
I've never done anything like this before with an encrypted device but my assumption was if you adb pull a file, it would decrypt it on the fly.. Does it not?? If it does, I'd just dd it to an img.
Sent from my Nexus 5 using Tapatalk
rootSU said:
Nandroid won't backup sdcard but you can use foldersync to back that up.
Yes it is just ext4
I've never done anything like this before with an encrypted device but my assumption was if you adb pull a file, it would decrypt it on the fly.. Does it not?? If it does, I'd just dd it to an img.
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
Nope, in this case, userdata is the encrypted *device*; in any case TWRP knows nothing about the encryption. The pull was identical to using dd to copy the file. Of course, if you wanted to decrypt your device without wiping data, you could probably have TWRP decrypt the data partition, then dd or pull the resulting /dev/block/dm-0 file (which is equivalent to my /dev/mapper/nexus file I created). Haven't tried it though; ain't nobody got time for that.
I wonder why it wouldn't mount. Oh well. I'm just happy that my device is the way it was yesterday.
I'd love to have a play with this but I just don't have the time to start encrypting and decrypting stuff
Out of interest what about adb whilst in android?
Sent from my Nexus 5 using Tapatalk
rootSU said:
I'd love to have a play with this but I just don't have the time to start encrypting and decrypting stuff
Out of interest what about adb whilst in android?
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
You would have the exact same results, as the /dev/* files are the physical disks represented as a file. The crypto drivers read/write this block device file to present a decrypted /dev/block/dm-0 device. Then the kernel mounts dm-0 as an ext4 filesystem on /data. All the files I mentioned are pullable with adb, assuming you have sufficient privileges. You don't need fancy tools to read/write them, which is why the netcat hack worked. Thus is the power of Unix!
You can screw around with it if you want in regular desktop Linux with a "device" you make from a bunch of 0s. Do:
Code:
# dd if=/dev/zero of=disk.image count=100000
# losetup /dev/loop0 disk.image
Now you can do "mkfs.ext4 /dev/loop0" and "mount ..." or whatever, and the data will be written to the "device" disk.image.
some time ago I backed up /dev/block/sda from my android 12 phone.
I forgot it was encrypted..
and that it had 34 partitions.
userdata partition WAS sda34.
how can I momentarily mount the backup in android?
losetup is present...

[SOLVED] "E: can't mount /sdcard" CWM 6.0.4.5 after trying L preview.

[SOLVED]
there may be other causes of this error, so there is no guarantee this will always be the fix.
"E: can't mount /sdcard"
in my case was "E: can't mount /sdcard" caused by some corrupted files in /data.
see here:
[email protected]:~$ adb shell
~ # mount /data
mount: mounting /dev/block/platform/msm_sdcc.1/by-name/userdata on /data failed: Invalid argument
i was able to fix this with instructions from this thread: http://forum.xda-developers.com/goo...o-repairing-corrupted-data-partition-t2577447
boot phone into recovery, and ensure you are able to to see your device with the command:
sudo adb devices
then use this command:
adb shell ‘e2fsck /dev/block/platform/msm_sdcc.1/by-name/userdata’
it should prompt you to hit enter to repair several times. simply hit enter each time you are prompted until it resolves.
after that you should be able to access your data through recovery or adb pull.
the "/data/media/0/0/" problem
i thought we were passed this bug, but somehow i caused it again.
it isn't particularly difficult to fix, provided you have proper access to your data.
i just used solid explorer to move the contents of to "/data/media/0/0" to "/data/media/0" and "/data/media/0/clockworkmod" to "/data/media/clockworkmod".
any sort of root file manager should be fine.
original thread:
current situation: nexus 5 has no system data. i can get into fastboot and CWM recovery, but CWM can't perform any functions due to "E: can't mount /sdcard"
[update/edit:
[email protected]:~$ fastboot devices
0370333c437f5965 fastboot
[email protected]:~$ adb devices
List of devices attached
0370333c437f5965 recovery
]
is there anything i can do from fastboot?
should i reflash the recovery or use a different recovery?
do i have to flash stock images?
anyway to back up my data to my pc first?
full story (in case something dumb i did is relevant):
ok, so i flashed the L preview from vomer's thread (http://forum.xda-developers.com/google-nexus-5/development/rom-n5-l-developer-preview-t2796003), and yes i made a nandroid backup (wish i'd copied it to my pc now...)
i dirty flashed because i'm dumb and thought i would format /data anyway. it didn't, but actually didn't cause too many problems (no force closes, but the home button didn't work.)
i went back to recovery and formatted /data, /cache, and dalvik, then reflashed the L zip and made a backup of this fresh install.
messed around with L for awhile, but wanted to go back to my previous setup. so i went back to recovery to restore my nandroid. there was only that most recent backup in the list.
i poked around and realized my files were now located inside "/sdcard/0/0/" so i formatted /data, /cache, and dalvik and flashed my rom (latest aokp, 4.4.4) and gapps. the phone booted up fine but got infinite play services force closes. i assume this is because flashing my rom hadn't actually cleared /system first.
so i go back into recovery once more, format /system, and try to flash the rom again.
E: can't mount /sdcard
i'm assuming my data (and my backup) is still there somewhere in /sdcard/0/0/ but i have no idea how i might access it.
any help would be appreciated. i can definitely return to stock and start over, but i'd much rather have my data.
Click to expand...
Click to collapse
Fastboot flash the stock userdata.img
You'll need to adb pull everything from /data/media first
Yes you should use another recovery but not for this reason
Sent from my Nexus 5 using Tapatalk
rootSU said:
Fastboot flash the stock userdata.img
You'll need to adb pull everything from /data/media first
Yes you should use another recovery but not for this reason
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
i'm not super familiar with this. i've only really used adb with guides for specific tasks.
do i just use "adb pull /data/media /where/i/want/it/to/go"
i'm using ubuntu if that matters.
Yep.
Boot into recovery
Open terminal
mkdir sd_backup
adb shell
mount /data
exit
adb pull /data/media/* /sd_backup
Sent from my Nexus 5 using Tapatalk
rootSU said:
Yep.
Boot into recovery
Open terminal
mkdir sd_backup
adb she'll
mount /data
exit
adb pull /data/media/* /sd_backup
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
ahh, the "/data/media/*" was the part i was looking for.
not sure i understand the
"adb shell
mount /data
exit"
part.
vonlupe said:
ahh, the "/data/media/*" was the part i was looking for.
not sure i understand the
"adb shell
mount /data
exit"
part.
Click to expand...
Click to collapse
In what respect?
They're commands. Type them in the terminal
Sent from my Nexus 5 using Tapatalk
rootSU said:
In what respect?
They're commands. Type them in the terminal
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
[email protected]:~$ adb devices
List of devices attached
0370333c437f5965 recovery
[email protected]:~$ adb shell
~ # mount /data
mount: mounting /dev/block/platform/msm_sdcc.1/by-name/userdata on /data failed: Invalid argument
~ # exit
Try and do "adb root" first..
Sent from my Nexus 5 using Tapatalk
rootSU said:
Try and do "adb root" first..
Sent from my Nexus 5 using Tapatalk
Click to expand...
Click to collapse
[email protected]:~$ adb root
adbd is already running as root
[email protected]:~$ adb shell
~ # mount /data
mount: mounting /dev/block/platform/msm_sdcc.1/by-name/userdata on /data failed: Invalid argument
~ #
not sure if this is relevant or weird or not, but "datadata"??
[email protected]:~$ adb shell
~ # ls
boot fstab.hammerhead sdcard
cache init seapp_contexts
charger init.rc sepolicy
data internal_sd storage
datadata mnt sys
default.prop proc system
dev property_contexts tmp
emmc recovery ueventd.goldfish.rc
etc res ueventd.hammerhead.rc
external_sd root ueventd.rc
file_contexts sbin
fstab.goldfish sd-ext
~ #
vonlupe said:
[email protected]:~$ adb root
adbd is already running as root
[email protected]:~$ adb shell
~ # mount /data
mount: mounting /dev/block/platform/msm_sdcc.1/by-name/userdata on /data failed: Invalid argument
~ #
Click to expand...
Click to collapse
[email protected]:~$ adb root
adbd is already running as root
[email protected]:~$ adb shell
~ # mount /data
~ # exit
[email protected]:~$
Click to expand...
Click to collapse
Could be your data partition is screwed too. Can you still boot into L? if not, I think your data is done for. Basically you have to format data going to and from L.
No idea what "datadata" is.
rootSU said:
Could be your data partition is screwed too. Can you still boot into L? if not, I think your data is done for. Basically you have to format data going to and from L.
No idea what "datadata" is.
Click to expand...
Click to collapse
no, i formatted /system, that's when everything broke.
thanks for all your help! i'm going to keep poking around, as i'd rather like to keep my data. i have the stock 4.4.4 images if i need to wipe though.
vonlupe said:
no, i formatted /system, that's when everything broke.
thanks for all your help! i'm going to keep poking around, as i'd rather like to keep my data. i have the stock 4.4.4 images if i need to wipe though.
Click to expand...
Click to collapse
Just fastboot flash the L system.img and boot.img
rootSU said:
Just fastboot flash the L system.img and boot.img
Click to expand...
Click to collapse
hmm, will that work?
will it boot without userdata.img?
it's just usuerdata that wipes everything, right?
vonlupe said:
hmm, will that work?
will it boot without userdata.img?
it's just usuerdata that wipes everything, right?
Click to expand...
Click to collapse
Userdata wipes data if flashed and no it is not a requirement. Will it work, not sure. Try it.
Also flash a cache.img just incase because dodgy cache can prevent mounting too
Sent from my Nexus 5 using Tapatalk
AHA!!
i found this thread: http://forum.xda-developers.com/goo...o-repairing-corrupted-data-partition-t2577447
which instructed me to run
‘e2fsck /dev/block/platform/msm_sdcc.1/by-name/userdata’ in adb shell.
and it worked!!!
i was able to mount /data and am currently running adb pull /data/media/ (no asterisk, btw)
and backing up all my data.
will update OP if this resolves everything.
Cool
Sent from my Nexus 5 using Tapatalk

"write error: No space left on device" error fix

when im about to remove the modem files like this from adb menu
dd if=/dev/zero of=/dev/block/bootdevice/by-name/mdm1m9kefs1
dd if=/dev/zero of=/dev/block/bootdevice/by-name/mdm1m9kefs2
dd if=/dev/zero of=/dev/block/bootdevice/by-name/mdm1m9kefs3
dd if=/dev/zero of=/dev/block/bootdevice/by-name/mdm1m9kefsc
im getting "write error: No space left on device" error.
how to fix this. or is there any other way to delete those files.
Those commands will overwrite the named block-devices with zeroes, they don't get deleted means it's not technically erasing.
jwoegerbauer said:
Those commands will overwrite the named block-devices with zeroes, they don't get deleted means it's not technically erasing.
Click to expand...
Click to collapse
ok, so is there a way to overwrite them? cos atm i cant with those commands
To overwrite you have to specify as infile an image ( .img ) and as outfile the block-device wanted
jwoegerbauer said:
Look inside here:
dd: No Space Left on Device | Beamtic
After running dd for a long time, it stops with an error saying no space is left on the device.
beamtic.com
Click to expand...
Click to collapse
would it also be fixed when i format the device and wipe all data?
Raw34 said:
would it also be fixed when i format the device and wipe all data?
Click to expand...
Click to collapse
Re-read my altered post above yours.
jwoegerbauer said:
To overwrite you have to specify as infile an image ( .img ) and as outfile the block-device wanted
Click to expand...
Click to collapse
can u give me an example for the command for adb menu?
i want to get rid of this file mi10orj.bin in the modem
What ADB are you using? AFAIK ADB hasn't a menu,
If device is rooted then you may run
Code:
adb devices
adb shell "stop"
adb shell "rm -f /vendor/mi10orj.bin"
adb shell "start"
if the .bin-file is located in vendor partition what IDK
jwoegerbauer said:
What ADB are you using? AFAIK ADB hasn't a menu,
If device is rooted then you may run
Code:
adb devices
adb shell "stop"
adb shell "rm -f /vendor/mi10orj.bin"
adb shell "start"
if the .bin-file is located in vendor partition what IDK
Click to expand...
Click to collapse
its called "minimal adb and fastboot tool".
yes the device is rooted. im gonna try this commands when im done with my working.
thx so much for your help and insight, so far.

Data Recovery

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
.

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