[HELP] Internal Storage not accessible a.k.a How to clear com.android.providers.media.MediaApplication data - General Questions and Answers

Hi,
Since a few days I'm unable to see any data in my phone via gallery or file manager or any application, and I'm unable to save any data to internal storage. (example: I'm able to use whatsapp for texting, but I can't receive/send any audio/picture and I can't access the old ones).
And I keep getting this error message:"com.android.providers.media.MediaApplication keeps stopping."
I don't know if that's what causing it or if that's just a consequence of not being able to access internal storage.
I can still see all the used storage from settings though.
Phone has unlocked bootloader, but no root/custom rom/recovery.
I saw other Oneplus users started getting the same error these days... (I have a Oneplus 6, but others have different models like Oneplus Nord).
Someone resolved by wiping system and they were able to retrieve storage content and functionality, but they lost apps data, I'm trying to find another way since I have an unlocked bootloader.
An user on stackoverflow suggested I should clean the com.android.providers.media.MediaApplication app data to regenerate the database, but I couldn't figure out how to do it
I tried cleaning media and media.module packages (not media.MediaApplication) from adb but no luck even if successful.
I tried removing "com.android.providers.media" (not media.MediaApplication, I couldn't find that one) folder from data/data with twrp file manager but no luck...
Is there a way to specifically clean "com.android.providers.media.MediaApplication"?
If anyone has any other suggestion on things to try, post it here please.
Thank you in advance

you wrote you already did successfully - obviously that is not the cause. my suspect is broken encryption (you will figure out from recovery.log)

encrypted files look like this +NiZZaTrs3RFzYegpkEk if encryption is not the reason, it could be symlinks messed up. in android enable usb-debugging and check from adb shell.
(repeat this for each result)
Code:
readlink /sdcard
readlink ...
in TWRP recovery check for files like /data/system/uiderrors.txt
/data/log
(don't know exact names) you can adb pull files to PC and inspect with wordpad or Notepad++
last but no least you can capture logcat during boot for further analysis
Code:
adb logcat > logcat.txt
if you're going to factory reset device, install Magisk from TWRP and backup apps to usb flash drive with Migrate-NG beforehand. copy all your pictures + backups to PC
Code:
adb pull -a /sdcard
if you can't install Migrate or can't get usb-otg to work, get a backup to PC at least, I can tell you how to restore single apps from it later (ignore the confirmation request "WARNING adb backup is deprecated... Now Unlock your device and confirm...")
Code:
adb backup --twrp --compress data

alecxs said:
encrypted files look like this +NiZZaTrs3RFzYegpkEk if encryption is not the reason, it could be symlinks messed up. in android enable usb-debugging and check from adb shell.
(repeat this for each result)
Code:
readlink /sdcard
readlink ...
in TWRP recovery check for files like /data/system/uiderrors.txt
/data/log
(don't know exact names) you can adb pull files to PC and inspect with wordpad or Notepad++
last but no least you can capture logcat during boot for further analysis
Code:
adb logcat > logcat.txt
if you're going to factory reset device, install Magisk from TWRP and backup apps to usb flash drive with Migrate-NG beforehand. copy all your pictures + backups to PC
Code:
adb pull -a /sdcard
if you can't install Migrate or can't get usb-otg to work, get a backup to PC at least, I can tell you how to restore single apps from it later (ignore the confirmation request "WARNING adb backup is deprecated... Now Unlock your device and confirm...")
Code:
adb backup --twrp --compress data
Click to expand...
Click to collapse
Hi @alecxs , I really hope you are still active on this forum...
Probably you won't remember this discussion from back in the days (This was the previous part of our exchange if you would like to refresh your memory).
In the end I ended up using my phone in that state for more than one year with the plan of changing phone soon and not have to deal with the wipe and restoration on the same device (if that's not procrastination.... ).
Well, last week I dropped the phone and the screen died. I bought a pixel 7 as a replacement but now I would like to try to save the data of just a few apps. Most important one being Whatsapp, I don't really care about the rest...
So basically:
-the screen is dead but touch is still working and I was able to get scrcpy to work so I can still use it as a "normal' phone from my computer, so that shouldn't be an impediment.
-as previously stated the phone is not able to access internal storage, but I'm able to access it in recovery mode through adb so pulling files should not be an issue.
-I'm able to install and update apks through adb install.
-whatsapp was not able to execute backups during this year since it could not access internal storage, so I have only old ones.
-bootloader is unlocked, I have twrp but no root.
I still need to try your suggestion above, but wanted to ask this before cause maybe you have a different suggestion to extract a single app. Also, I don't really know how migrate works but if it saves the backup on the internal storage I think that's not gonna work cause every app that needs to save something (that isn't data) doesn't work.
Isn't there a way to just copy the data folder of the app on the new phone to transfer data (like what happens for mac apps)?
Thank you in advance

0xCuter said:
-as previously stated the phone is not able to access internal storage, but I'm able to access it in recovery mode through adb so pulling files should not be an issue.
Click to expand...
Click to collapse
yes, if that is true all fine, you can run the Migrate_EMERGENCY_FLASHABLE.zip from recovery and restore app data on other device with Migrate

alecxs said:
yes, if that is true all fine, you can run the Migrate_EMERGENCY_FLASHABLE.zip from recovery and restore app data on other device with Migrate
Click to expand...
Click to collapse
Hey, it's me again... So, I rooted my new phone and I found the emergency_flashable.zip in the migrate thread, now I just need to flash it, but I cannot use scrcpy in recovery mode to see the screen. I guess there is a way to flash the zip from adb without the need to use the screen, but better to ask since I don't want to do stupid stuff...

yes, you can do it from adb. best is MicroSD Card as target directory. copy the zip into the target directory, mount data system vendor product, then install zip. on the first trial it will fail because packages.list needed. but it will create one you can edit. delete unwanted packages before second trial. you can repeat as often you want, existing backups won't created twice.
Code:
adb push Migrate_EMERGENCY_FLASHABLE.zip /sdcard
adb shell
# mount /system_root
# mount /system
# mount /vendor
# mount /product
# mount /external_sd
# mkdir /external_sd/Migrate
# cd /external_sd/Migrate
# mv /sdcard/Migrate_EMERGENCY_FLASHABLE.zip .
# twrp install ./Migrate_EMERGENCY_FLASHABLE.zip
# exit
adb pull /external_sd/Migrate/packages.list
edit the file with editor and push it back
https://twrp.me/faq/openrecoveryscript.html

alecxs said:
yes, you can do it from adb. best is MicroSD Card as target directory. copy the zip into the target directory, mount data system vendor product, then install zip. on the first trial it will fail because packages.list needed. but it will create one you can edit. delete unwanted packages before second trial. you can repeat as often you want, existing backups won't created twice.
Code:
adb push Migrate_EMERGENCY_FLASHABLE.zip /sdcard
adb shell
# mount /system_root
# mount /system
# mount /vendor
# mount /product
# mount /external_sd
# mkdir /external_sd/Migrate
# cd /external_sd/Migrate
# mv /sdcard/Migrate_EMERGENCY_FLASHABLE.zip .
# twrp install ./Migrate_EMERGENCY_FLASHABLE.zip
# exit
adb pull /external_sd/Migrate/packages.list
edit the file with editor and push it back
https://twrp.me/faq/openrecoveryscript.html
Click to expand...
Click to collapse
One thing I forgot to ask: do I need to root my old phone as well or is twrp sufficient?
And to root I would just need to flash Magisk the same way I would flash the emergency flashable.zip right? Or can I just "twrp install [magisk_package]" without going into the shell?

No need to root old phone, TWRP already provides root access for backup purposes. the new phone should be rooted by flashing magisk patched boot.img because the TWRP install method is deprecated. I know I gave only short hints, so don't hesitate to ask for more detailed instructions in case you don't know what to do for some specific step...

alecxs said:
No need to root old phone, TWRP already provides root access for backup purposes. the new phone should be rooted by flashing magisk patched boot.img because the TWRP install method is deprecated. I know I gave only short hints, so don't hesitate to ask for more detailed instructions in case you don't know what to do for some specific step...
Click to expand...
Click to collapse
Thank You... Yes, the new phone is rooted.
One thing that's not needed for the process but I wanted to understand is: Is there a specific reason why we "twrp install" from shell or could in theory be possible to flash the zip file directly from pc storage?

0xCuter said:
or could in theory be possible to flash the zip file directly from pc storage?
Click to expand...
Click to collapse
the reason is, the backup is created locally in the same directory where the zip file is. never tried sideload but I guess it would try to store in /tmp which is RAM.

alecxs said:
yes, you can do it from adb. best is MicroSD Card as target directory. copy the zip into the target directory, mount data system vendor product, then install zip. on the first trial it will fail because packages.list needed. but it will create one you can edit. delete unwanted packages before second trial. you can repeat as often you want, existing backups won't created twice.
Code:
adb push Migrate_EMERGENCY_FLASHABLE.zip /sdcard
adb shell
# mount /system_root
# mount /system
# mount /vendor
# mount /product
# mount /external_sd
# mkdir /external_sd/Migrate
# cd /external_sd/Migrate
# mv /sdcard/Migrate_EMERGENCY_FLASHABLE.zip .
# twrp install ./Migrate_EMERGENCY_FLASHABLE.zip
# exit
adb pull /external_sd/Migrate/packages.list
edit the file with editor and push it back
https://twrp.me/faq/openrecoveryscript.html
Click to expand...
Click to collapse
I'm trying and when I do "mount /system" from the shell I get this:
mount: '/system' not in fstab
Click to expand...
Click to collapse
Is it normal?

it's either /system_root or /system so one of it will fail. I just listed both.

alecxs said:
it's either /system_root or /system so one of it will fail. I just listed both.
Click to expand...
Click to collapse
I suspected that... is it the same for product and external_sd?
Only system_root and vendor went through

/external_sd is the mount point for MicroSD Card, it may have a different name like /sdcard1 or something. if you have enough disk space on /data, no need for external SD.
/product is maybe not needed, just running with /system_root + /vendor is fine.

alecxs said:
/external_sd is the mount point for MicroSD Card, it may have a different name like /sdcard1 or something. if you have enough disk space on /data, no need for external SD.
/product is maybe not needed, just running with /system_root + /vendor is fine.
Click to expand...
Click to collapse
There is no external MicroSD on Oneplus 6... can I put the migrate folder in /sdcard?
Also, I think I should delete some stuff from storage to make space, since I already pulled it on the pc

/sdcard = /data/media can be used. you can split the packages.list file into few parts so it fits in remaining disk space.

alecxs said:
/sdcard = /data/media can be used. you can split the packages.list file into few parts so it fits in remaining disk space.
Click to expand...
Click to collapse
I tried the install and I get this, even though the zip file is in the same folder I'm in (it even autocompletes from terminal)
OnePlus6:/sdcard/Migrate # ls
Migrate_EMERGENCY_FLASHABLE.zip
OnePlus6:/sdcard/Migrate # twrp install Migrate_EMERGENCY_FLASHABLE.zip
Unable to locate zip file 'Migrate_EMERGENCY_FLASHABLE.zip'.
Installing zip file 'Migrate_EMERGENCY_FLASHABLE.zip'
Error installing zip file 'Migrate_EMERGENCY_FLASHABLE.zip'
Done processing script file
Click to expand...
Click to collapse

make sure you give a path to zip file on install, like ./ or full path. it will fail on first execution. check if packages.list was created successfully.
alecxs said:
on the first trial it will fail because packages.list needed. but it will create one you can edit.
Click to expand...
Click to collapse
you can always pull recovery.log afterwards to see what's going on.
Code:
adb pull /tmp/recovery.log

alecxs said:
make sure you give a path to zip file on install, like ./ or full path. it will fail on first execution. check if packages.list was created successfully.
you can always pull recovery.log afterwards to see what's going on.
Code:
adb pull /tmp/recovery.log
[/cod
[/QUOTE]
Click to expand...
Click to collapse
It launched with the full path. I didn't edit the package.list file and I launched it again.
I got a lot of "migrate.sh: failed:..." and just a few "migrate.sh: finish:..." mostly for system apps, but honestly I really only need to backup whatsapp...
...
Click to expand...
Click to collapse
migrate.sh: failed: com.intsig.lic.camscanner
migrate.sh: failed: com.android.theme.icon_pack.ci
migrate.sh: failed: com.google.android.apps.restor
migrate.sh: 397x packages failed / 0x already exist
# MIGRATE_STATUS: backup finished (27/424)
# DONE.
#
# exiting script
#
# # # # # # # # # # # # # # # # # # # # # # # # # #
Updater process ended with ERROR: 1
I:Install took 69 second(s).
Error installing zip file 'sdcard/Migrate/Migrate_EMERGENCY_FLASHABLE.zip'
Done processing script file
Click to expand...
Click to collapse
These are the things that have been backed up:
OnePlus6:/sdcard/Migrate # ls
Backup_android Backup_com.google.android.networkstack
Backup_com.android.bluetooth Backup_com.google.android.packageinstaller
Backup_com.android.cellbroadcastreceiver Backup_com.oneplus.screenshot
Backup_com.android.emergency Backup_com.qualcomm.qti.cne
Backup_com.android.inputdevices Backup_com.qualcomm.qti.poweroffalarm
Backup_com.android.location.fused Backup_com.qualcomm.qti.smq
Backup_com.android.phone Backup_com.qualcomm.qti.uceShimService
Backup_com.android.providers.blockednumber Backup_org.ifaa.aidl.manager
Backup_com.android.providers.settings Backup_se.dirac.acs
Backup_com.android.providers.telephony Backup_vendor.qti.hardware.cacert.server
Backup_com.android.proxyhandler Migrate_EMERGENCY_FLASHABLE.zip
Backup_com.android.server.telecom backup_app_and_data.sh
Backup_com.android.settings busybox
Backup_com.android.shell migrate.log
Backup_com.android.stk migrate.sh
Backup_com.android.systemui packages.list
Backup_com.google.android.ext.shared readme.txt
Click to expand...
Click to collapse

Related

[GUIDE] Root Hero [MAC], Load Unofficial MoDaCo 1.2c, Nandroid Backup/Restore!

NOTE: This is a work in progress. While I have completed this guide myself SEVERAL times to ensure accuracy, It is possible that typos or errors in understanding exist. Please use at your own risk, and expect NOTHING from me. I will do my best to update this guide and improve the formatting as I find time. Feel free to leave feedback!
I cannot stress this enough: always have backups of any important information. While we may not be able to do full image-based backups until after root, you can still make sure we aren't deleting needed data. While yes, Google should hold your most important data and allow you to sync at any time, what would you do if Google went down? And I've even had trouble using the "Offline" function for some of the Apps. Therefore, Make a copy of everything on your SD card and read this excellent guide from Lifehacker about how to backup Google Apps data: Lifehacker
You will need an SD card. I recommend AT LEAST an 8GB Class 4. Most actually recommend a Class 6 for use with apps2sd, but I just wanted to let you know that it would still work with a Class 4. For those unaware, apps2sd allows you to save internal phone memory by placing after-market applications onto your SD card. Most users notice a speed benefit from this.
If you would like to purchase a Class 6 SD card, you can get a one here with three sizes available (4GB, 8GB, 16GB):
A-DATA MicroSDHC Class 6 Turbo With SD Adapter
To ensure the best possible load, perform a factory reset, and WIPE your SD card!
Code:
Menu > Settings > Security > Factory data reset > Reset phone > Erase everything
TRUE FACTORY RESET (UN-ROOT)
If you, like me, have already rooted and are trying to perform this process over again, you will unfortunately have to download the original ROM and flash it in Windows.
Download: RUU_Hero_C_Sprint_1.29.651.1_signed_release.exe
Run in Windows (I used XP through VMWare Fusion), and this will return the phone to the TRULY factory loaded state. Any other Factory data reset will simply reload the last ROM image saved, which, if you rooted and loaded MoDaCo, would be MoDaCo. I am encouraging you to follow this process to avoid any problems that may exist while the phone is rooted or loaded with the unofficial ROM. And even if you perform this process as a first-time rooter, it certainly wont hurt!
ROOT HERO [MAC]
(This is the process that allows modifications to occur on your phone):
The guide I follow and can verify is this:
Rooting CDMA Hero [Mac]
I do not use Windows as a primary platform, so I would recommend following this guide if you are on Windows:
How to root the CDMA Hero (DETAILED Windows guide)
You should be able to return to this guide after you have successfully completed the root process on Windows. Continue from the section "NANDROID BACKUP" below.
Per the purpose of this guide, I will detail my exact steps from the "Rooting CDMA Hero [Mac]" post. Thanks ajones7279!
Plug in your phone
Download Android SDK: http://developer.android.com/sdk/index.html
Unpack, Rename the extracted folder to "AndroidSDK" (This is case sensitive!), and Move it to "Applications" (I consider the Android SDK a set of applications.)
Open TextEdit, Click Format>Make Plain Text, then copy and paste the following:
Code:
export PATH=${PATH}:/Applications/AndroidSDK/tools
Save as: ".bash_profile"
On Phone: Go to Settings > Applications > Development>USB Debugging and make sure the option is checked.
On your Mac: Download asroot2: http://zenthought.org/tmp/asroot2
Save this file into: /Applications/AndroidSDK/tools
Open Terminal and run the following commands (You can copy and paste):
Code:
cd /Applications/AndroidSDK/tools
adb push asroot 2 /data/local
adb shell chmod 0755 /data/local/asroot2
adb shell
/data/local/asroot2 /system/bin/sh
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cd /system/bin
cat sh > su
chmod 4775 su
exit
exit
At this point, the phone has root access.
Download: http://rapidshare.com/files/303797523/recovery-RA-heroc-v1.2.3.img
Save this file into: /Applications/AndroidSDK/tools
Go back to your terminal and type:
Code:
adb push recovery-RA-heroc-v1.2.3.img /sdcard/
adb shell
su
flash_image recovery /sdcard/recovery-RA-heroc-v1.2.3.img
exit
exit
adb shell reboot recovery
Now, the phone will reboot into recovery mode. To preserve our freshly rooted state, we will make a Nandroid backup.
NANDROID BACKUP
*NOTE: These steps assume that you have already entered Recovery Mode on the phone through Terminal "adb shell reboot recovery" or the "Quick Boot" app.*
On phone: Using the trackball, scroll down and select "Nandroid v2.2 backup". This will create a backup of the phone in its freshly rooted state to your SD card, under the nandroid directory.
After it completes the backup, we want to make sure that we have the backup "backed up" by copying it to our Mac (Just in case anything happens to the SD card!).
Select "USB Mass storage on"
After your SD Card appears, copy the contents of the "nandroid" folder to anywhere you wish on your Mac (You are using Time Machine right?)
Once the copy is complete, eject the sdcard in mac and select "USB Mass storage off" on the phone.
NOTE: Nandroid does not backup the contents of your SD card. If you don't want to lose what's on your SD card, MAKE A BACKUP COPY!
From this point forward, if you do something that seems to really mess with the phones functionality, you can simply go back to your Nandroid backup!
RESTORE NANDROID BACKUPS
Select "Nandroid v2.2 restore" *THIS WILL ERASE EVERYTHING ON YOUR PHONE*
Your phone will be returned to the condition it was in as of the last Nandroid backup. You can control which backup is restored by deleting the unwanted, time-stamped folders within the "nandroid" directory on your SD card. If you leave only one time-stamped backup folder, that is the backup that will be restored.
Note that this will leave the custom Recovery ROM we loaded (recovery-RA-heroc-v1.2.3.img) in place.
I actually perform a Restore after every Backup. While this takes extra time, you know your Backup is intact and not corrupted in any way!
If you are looking for a complete factory reset, you will need to scroll up to "TRUE FACTORY RESET (UN-ROOT)"
PREPARE SD CARD FOR APPS2SD (A2SD)
For those unaware, apps2sd allows you to save internal phone memory by placing after-market applications onto your SD card. Most users notice a speed benefit from this.
Select "Wipe SD: fat32+ext2+swap" *THIS WILL ERASE EVERYTHING ON YOUR SDCARD*
Select "USB Mass storage on"
The mounted drive should now be empty. Double-check that it was partitioned correctly by opening Disk Utility and verifying 3 partitions on the sdcard: NONAME, disk1s2, and disk1s3. Close Disk Utility.
LOAD Unofficial MoDaCo 1.2c Core ROM
Forum Post: Unofficial MoDaCo 1.2
Download: Unofficial MoDaCo 1.2c Core
Save this file into: your SD card. (the root of your SD card, probably named "NONAME" if you didn't change it. You can change it to whatever you want though.)
Save the file as: "update.zip" (Or rename it)
Eject your sdcard and Select "USB Mass storage off"
Select "Apply sdcard:update.zip"
Select "Reboot system now"
If it successfully loaded, you now have a fresh load of the Unofficial MoDaCo 1.2c ROM! Congrats!
I would recommend that you create another Nandroid backup. Scroll back up to "NANDROID BACKUP" and follow the steps over again and come back to this point.
Now you are ready for the workarounds!
Guide: Workaround Issues (Unofficial MoDaCo 1.2c)
Why'd you make another guide?
nice guide man, no need to respond why you made another guide, the more the merry, nicely detailed as well
Shhhhhh.
I was just curious because there are like six...
I made another guide because while many of the forum posts acomplish bits and pieces, my guide provides the overall picture. Root, ROM, and Backup. And my upcoming "Workarond Issues" guide will collect scattered information in a similar fashion.
I find it ironic that I thanked you for your contribution and you find this guide excessive. Would you prefer that I removed the guide?
No not at all. Yours is nice and concise. There's just a lot, that's all. That's why I said it would be nice if a moderator could have merged all the ones that were already written at the end of mine. Didn't mean any harm.
Ah, I see what you mean. To be honest, I am also making this guide for self reference. If most all of the information I need is together its easier to help myself as well as my friends and the community. Thanks again for all your contributions.
Just to raise awareness, Nandroid does NOT back up your apps if you are using AppsToSD as in MoDaCo. You must back up your apps separately.
True, thanks for the heads up. I'll work on a separate guide that details how to backup your other apps. I believe that anything after-market can be backed up and restored through ASTRO though, and this is much easier for most than adb and Terminal commands (push/pull).
The whole 1.56.651.2 Firmware update is also making me wait to post any further guides, as some of my worksarounds may prove useless. It looks like we still have the Apps Renaming and Reverting issue though, and I didn't see the Sprint admin adress such issues specfically.
?
ok i did the update to the hero. and now found out about rooting(im new to all this) do i run that program you put in the beginning with windows? and then does that rom resolve the issue with battery with sms and other things the OTA update fixed? or should i get another rom or .img idk what to call it really and what does RUU stand for?
Alright,
A couple things to add to this guide, for the complete noob, as I can try to explain it a little more clear.
This should be done prior to doing anything within the guide.
First, connect your phone to your computer and mount your sd card. This can be done by connecting the usb cable, then on your phone, drop down the menu and chose, connect to p.c., Mount SD card. Make a folder and backup your entire sd card to this folder. Once done, delete everything off the card. if you don't, you will run into format and partitions errors later in the guide.
Eject the sd card on the computer, and end usb sharing on the phone. remove the USB cable from the computer.
Next, on the phone Go to Settings > Applications > Development>USB Debugging
Make sure that USB debugging is NOT CHECKED. If its checked later in the guide you will run into errors pushing the files onto the phone.
At this point you can start the guide from the beginning, under the main heading Root Hero [MAC]
I am running OSX 10.6.2 so i ran into a couple of issues.
Next. Under the part where you have to create the .bash file. This file should be saved in your user folder.
/Users/USERNAME where USERNAME is the name of your user account.
For instance my User account is Hamspiced so my user folder is:
/Users/Hamspiced/
when saving the file, uncheck "if no extension is provided, use .txt".
Next, I couldn't copy paste the code because it wasn't parsed properly. This is what i had to do.
And this should be a direct copy paste into terminal. If you don't know how to access terminal click the spyglass in the upper right hand of the screen, and type in terminal. then you should be able to directly copy paste this text.
Code:
cd /Applications/AndroidSDK/tools
./adb push asroot2 /data/local
./adb shell chmod 0755 /data/local/asroot2
./adb shell
/data/local/asroot2 /system/bin/sh
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
cd /system/bin
cat sh > su
chmod 4775 su
exit
exit
As stated you should have root access on the phone. you can verify this by downloading Terminal emulator from the Market, then running the app. Once inside the app if you hold Menu, you should bring up the onscreen keyboard. if you type in "su" (stands for super user) it will change the prompt from $ to #. If yours does not change, start over, something went wrong. If it did change then you can proceed to the next part of this guide.
Next the guide is trying to put the recovery Image to your phone. This doesnt restore your phone, it just puts the recovery portion to it, and it allows you to do all the cool things to your phone, like allow you to create backups, restore backups, and load customs roms.
again i ran into issues with parsing the correct format so these are copy pastes from terminal.
Code:
./adb push recovery-RA-heroc-v1.2.3.img /sdcard/
./adb shell
su
flash_image recovery /sdcard/recovery-RA-heroc-v1.2.3.img
exit
exit
adb shell reboot recovery
If you get an access denied error pushing the recovery image, its because you had debugging turned on prior to connecting your phone to the computer. it must be off, then turned on once the phone is connected.
This will result in headaches, and endless google searching with no results.
Follow the rest of the guide regarding the Nandroid backup this backs up the entire phone settings. you want to save the raw phone backup as well as the backup after you load the rom. both are incredibly important!
Prepare SD Card for Apps2sd….
If when you checked Disk Utility and your SD card didnt partition properly follow these steps.
You must erase everything on your sd card for these steps to work. I ran into errors creating the partition. What i had to do was in the recovery mode chose factory recovery. when the phone restarted i had to go to Settings>Security>Factory Data Reset.
This restored EVERYTHING. THe phone, Sd Card, Etc. Everything was lost, however since in the begining, we made a backup of the SD card, and then we made a backup of our phone, we are fine.
Restart the phone in recovery mode once this finishes and restarts. (Hold Home and Power to turn on)
Next chose Part SD: fat32+ext2+swap this will partition the card properly. Then choose restart phone.
Once the phone restarts, we have to go through the normal steps that we did once we first received the phone for its first bootup. connect it to the computer, transfer over the Nandroid backup that should be saved from the first time you saved it on your phone. then restart the phone again in recovery mode.
Now you need to restore the nandroid backup. since you transferred it over, its the only nandroid backup there is, it will restore the phones origional settings. from here you can load the official MoDaCO rom fine on the SD card that is now formatted properly.
These are about all the issues and resolutions i ran into. Hopefully it helps someone else.
Guess it's subjective. I think I haven't turned off USB Debugging since shortly after I got the phone and didn't run into any problems. It's always on before I plug it in and I haven't ran into any errors while pushing a file to my sd card. Also didn't erase my sd card before I formatted (did back it up though of course) and everything went smooth. Dunno. It's always good to hear from diff people though. Also just edited my thread, thanks for the heads up.
need help rooting htc hero from sprint
i have 1.5 firmware bb version is 1.04.01.09.21 kernel version 2.6.27-533ce29dhtc [email protected] build number1.56.651.2 cl85027software 1.56 cant get root on this device can someone please help me
quis5550 said:
i have 1.5 firmware bb version is 1.04.01.09.21 kernel version 2.6.27-533ce29dhtc [email protected] build number1.56.651.2 cl85027software 1.56 cant get root on this device can someone please help me
Click to expand...
Click to collapse
Try here
http://forum.xda-developers.com/showthread.php?t=581686&highlight=root+mac
First, excellent guide! Personally, I used Universal Androot (snipurl.com/uaroot) to root my Hero, but this was a huge help in getting the SDK installed!
I'm running into a problem while trying to do the Nandroid backup. When I try to flash the recovery image, I get the following error message....
AJBlue98$ ./adb shell
$ cd /sdcard/
$ su
# flash_image recovery recovery-RA-herocv1.6.2.img
flash_image: not found
Click to expand...
Click to collapse
I even try the command with the leading "./" and I get essentially the same thing...
# ./flash_image recovery recovery-RA-herocv1.6.2.img
./flash_image: not found
Click to expand...
Click to collapse
I'm running the latest official Sprint 2.1 ROM on my Hero and Terminal on Mac OS X Snow Leopard 10.6.4 on a late-2009, 17 in. MacBook Pro. Oh, and I installed the Android SDK into another directory (had it installed before I found this tutorial), so here's my $PATH...
-bash: type: /opt/local/bin:/opt/local/sbin:/Users/AJBlue98/soylatte/bin:/Users/AJBlue98/android-sdk-mac_86:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/texbin:/usr/X11/bin: not found
Click to expand...
Click to collapse
Am I missing something? I'll really appreciate the help!
—Adam
ajblue98 said:
First, excellent guide! Personally, I used Universal Androot (snipurl.com/uaroot) to root my Hero, but this was a huge help in getting the SDK installed!
I'm running into a problem while trying to do the Nandroid backup. When I try to flash the recovery image, I get the following error message....
I even try the command with the leading "./" and I get essentially the same thing...
I'm running the latest official Sprint 2.1 ROM on my Hero and Terminal on Mac OS X Snow Leopard 10.6.4 on a late-2009, 17 in. MacBook Pro. Oh, and I installed the Android SDK into another directory (had it installed before I found this tutorial), so here's my $PATH...
Am I missing something? I'll really appreciate the help!
—Adam
Click to expand...
Click to collapse
yeah, you're missing the "flash_image" binary on your phone lol search xda for it and push it to /system/bin, then try the command again.
regaw_leinad said:
yeah, you're missing the "flash_image" binary on your phone lol search xda for it and push it to /system/bin, then try the command again.
Click to expand...
Click to collapse
Thanks, regaw_leinad, for the lead! I found a copy of the flash_image file and copied it to my Android SDK folder, but when I try to push it to my phone, I get this:
AJBlue98$ ./adb push flash_image /system/bin
failed to copy 'flash_image' to '/system/bin/flash_image': Permission denied
failed to copy 'flash_image' to '/system/bin/flash_image': Read-only file system
Click to expand...
Click to collapse
(I rebooted the phone and tried again after my original post. The error message changed. BTW I'm connected via USB with debugging turned on and "Charge only" selected as my connection type.)
I've tried running adb as root, but I get this:
AJBlue98$ ./adb root
adbd cannot run as root in production builds
Click to expand...
Click to collapse
Again, any help will be greatly appreciated!
—AJBlue98
ajblue98 said:
Thanks, regaw_leinad, for the lead! I found a copy of the flash_image file and copied it to my Android SDK folder, but when I try to push it to my phone, I get this:
(I rebooted the phone and tried again after my original post. The error message changed. BTW I'm connected via USB with debugging turned on and "Charge only" selected as my connection type.)
I've tried running adb as root, but I get this:
Again, any help will be greatly appreciated!
—AJBlue98
Click to expand...
Click to collapse
ok type
adb shell
then
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
to mount it as r/w
then try the flash image command again.
Adb root or adb remount won't work, because your boot.img isn't patched yet.
regaw_leinad said:
ok type
adb shell
then
mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
to mount it as r/w
then try the flash image command again.
Adb root or adb remount won't work, because your boot.img isn't patched yet.
Click to expand...
Click to collapse
Okay, I did that. I'm still charge-only and debugging turned on, and here's what happened.
(N.B.: I'm on a Mac, so I have to include "./" before running an application in the current directory. Also, I'm including "AJBlue98" in front of my "$" prompts to differentiate my Mac's local prompts from the adb shell prompts.)
AJBlue98$ ./adb shell
$ mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
mount: Operation not permitted
Click to expand...
Click to collapse
So I tried these few things...
$ su
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
# cd /sdcard/
# mv flash_image /system/bin
failed on 'flash_image' - Cross-device link
# exit
$ exit
AJBlue98$ ./adb shell su mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
Permission denied
AJBlue98$ ./adb push flash_image /system/bin
failed to copy 'flash_image' to '/system/bin/flash_image': Permission denied
Click to expand...
Click to collapse
Now I'm completely flummoxed. As always, please help and thanks in advance!
Update: I got frisky, so I tried this, just for the heck of it...
AJBlue98$ ./adb shell
$ su
# cd /sdcard
# ./flash_image recovery /sdcard/recovery-RA-heroc_v1.2.3.img
./flash_image: permission denied
# chmod 755 ./flash_image
# ./flash_image recovery /sdcard/recovery-RA-heroc_v1.2.3.img
./flash_image: permission denied
# su ./flash_image recovery /sdcard/recovery-RA-heroc_v1.2.3.img
Permission denied
Click to expand...
Click to collapse
Update 2:
I got some help at irc.twit.tv from a good soul in the #twitlive channel, who pointed me to ROM Manager (downloadable from the Market). That just did the whole backup, hey-presto, no flash_image BS required.
Thanks for the help anyway, all!
ajblue98 said:
Okay, I did that. I'm still charge-only and debugging turned on, and here's what happened.
(N.B.: I'm on a Mac, so I have to include "./" before running an application in the current directory. Also, I'm including "AJBlue98" in front of my "$" prompts to differentiate my Mac's local prompts from the adb shell prompts.)
So I tried these few things...
Now I'm completely flummoxed. As always, please help and thanks in advance!
Update: I got frisky, so I tried this, just for the heck of it...
Update 2:
I got some help at irc.twit.tv from a good soul in the #twitlive channel, who pointed me to ROM Manager (downloadable from the Market). That just did the whole backup, hey-presto, no flash_image BS required.
Thanks for the help anyway, all!
Click to expand...
Click to collapse
sweet, glad you got it worked out
there were a few errors in what you did above, but looks like you got everything working without it, so that's good

[HOW-TO] Backup your files before rooting

To fully root your EVO, you must apply a couple of updates over the top of your current installation. They will completely erase your user data.
To backup your files before rooting:
- Plug in your phone to your computer
- Make sure you have adb installed.
- Download the unrEVOked userland root.
- Open a terminal and cd into your downloads folder (e.g. cd ~/Downloads)
- Type the following:
Code:
adb install unrevoked.apk
adb shell
su
-- Look at your phone screen. Superuser Permissions is asking you if terminal has
permission to become root. Click allow. --
mkdir /sdcard/backup/
busybox cp -R /data /sdcard/backup/data
This will place a full copy of your userdata partition on your sdcard. To restore files back to your userdata partition after the root, simply use busybox cp to move them back. If your new ROM didn't include busybox, download and install it:
Code:
adb push busybox /system/bin/busybox
adb shell
chmod 755 /system/bin/busybox
I haven't tried copying all my userdata from the sdcard back to the data partition. I've simply used this method to backup and restore files I really didn't want to lose (like my bike calculator logs). I don't know if you could circumvent the wipe by copying your whole data backup back to the data partition after rooting. If you'd like to try and find out, please leave your results in the comments.
I've noticed that the files I've restored from my sdcard back to /data/data have root permissions. In Android, each app gets its own user account that has permissions to its data. If you don't fix the permissions, your apps won't be able to save their data. I don't know how to lookup which app gets which user account, but once you figure it out, you can do this:
Code:
cd /data/data/com.myapp
chown app_83.app_83 ./*
where myapp and app_83 are replaced with the values you are changing. joeykrim has posted a link which may help you do this automatically (fix_permissions.sh) in his thread.
theillustratedlife said:
I've noticed that the files I've restored from my sdcard back to /data/data have root permissions. In Android, each app gets its own user account that has permissions to its data. If you don't fix the permissions, your apps won't be able to save their data.
Click to expand...
Click to collapse
i never got that far, w/o restoring the correct permissions the apps won't load and puts android into a continuous boot loop and it will keep trying to load the apps but the permissions wont match.
theillustratedlife said:
I don't know how to lookup which app gets which user account
Click to expand...
Click to collapse
i think the permissions are kept in /data/system/packages.xml ...
theillustratedlife said:
joeykrim has posted a link which may help you do this automatically (fix_permissions.sh) in his thread, but the link currently appears to be down.
Click to expand...
Click to collapse
switched hosting providers, this link got lost in the shuffle. its http://www.joeyconway.me/evo/apps/fix_permissions.sh . updated my post. thanks!
Interesting. I've only used this trick to restore data selectively. I haven't tried moving the whole backup back into my /data partition.
Thanks for the heads up.

Backup your EFS-partition using tar and dd

This guide has been made with and for the i9505, but will most likely also work on other Galaxy S4-models.
Please be extra careful on models other than i9505 as the 'mmcblkXpXX' partition numbers might differ on your device. How to check this is written in the procedure.
As I could not find a procedure in this forum yet, I have made one myself.
Of course all of the below is 'USE AT YOUR OWN RISK'.
Requirements before you start
Install KIES software (and included driver) and connected your S4 atleast once (to see if it works)
Have ADB-executable available. It can be found in the ADT Bundle from Google. There are also much smaller packages with ADB-only which will work. I might create one myself later on and attach it to this thread..
Device is rooted and has busybox-installed (default with motochopper root method). Applications with a similar name in Play Store will allow you to install busybox manually.
Enable developer mode, go to Settings - More - Device-info - Tap 7 times on 'Build number' to unlock 'Developer options' in the previous screen. Then go to 'Developer options' and thick 'USB debugging'
Connect USB cable to your computer and smartphone with 'USB debugging' enabled
Preparations for both backup methods
Now open a ADB-shell, in Windows this would be: 'cmd' in Start-menu (or CTRL+R).
Change the directory to the ADT directory: sdk\platform-tools. In my case:
Code:
cd C:\Android\sdk\platform-tools
Then start the shell using adb:
Code:
adb shell
If you get the error:
'error: device offline'
Then, check your device and allow USB debugging for the presented device. Now try again the command 'adb shell'
If all goes well, you will see the following:
[email protected]:/ $
Now switch to root-user:
Code:
su -
It is possible that the phone now asks you to permit or deny root access. Of course, please permit.
When the switch succeeds, the '$' changes to '#', but you can also verify it by the id-command:
Code:
[email protected]:/ # id
id
uid=0(root) gid=0(root) context=u:r:shell:s0
If it shows root, all is fine.
Then, check with the following command if /efs is available and mounted:
Code:
mount | grep efs
It should show something like:
Code:
mount | grep efs
/dev/block/platform/msm_sdcc.1/by-name/efs /efs ext4 rw,seclabel,nosuid,nodev,no
atime,discard,journal_checksum,journal_async_commit,noauto_da_alloc,errors=panic
,data=ordered 0 0
Backup method using TAR
NOTE: In case you left the ADB shell, please return to it using command 'adb shell' and switch to root again via 'su -' as described above.
Run the folowing command to backup the whole efs-partition (all the files available on the system):
Code:
tar -cvf /data/media/0/efs.tar /efs
Your output will look like this:
Code:
[email protected]:/ # tar -cvf /data/media/0/efs.tar /efs
tar -cvf /data/media/0/efs.tar /efs
tar: removing leading '/' from member names
efs/
efs/imei/
efs/imei/mps_code.dat
efs/wifi/
efs/wifi/.mac.info
efs/FactoryApp/
efs/FactoryApp/test_nv
efs/FactoryApp/hist_nv
efs/FactoryApp/fdata
efs/FactoryApp/serial_no
efs/FactoryApp/factorymode
efs/FactoryApp/keystr
efs/FactoryApp/hw_ver
efs/FactoryApp/baro_delta
efs/FactoryApp/prepay
efs/FactoryApp/earjack_count
efs/FactoryApp/batt_cable_count
efs/bluetooth/
efs/bluetooth/bt_addr
efs/gyro_cal_data
efs/00000000.authtokcont
efs/carrier/
efs/carrier/HiddenMenu
efs/drm/
efs/drm/widevine/
efs/drm/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_/
efs/drm/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_/D3qpp0bxmJhbiZwIsCbXJ1434rc_
efs/drm/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_/RXFABDUxyT6Q+Zwx9ZhPGOq2Bq8_
efs/drm/playready/
efs/drm/playready/00004.PRV
efs/drm/playready/playready0.dat
efs/drm/playready/playready1.dat
efs/drm/playready/playready.hds
efs/wv.keys
efs/log/
efs/log/boot_cause
efs/.files/
efs/.files/.dx1/
efs/.files/.dm33/
efs/.files/.mp301/
efs/ss_data
efs/h2k.dat
efs/hw_offset
This will add all files in /efs to the tar archive located on your internal memory as 'efs.tar'.
Now, the permissions of this tar are incorrect (for this location) so we have to correct them:
Change owner and group:
Code:
chown media_rw:media_rw /data/media/0/efs.tar
And the file permissions:
Code:
chmod 664 /data/media/0/efs.tar
Now, your tar-backup is ready and can be copied via MTP towards your computer or you can use adb to copy it over. First type 'exit' twice to exit the adb shell. CTRL+C is an alternative to leave the 'adb shell'.
Code:
adb pull /mnt/shell/emulated/0/efs.tar .
This will copy the efs.tar to your current directory, which is in my case C:\Android\sdk\platform-tools. You can also replace the last . with the directory where you would like to put the file in.
Backup method using 'dd'
NOTE: In case you left the ADB shell, please return to it using command 'adb shell' and switch to root again via 'su -' as described above.
From the output of the earlier executed command 'mount | grep efs', you can get the path of the EFS partition. It start with '/dev/block/..' is the part which you can use to find the original partition on your device.
As you can see, in my case this is, and I do not expect it to be any different on your device:
/dev/block/platform/msm_sdcc.1/by-name/efs
To check which 'mmcblk' partition it is, we should check out this link:
Code:
ls -al /dev/block/platform/msm_sdcc.1/by-name/efs
This will show you the mmcblk which is the EFS-partition:
Code:
ls -al /dev/block/platform/msm_sdcc.1/by-name/efs
lrwxrwxrwx root root 1970-01-05 23:39 efs -> /dev/block/mmcblk0p10
As you can see, the actual partition in my case is:
Code:
/dev/block/mmcblk0p10
I expect that this is the same for all i9505-devices, but it's better safe to check it. On i9500-devices this might be a different number as they have a different partition-layout, that's why we're checking this. It is very important to save this location, also for future restores.
Now, to backup the partition using dd, run the following command, please make sure that the part directly after 'if=' is the partition you found using the 'ls -l' command. In my case '/dev/block/mmcblk0p10':
Code:
dd if=/dev/block/mmcblk0p10 of=/data/media/0/efs.img
When it finishes, it will show you something like:
Code:
27904+0 records in
27904+0 records out
14286848 bytes transferred in 1.195 secs (11955521 bytes/sec)
This command reads the efs-partition, byte-by-byte to your internal memory, which you can transfer later on to your PC using ADB or MTP.
As the file created is owned by root:root and doesn't have the default permissions used for files at this location, it can be corrected with the following 2 commands:
Change owner and group:
Code:
chown media_rw:media_rw /data/media/0/efs.img
And the file permissions:
Code:
chmod 664 /data/media/0/efs.img
Now, your DD-backup is ready and can be copied via MTP towards your computer or you can use adb to copy it over. First type 'exit' twice to exit the adb shell. CTRL+C is an alternative to leave the 'adb shell'.
Code:
adb pull /mnt/shell/emulated/0/efs.img .
This will copy the efs.img to your current directory, which is in my case C:\Android\sdk\platform-tools. You can also replace the last . with the directory where you would like to put the file in.
To restore the files
Now to restore the files, in case there is really a need to, like imei-number ****up or something with the MAC-address of your wifi, or whatever.. the following commands can be used:
Of course, once again. USE AT YOUR OWN RISK!!!! Do not use this if not really necessary, as there are risks involved in doing this.
To restore the tar-backup, open 'adb shell' and switch to root using 'su -'. Now, first switch to the root directory, which is most likely not needed, but just to make sure the files will be extracted to the right location:
Code:
cd /
Before executing the next command, I assume that you have the efs.tar file in the root-directory of your internal SD-card.
Now, extract the tar file:
Code:
tar -xvf /data/media/0/efs.tar
This will extract the efs.tar file back to it's original location. It will show you something like:
Code:
[email protected]:/ # tar -xvf /data/media/0/efs.tar
tar -xvf /data/media/0/efs.tar
efs/
efs/imei/
efs/imei/mps_code.dat
efs/wifi/
efs/wifi/.mac.info
efs/FactoryApp/
efs/FactoryApp/test_nv
efs/FactoryApp/hist_nv
efs/FactoryApp/fdata
efs/FactoryApp/serial_no
efs/FactoryApp/factorymode
efs/FactoryApp/keystr
efs/FactoryApp/hw_ver
efs/FactoryApp/baro_delta
efs/FactoryApp/prepay
efs/FactoryApp/earjack_count
efs/FactoryApp/batt_cable_count
efs/bluetooth/
efs/bluetooth/bt_addr
efs/gyro_cal_data
efs/00000000.authtokcont
efs/carrier/
efs/carrier/HiddenMenu
efs/drm/
efs/drm/widevine/
efs/drm/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_/
efs/drm/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_/D3qpp0bxmJhbiZwIsCbXJ1434rc_
efs/drm/widevine/5dsokxEEDXgQhkN50bp-Z2K5InM_/RXFABDUxyT6Q+Zwx9ZhPGOq2Bq8_
efs/drm/playready/
efs/drm/playready/00004.PRV
efs/drm/playready/playready0.dat
efs/drm/playready/playready1.dat
efs/drm/playready/playready.hds
efs/wv.keys
efs/log/
efs/log/boot_cause
efs/.files/
efs/.files/.dx1/
efs/.files/.dm33/
efs/.files/.mp301/
efs/ss_data
efs/h2k.dat
efs/hw_offset
Then reboot your phone normally and see if it works again as you would expect.
If you restored the TAR-backup succesfully, you do not need to restore the dd-image. But in case your tar did not work or your /efs is not mounted due to corruption (in recovery) you can try the dd-recovery instead.
PLEASE BE AWARE THAT YOU SHOULD BE SURE ABOUT THE LOCATION OF THE EFS-PARTITION. THIS LOCATION WAS FOUND USING the 'ls -al /dev/block/platform/msm_sdcc.1/by-name/efs'-COMMAND EARLIER DESCRIBED. If you do not know this location, there's a risk you are overwriting other partitions (MODEM, SYSTEM, RECOVERY, ETC).
If you are sure about the original location, /dev/block/mmcblk......, then use this path just straight after 'of='. On my device the partition is /dev/block/mmcblk0p10.
Code:
dd if=/data/media/0/efs.img of=/dev/block/mmcblk0p10
Output will be similar to:
Code:
27904+0 records in
27904+0 records out
14286848 bytes transferred in 1.195 secs (11955521 bytes/sec)
This will read the efs.img and put it back in the original location.
NOTE 1: This thread gives you two options of backupping the EFS-partition. It is preferred to do both, better safe than sorry.
NOTE 2: Luckily, I have never had to restore any of the backups myself (not on this phone and not on earlier phones). This means that I was never able to test the restores, which counts for the most of us.
NOTE 3: DO NOT RESTORE unless you are really sure this will solve your issue. This will never resolve any lag or other problems with your rom.
NOTE 4: It is normal that the DD-file is much larger (10MB in size) as it also copies unused space and other meta-data of the partition.
NOTE 5: USE AT YOUR OWN RISK! Although the backup part is nearly riskless.
Note X: Feel free to thank me for this post.
Reservation for second post, just in case.
Isn't rooting and using rootexplorer to zip de efs folder to external SD card and just copying that with a microSD cabel way easier?
johan81 said:
Isn't rooting and using rootexplorer to zip de efs folder to external SD card and just copying that with a microSD cabel way easier?
Click to expand...
Click to collapse
Yes, zipping is easier but you will lose your permissions (owner and file permissions (changed via chown/chmod)) so it is actually not a good backup. The permissions/ownerships are backupped with the tar- and dd-backup.
The dd-file includes more than just the file; it also contains the partition meta-data, in case your filesystem got corrupted and it is not possible to recovery it.
Good job man.
EFS Professional v2.0.35 is now support S4. You can also use this:
http://forum.xda-developers.com/showthread.php?t=1308546
shaq1907 said:
EFS Professional v2.0.35 is now support S4. You can also use this:
http://forum.xda-developers.com/showthread.php?t=1308546
Click to expand...
Click to collapse
dont seem to work crashes out while backing up
working now with new update
anybody knows how to adb read the the entire partition table of the galaxy s4?

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)

Accessing my phone with a dead screen

So my phone screen connector was liquid damaged. No touch or display. It's an Essential Phone which supports HDMI output, however I can't unlock it because I don't see the lock screen on the monitor I just see a lock icon. I have fingerprint/pattern set up but I can't use fingerprint because it wants me to do the pattern first after a reboot. I do not have access to ADB since for whatever reason MTP is always enabled. I do have TWRP except the contents of the phone are encrypted so I can't get the data off that way. I am running an Android 12 custom rom. Any ideas on how I can access my files/unlock the phone?
we can enable adb in boot.img - please backup from adb while in TWRP recovery, share zip here so I will have a look.
Code:
adb pull /dev/block/bootdevice/by-name/boot boot.img
with adb enabled we can use scrcpy to mirror lock screen and unlock from PC.
aIecxs said:
we can enable adb in boot.img - please backup from adb while in TWRP recovery, share zip here so I will have a look.
Code:
adb pull /dev/block/bootdevice/by-name/boot boot.img
with adb enabled we can use scrcpy to mirror lock screen and unlock from PC.
Click to expand...
Click to collapse
Thanks for the response, I've got the boot image backed up.
Just for fun a built a digitizer emulator. It will work even when the ADB is turned off.
are you sure that is actually the boot.img dumped off your current boot partition? there is a twrp.fstab inside? However, I have modified prop.default and added custom.rc in overlay.d to enable adb. try this without flashing, then check adb. if it works, you can run scrcpy (link above)
Code:
fastboot devices
fastboot boot boot.img
adb devices
in case it does not work, you could also try to boot this TWRP (do not flash)
https://forum.xda-developers.com/t/official-twrp-3-2-3-0-for-essential-ph-1.3840931
you can decrypt pattern from adb too
https://twrp.me/faq/openrecoveryscript.html
(attachment removed)
aIecxs said:
are you sure that is actually the boot.img dumped off your current boot partition? there is a twrp.fstab inside? However, I have modified prop.default and added custom.rc in overlay.d to enable adb. try this without flashing, then check adb. if it works, you can run scrcpy (link above)
Code:
fastboot devices
fastboot boot boot.img
adb devices
in case it does not work, you could also try to boot this TWRP (do not flash)
https://forum.xda-developers.com/t/official-twrp-3-2-3-0-for-essential-ph-1.3840931
you can decrypt pattern from adb too
https://twrp.me/faq/openrecoveryscript.html
md5: 2baeb682f45ac1da8fcdbf75a60c99a4
Click to expand...
Click to collapse
Yeah it is, that is there probably because you need to install TWRP to the boot partition for the Essential Phone. Anyway, it didn't work sadly. I get the same result, all I got in device manager is "Essential MTP Device" and an inaccessible folder cause it's still locked. and it appears that twrp for the Essential Phone can't decrypt Android 12 data. I couldn't get it decrypted back when I could see my screen & used a pin either iirc
Renate said:
Just for fun a built a digitizer emulator. It will work even when the ADB is turned off.
Click to expand...
Click to collapse
How do I use it?
okay flash this boot.img to boot_a and boot_b and try again. I have added some flags for TWRP in recovery ramdisk too, maye it decrypts now. at least, it should enable adb. it may require ADB Interface Driver re-installed from device manager.
aIecxs said:
okay flash this boot.img to boot_a and boot_b and try again. I have added some flags for TWRP in recovery ramdisk too, maye it decrypts now. at least, it should enable adb. it may require ADB Interface Driver re-installed from device manager.
Click to expand...
Click to collapse
Unfortunately neither situation has changed, also reinstalled the ADB drivers
Zumbuh said:
Unfortunately neither situation has changed, also reinstalled the ADB drivers
Click to expand...
Click to collapse
can you please provide TWRP recovery.log after passing encoded pattern from cmd line?
Code:
adb shell twrp decrypt '12357'
adb pull /tmp/recovery.log
what custom ROM you are running?
maybe startup script requires u:r:init:0 secontext, or it is executed too early and just dropped before zygote? or maybe it is too late, as usually build.prop properties are triggers for init.rc so the resetprop is not working.
this is how I did
https://topjohnwu.github.io/Magisk/guides.html#root-directory-overlay-system
it will work, it's just a matter of right parameters. you can unpack boot.img your own and replace late-init with boot or post-fs-data or something different.
you can also try to write log to /cache partition and view from TWRP afterwards, so you will figure out script is even executed.
Zumbuh said:
How do I use it?
Click to expand...
Click to collapse
This was really just a proof of concept using a microcontroller that gets the swipe/click details from a desktop.
If you had a 2nd rooted Android that had HID USB Gadget built in (g_hid) it would be possible to write an app to do this.
You'd tether the two Androids together.
Edit: I did get it working with just the rooted Android and the target Android.
It's just a bit cumbersome to install. You need a custom USB config daemon and a udevd.
No design awards here, but it works.
I spend mostly 2 hours, I could change properties from overlay.d and also confirmed double check after boot. However, my Xiaomi denies any usb connection in case of modifications. So the default.prop trick did not work for me.
What worked is get a copy of %UserProfile%\.android\adbkey.pub rename it to adb_keys and copy to cache partition.
Code:
adb push %UserProfile%\.android\adbkey.pub /cache/adb_keys
adding these two files in boot.img overlay.d will copy /cache/adb_keys -> to /data/misc/adb/adb_keys. this worked for me, so give it one more shot.
aIecxs said:
I spend mostly 2 hours, I could change properties from overlay.d and also confirmed double check after boot. However, my Xiaomi denies any usb connection in case of modifications. So the default.prop trick did not work for me.
What worked is get a copy of %UserProfile%\.android\adbkey.pub rename it to adb_keys and copy to cache partition.
Code:
adb push %UserProfile%\.android\adbkey.pub /cache/adb_keys
adding these two files in boot.img overlay.d will copy /cache/adb_keys -> to /data/misc/adb/adb_keys. this worked for me, so give it one more shot. (edit: fixed)
Click to expand...
Click to collapse
I actually saw your earlier version of this reply so I was trying it myself, then when I went to reply I saw that you added a boot image and tried that as well. Though neither worked for me. I've attached my recovery.log though I assume the part you wanted to see was this.
I:operation_start: 'TWRP CLI Command'
Attempting to decrypt data partition via command line.
get_crypt_ftr_info crypto key location: ''
Unexpected value for crypto key location
Error getting crypt footer and key
Failed to decrypt data.
I:Done reading ORS command from command line
does phone have cache partition at all? you can check if /cache/adb_keys still exist. if you can see /cache/adb_keys.bak that is dump including all the existing keys. if not increase the timeout 60 seconds.
What ROM you are using? crypto-footer sounds more like FDE encryption, but I did only add flags FBE + metadata encryption.
kindly provide recovery.log. you can share via pastebin.com with expire date
aIecxs said:
does phone have cache partition at all? you can check if /cache/adb_keys still exist. if you can see /cache/adb_keys.bak that is dump including all the existing keys. if not increase the timeout 60 seconds.
What ROM you are using? crypto-footer sounds more like FDE encryption, but I did only add flags FBE + metadata encryption.
kindly provide recovery.log. you can share via pastebin.com with expire date
Click to expand...
Click to collapse
I'm using this Pixel Extended 12L rom. For whatever reason it wouldn't attach recovery.log to the last post, anyways here's the pastebin link
Starting TWRP 3.2.3-0-007de98f-dirty on Thu Jan 1 00:00:13 1970 (pid 601)I: - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
pastebin.com
the log is not from my (3) boot.img
I:Mount: Unable to find partition for path '/cache'
where did you place your adb_keys?
aIecxs said:
I:Mount: Unable to find partition for path '/cache'
where did you place your adb_keys?
Click to expand...
Click to collapse
In cache originally, but yeah I noticed that it didn't mount earlier as well. I did try placing them in a new directory I created and modifying the adbguard.sh file but it didn't work. The adb_keys file is still in that directory but there is no .bak file. Got anywhere else I could place it?
what directories can you access unencrypted on /data?
aIecxs said:
what directories can you access unencrypted on /data?
Click to expand...
Click to collapse
Seems the only one that isn't encrypted is /data/gsi
so you can place adbkey.pub there instead. change these lines in overlay.d/sbin/adbguard.sh. increase the timeout. you can also add some output to see if script is running at all.
Bash:
while [ ${i:-0} -le 60 ]; do
set_adbkey /data/gsi/adb_keys
echo "Hello World ($i)" >> /data/gsi/hello.txt
Code:
adb push adbkey.pub /data/gsi/adb_keys
according to the ROM you linked, that is just FBE encryption, I bet some dev can fix that TWRP.
/vendor/etc/fstab.mata
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/dev/block/platform/soc/1da4000.ufshc/by-name/system / ext4 ro,barrier=1 wait,slotselect,verify
/dev/block/platform/soc/1da4000.ufshc/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc latemount,wait,check,formattable,fileencryption=ice,quota
/dev/block/platform/soc/1da4000.ufshc/by-name/misc /misc emmc defaults defaults
/dev/block/platform/soc/1da4000.ufshc/by-name/modem /vendor/firmware_mnt vfat ro,shortname=lower,uid=1000,gid=1000,dmask=222,fmask=333,context=u:object_r:firmware_file:s0 wait,slotselect
/dev/block/platform/soc/1da4000.ufshc/by-name/dsp /vendor/lib/dsp ext4 ro,nosuid,nodev,barrier=1,context=u:object_r:adsprpcd_file:s0 wait,slotselect
/devices/*/xhci-hcd.0.auto* auto auto defaults voldmanaged=usb:auto
/devices/*/0000:01:00.0* auto auto defaults voldmanaged=usb:auto
/dev/block/zram0 none swap defaults zramsize=2147483648,max_comp_streams=8
aIecxs said:
so you can place adbkey.pub there instead. change these lines in overlay.d/sbin/adbguard.sh. increase the timeout. you can also add some output to see if script is running at all.
Bash:
while [ ${i:-0} -le 60 ]; do
set_adbkey /data/gsi/adb_keys
echo "Hello World ($i)" >> /data/gsi/hello.txt
Code:
adb push adbkey.pub /data/gsi/adb_keys
according to the ROM you linked, that is just FBE encryption, I bet some dev can fix that TWRP.
/vendor/etc/fstab.mata
Code:
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
/dev/block/platform/soc/1da4000.ufshc/by-name/system / ext4 ro,barrier=1 wait,slotselect,verify
/dev/block/platform/soc/1da4000.ufshc/by-name/userdata /data ext4 noatime,nosuid,nodev,barrier=1,noauto_da_alloc latemount,wait,check,formattable,fileencryption=ice,quota
/dev/block/platform/soc/1da4000.ufshc/by-name/misc /misc emmc defaults defaults
/dev/block/platform/soc/1da4000.ufshc/by-name/modem /vendor/firmware_mnt vfat ro,shortname=lower,uid=1000,gid=1000,dmask=222,fmask=333,context=u:object_r:firmware_file:s0 wait,slotselect
/dev/block/platform/soc/1da4000.ufshc/by-name/dsp /vendor/lib/dsp ext4 ro,nosuid,nodev,barrier=1,context=u:object_r:adsprpcd_file:s0 wait,slotselect
/devices/*/xhci-hcd.0.auto* auto auto defaults voldmanaged=usb:auto
/devices/*/0000:01:00.0* auto auto defaults voldmanaged=usb:auto
/dev/block/zram0 none swap defaults zramsize=2147483648,max_comp_streams=8
Click to expand...
Click to collapse
Alright I have replaced those lines and that file was never created, so it looks like it never runs the script

Categories

Resources