[Q] Extracting boot class path without directory info - Galaxy S 4 Developer Discussion [Developers-Only]

I am working on a new tool that will perform various function and one function i am trying to implement is the ability to odex / deodex system files.
The following command will extract the phones bootclasspath and save to a temp file ...
Code:
adb shell echo $BOOTCLASSPATH > tmp.txt
However, it saves the bootclasspath with all the directories to the files intact. For example,....
core.jar shows as /system/framework/core.jar
The whole file string looks like this...
Code:
/system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/framework2.jar:/system/framework/telephony-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar:/system/framework/sec_edm.jar:/system/framework/seccamera.jar:/system/framework/scrollpause.jar:/system/framework/stayrotation.jar:/system/framework/smartfaceservice.jar:/system/framework/abt-persistence.jar:/system/framework/secocsp.jar:/system/framework/sc.jar
Notice all the directory locations proceeding the actual file? So basically I am trying to find a way to pull the BCP without the directories showing since I am using a batch file to process the command.
I have even tried to remove the info from the text via batch file with the following but it didnt work...
Code:
findstr /V "/system/framework" tmp.txt > tmp2.txt
and a loop to pull just the few first characters....
Code:
[user=279333]@ECHO[/user] off
Set "InputFile=tmp.txt"
Set "OutputFile=tmp2.txt"
setLocal EnableDelayedExpansion > "%OutputFile%"
for /f "usebackq tokens=* delims= " %%a in ("%InputFile%") do (
set s=%%a
>> "%OutputFile%" echo.!s:~18!
)
But what i really need to make everything much simpler is a command to pull the BCP without the directories with them.
Thanks....

never mind....
I got some batch file help......this code scans the txt and pulls out the unwanted info
Code:
[user=279333]@ECHO[/user] OFF &SETLOCAL
FOR /f "delims=" %%a IN (tmp.txt) DO SET "BOOTCLASSPATH=%%a"
SET "BOOTCLASSPATH=%BOOTCLASSPATH:/system/framework/=%"
ECHO %BOOTCLASSPATH% > tmp2.txt
SET /p myvar= < tmp2.txt

Another way to do it is straight on the Android side using the basename utility:
Code:
for f in $BOOTCLASSPATH; do
name=$(basename "$f")
echo $name >> tmp.txt
done
Code above will work on pretty much any Linux OS

CNexus said:
Another way to do it is straight on the Android side using the basename utility:
Code:
for f in $BOOTCLASSPATH; do
name=$(basename "$f")
echo $name >> tmp.txt
done
Code above will work on pretty much any Linux OS
Click to expand...
Click to collapse
Right! Good info!
On another note, still creating some different options for the tool and have ran into an apparent size limitation for both user data and system images when extracted.
When performing the following command...
Code:
adb shell su -c "dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system.img bs=4096
I am getting an error that says the file is too large. So there must be some 2gb barrier that will not allow an image beyond that file sizeto be extracted. I can see that twrp and similar recoveries split their images into multiple files like system.ext4.win000 - system.ext4.win001. So my question is from a command line, how would one extract these images into multiple files?

Didact74 said:
Right! Good info!
On another note, still creating some different options for the tool and have ran into an apparent size limitation for both user data and system images when extracted.
When performing the following command...
Code:
adb shell su -c "dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system.img bs=4096
I am getting an error that says the file is too large. So there must be some 2gb barrier that will not allow an image beyond that file sizeto be extracted. I can see that twrp and similar recoveries split their images into multiple files like system.ext4.win000 - system.ext4.win001. So my question is from a command line, how would one extract these images into multiple files?
Click to expand...
Click to collapse
That's an interesting question...I think you can take advantage of dd's "count" and "skip" option to do it
Code:
#Copy first 1.5gb
dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system.img bs=4096 count=768 #1.5 * 1024 / 2 MB block size
#Copy the remaining 0.5 gb
dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system.img bs=4096 skip=768 count=256
Not very pretty, but I can't think of another way off the top of my head
What file system is the /%cardpath%/ that you're saving to?
The only downfall I see is that you need to know how large the entire system partition is first to see whether you need to break it up and the remainder to use for seek
--------
Also, I just thought of a sed one liner to do the bootclasspath thing you asked two posts above! Looks much cleaner IMO
Code:
echo $BOOTCLASSPATH | sed -e 's_\/system\/framework\/__g' > parsed.txt

CNexus said:
That's an interesting question...I think you can take advantage of dd's "count" and "skip" option to do it
Code:
#Copy first 1.5gb
dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system.img bs=4096 count=768 #1.5 * 1024 / 2 MB block size
#Copy the remaining 0.5 gb
dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system.img bs=4096 skip=768 count=256
Not very pretty, but I can't think of another way off the top of my head
What file system is the /%cardpath%/ that you're saving to?
Click to expand...
Click to collapse
Thats just my variable for the path to the SD card on my phone.
The above commands just result in a single 1mb file.
Can you explain what "count=768" represents?
oh....the file system is exfat

Didact74 said:
Thats just my variable for the path to the SD card on my phone.
The above commands just result in a single 1mb file.
Can you explain what "count=768 #1.5 * 1024 / 2 MB block size" represents?
Click to expand...
Click to collapse
Yes, I know that's the variable but unless it's formatted to some sort of FAT fs, it should copy the entire partition instead of stopping at a certain point.
Whoops, my math was off sorry. The concept is right, but I didn't spend too much time on the actual code
What I mean by that is that you're using bs=4096, which means you're going by 4096 byte chunks = 4 KB
Then you just do some math and calculate how many 4KB chunks are in 1.5GB and set that as the count parameter. So it would be (1.5GB *1024MB/GB ) / 4MB chunks = 384 MB chunks
384 MB chunks * 1024 KB/MB = 393216 KB chunks
So...
Final command would be
Code:
dd if=/dev/block/mmcblk0pXX of=/sdcard/out.img bs=4096 count=393216
And as you can see, it works...(I actually ran out of partition to copy so that's why it's 1.46)

CNexus said:
Yes, I know that's the variable but unless it's formatted to some sort of FAT fs, it should copy the entire partition instead of stopping at a certain point.
Whoops, my math was off sorry. The concept is right, but I didn't spend too much time on the actual code
What I mean by that is that you're using bs=4096, which means you're going by 4096 byte chunks = 4 KB
Then you just do some math and calculate how many 4KB chunks are in 1.5GB and set that as the count parameter. So it would be (1.5GB *1024MB/GB ) / 4MB chunks = 384 MB chunks
384 MB chunks * 1024 KB/MB = 393216 KB chunks
So...
Final command would be
Code:
dd if=/dev/block/mmcblk0pXX of=/sdcard/out.img bs=4096 count=393216
And as you can see, it works...(I actually ran out of partition to copy so that's why it's 1.46)
Click to expand...
Click to collapse
Okay, that makes sense.
File system is exFAT so i dont know why there is a size limit, but there is.
I am testing now to see what happens once the file reaches 1.5gb and how file #2 picks up. So this is what i have...
Code:
adb shell su -c "dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system.img bs=4096 count=393216"
adb shell su -c "dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system2.img bs=4096 skip=393216 count=196608"
I am not sure at this point what the last "count=" should be but I am trying 196608. Lastly, I would need to know how to join them into one file one on a local PC.
Will the last image grow to the count limit or will it only use the space needed? If i set it at 196606 will it only use what it needs or will the count force it to use it all?

The second count parameter should actually be 393,216÷3=131,072 (1.5gb / 3 = 0.5gb)
You can find the answer to that right here as I'm feeling lazy.
http://www.linuxquestions.org/linux...ltimedia/splitting_and_merging_files_using_dd
Didact74 said:
Will the last image grow to the count limit or will it only use the space needed? If i set it at 196606 will it only use what it needs or will the count force it to use it all?
Click to expand...
Click to collapse
I just ran a quick test on this and if you overshoot the count size, the last image will stop when it hits the end of the partition. So if there is 0.5gb left, it won't be any larger even if you specify for it to copy 0.8 gb.

CNexus said:
The second count parameter should actually be 393,216÷3=131,072 (1.5gb / 3 = 0.5gb)
You can find the answer to that right here as I'm feeling lazy.
http://www.linuxquestions.org/linux...ltimedia/splitting_and_merging_files_using_dd
I just ran a quick test on this and if you overshoot the count size, the last image will stop when it hits the end of the partition. So if there is 0.5gb left, it won't be any larger even if you specify for it to copy 0.8 gb.
Click to expand...
Click to collapse
Perfect, thank you. I think I have it worked out. Still in the process of learning linux so bare with me. I would like to use the standard dd command to not only copy the partition but save it to the local machine in one step rather than create and then pull.
So right now its this...
adb shell su -c "dd if=/dev/block/mmcblk0p%system% of=/%cardpath%/temp/system.img bs=4096 count=393216"
The dd is all happening in the virtual linux environment on the phone. Is there a way to dd out of the environment in one step? Like this?
adb shell su -c "dd if=/dev/block/mmcblk0p%system% of=**path to drive on local PC** bs=4096 count=393216"
This would copy the partition and save it to the local PC rather than copying it to the phone then pulling it.
Thanks,

Ah yeah, that annoys me too but I've never found a way around it because your device doesn't have a path to your PC's storage, it just knows that it's connected

CNexus said:
Ah yeah, that annoys me too but I've never found a way around it because your device doesn't have a path to your PC's storage, it just knows that it's connected
Click to expand...
Click to collapse
Okay so its a vicious circle ...lol. I can pull the system images in two parts, but rejoining them while still on the card revisits the whole 2gb file size barrier issue. While building, as soon as it hits 2gb, the command errors out.
If I pull the two separate parts from the card and rejoin them on the PC using cygwin there are no issues, everything builds fine.
However, I don't want cygwin to be required to run this tool. So my long winded question here is, what would be the BAT command to join these two files?
The command.........
system1.img+system2.img system.image
........results in a tiny 100kb file so something with that command is not working correctly unless there is a syntax i am missing.

Didact74 said:
Okay so its a vicious circle ...lol. I can pull the system images in two parts, but rejoining them while still on the card revisits the whole 2gb file size barrier issue. While building, as soon as it hits 2gb, the command errors out.
If I pull the two separate parts from the card and rejoin them on the PC using cygwin there are no issues, everything builds fine.
However, I don't want cygwin to be required to run this tool. So my long winded question here is, what would be the BAT command to join these two files?
The command.........
system1.img+system2.img system.image
........results in a tiny 100kb file so something with that command is not working correctly unless there is a syntax i am missing.
Click to expand...
Click to collapse
EDIT********
needed the /b switch
copy /b system1.img+system2.img system.img works great now.
Thanks

Didact74 said:
EDIT********
needed the /b switch
copy /b system1.img+system2.img system.img works great now.
Thanks
Click to expand...
Click to collapse
Ah, good deal.

Related

[Q] Unpack backup.ab created by "adb backup" command?

Is there any way to unpack the backup files created by the
Code:
adb backup -all
command? (Working since Android 4.0)
It seems this is a file-based backup and unpacking (and repacking) would allow tweaking some internal databases and files without needing to root.
I would like to know this also
I believe the ".ab" format is in some kind of "tar" compressed archive.
bakakaka said:
I believe the ".ab" format is in some kind of "tar" compressed archive.
Click to expand...
Click to collapse
Doesn't look like it. At least it's neither plain tar nor one of tarred gzip, bzip2 or compress. Also, it's not zip or rar.
So what's left?
- The android backup supports encryption. This does not necessarily mean that the archiver has to support that, too, since you could always first archive and then encrypt or vice versa.
- You can include .apk-files in backups. This suggests, that the archiver does not need to be über-effective, like bzip2, since that would cost time and cycles and .apk-files are already compressed, IIRC.
I don't know how to make any sense of this but maybe someone else does?
If anyone is still interested, here's a small utility that does this:
Apparently I can't post links, so add 'http' in front to get the URLs:
github.com/nelenkov/android-backup-extractor
More details about the format and the tool here:
nelenkov.blogspot.jp/2012/06/unpacking-android-backups.html
How to extract android adb ab backup
You can do it that way, you need dd and openssl. You can do it from linux, mac or windows with cygwin:
Code:
dd if=mybackup.ab bs=24 skip=1 | openssl zlib -d > mybackup.tar
scandiun said:
You can do it that way, you need dd and openssl. You can do it from linux, mac or windows with cygwin:
Code:
dd if=mybackup.ab bs=24 skip=1 | openssl zlib -d > mybackup.tar
Click to expand...
Click to collapse
Note that this only works for unencrypted backups though.
kapitan_petko said:
Note that this only works for unencrypted backups though.
Click to expand...
Click to collapse
I see
And the other way around:
1. create adb backup header
2. convert tar archive and append to header
Code:
echo -e "ANDROID BACKUP\n1\n1\nnone" > backup.ab
openssl zlib -in backup.tar >> backup.ab
Doesn't work
scandiun said:
You can do it that way, you need dd and openssl. You can do it from linux, mac or windows with cygwin:
Code:
dd if=mybackup.ab bs=24 skip=1 | openssl zlib -d > mybackup.tar
Click to expand...
Click to collapse
Doesn't work for me. I get this error: openssl:Error: 'zlib' is an invalid command.
What did I do wrong? Do I need to update my openssl?
CyanogenLover said:
Doesn't work for me. I get this error: openssl:Error: 'zlib' is an invalid command.
What did I do wrong? Do I need to update my openssl?
Click to expand...
Click to collapse
Run
Code:
openssl list-cipher-commands
And see if zlib is at the bottom
Which operating system are you using?
Nope, zlib is missing. I'm using Ubuntu 14.04. What do I do now?
Are there any other methods to unpack an .ab file?
any chance we can deflate .ab file on the phone itself ?
I know that one can deflate zlib by adding zlib header to the data then pass it through gzip:
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - filename | gzip -d
Click to expand...
Click to collapse
source: printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - body.zlib | gzip -dc
I even tried ( and failed, cause i'm getting 'corrupt data' error
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - /sdcard/backup.ab > /sdcard/backup2.ab
dd if=/sdcard/backup2.ab bs=24 skip=1 | busybox gzip -d > wa.tar
Click to expand...
Click to collapse
is the .ab ( without encryption ) is compress in some special way such that this technique isn't working ?
EDIT - SUCCESS !!!!
bu backup PACKAGE_NAME > /sdcard/backup.ab
dd if=/sdcard/backup.ab bs=24 skip=1 > /sdcard/backup2.ab
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - /sdcard/backup2.ab | busybox gzip -d > /sdcard/backup.tar
Click to expand...
Click to collapse
although gzip throws an error of 'gzip: corrupted data' - the ".ab" file is deflated into .tar, so that running
Code:
tar xvf <TARFILE> <FULL_INTERNAL_FILE_PATH> -C <WHERE_TO_EXTRACT_FILE>
extract the file I want !!!
EUREKA !!!!
DON'T YOU GET IT !?!?!
NOW IT IS POSSIBLE TO MAKE BACKUP SCRIPTS FOR APPS ON THE DEVICE ITSELF FOR FREE!
gps3dx said:
any chance we can deflate .ab file on the phone itself ?
I know that one can deflate zlib by adding zlib header to the data then pass it through gzip:
source: printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - body.zlib | gzip -dc
I even tried ( and failed, cause i'm getting 'corrupt data' error
is the .ab ( without encryption ) is compress in some special way such that this technique isn't working ?
EDIT - SUCCESS !!!!
although gzip throws an error of 'gzip: corrupted data' - the ".ab" file is deflated into .tar, so that running
Code:
tar xvf <TARFILE> <FULL_INTERNAL_FILE_PATH> -C <WHERE_TO_EXTRACT_FILE>
extract the file I want !!!
EUREKA !!!!
DON'T YOU GET IT !?!?!
NOW IT IS POSSIBLE TO MAKE BACKUP SCRIPTS FOR APPS ON THE DEVICE ITSELF FOR FREE!
Click to expand...
Click to collapse
Is root required?
---------- Post added at 03:38 PM ---------- Previous post was at 03:24 PM ----------
gps3dx said:
any chance we can deflate .ab file on the phone itself ?
I know that one can deflate zlib by adding zlib header to the data then pass it through gzip:
source: printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - body.zlib | gzip -dc
I even tried ( and failed, cause i'm getting 'corrupt data' error
is the .ab ( without encryption ) is compress in some special way such that this technique isn't working ?
EDIT - SUCCESS !!!!
although gzip throws an error of 'gzip: corrupted data' - the ".ab" file is deflated into .tar, so that running
Code:
tar xvf <TARFILE> <FULL_INTERNAL_FILE_PATH> -C <WHERE_TO_EXTRACT_FILE>
extract the file I want !!!
EUREKA !!!!
DON'T YOU GET IT !?!?!
NOW IT IS POSSIBLE TO MAKE BACKUP SCRIPTS FOR APPS ON THE DEVICE ITSELF FOR FREE!
Click to expand...
Click to collapse
Ok thanks but it probably requires root. Testing it in my Samsung S7 official stock ROM it generates a 0 bytes file. Note that not all apps allow adb backup, you have to perform backup only in those that allow it.
If I do "bu" on android terminal I get:
sh: resetreason: can't execute: Permission denied. Killed.
scandiun said:
Is root required?
Click to expand...
Click to collapse
bah... I think I gave my terminal emulator root perm, although I did not initiate any "su" command.
this gave some extra perm to the emulator...
so my answer is that root is required to run this command on the phone itself... but NO root is required is you run it through ADB from a PC.
so, yeah, no real special news here, but the fact that there is NO need to copy the backup to PC, because deflating zlib, tar extracting can be done on the phone itself.
which means in return, that NO special openSSL is needed to extract the WA key file.
gps3dx said:
bah... I think I gave my terminal emulator root perm, although I did not initiate any "su" command.
this gave some extra perm to the emulator...
so my answer is that root is required to run this command on the phone itself... but NO root is required is you run it through ADB from a PC.
so, yeah, no real special news here, but the fact that there is NO need to copy the backup to PC, because deflating zlib, tar extracting can be done on the phone itself.
which means in return, that NO special openSSL is needed to extract the WA key file.
Click to expand...
Click to collapse
Having root I would prefer to use Titanium backup or similar. The problem with adb backup is that not all apps are allowed to be backed up. There's a flag in AndroidManifest.xml
scandiun said:
Having root I would prefer to use Titanium backup or similar. The problem with adb backup is that not all apps are allowed to be backed up. There's a flag in AndroidManifest.xml
Click to expand...
Click to collapse
if you got root you don't need to use external backup, you have access directly to /data/data and can view/edit WA databases.
also, to backup WA's key, you MUST install old version of the app, then perform the "bu" backup.
( as OP's script does ).
scandiun said:
Having root I would prefer to use Titanium backup or similar. The problem with adb backup is that not all apps are allowed to be backed up. There's a flag in AndroidManifest.xml
Click to expand...
Click to collapse
Have a question, adb doesn't backup all kind of data, or doesn't backup all kind of apk?
I need some clarification please
Youms said:
Have a question, adb doesn't backup all kind of data, or doesn't backup all kind of apk?
I need some clarification please
Click to expand...
Click to collapse
It backups all apks provided that you use the -apk flag. For the data, it only backs up data for those applications that are allowed inside the manifest. with the app System Info for Android you can check the AndroidManifest of each app. Android does not tell you explicitly which apps will be backed up or not. iOS works much better, iTunes will backup all the data of your apps (the apps itself not, it have to be re-downloaded from the Apple Store, and if some app is removed from there you can't install it anymore).
Please, don't use dd bs=24, instead use dd ibs=24, which is a bit faster, but really fast is only
Code:
tail -c +25 backup.ab | zlib-flate -uncompress | tar -tf -

[Q] How to pipeline pipe contents from android phone via adb to my computer?

Suppose that I do the following command from windows:
Code:
adb shell cat /sdcard/myfile.zip > c:\file.zip
The result is that the two files don't match, even they have much different file size. Using 'adb pull' works but is not compatible with pipelining or fifos.
Any help?
EDITED: here is the solution:
Antonine said:
Right, I'm currently working on a project which involves imaging Android phones - specifically, the program I've written is mean to automate identifying the memory block containing the userdata and then using the following sequence of commands (using Android Debug Bridge) to copy it to the computer that the phone is connected to:
Code:
adb forward tcp:5555 tcp:5555
adb shell
busybox nc –l –p 5555 –e dd if=/dev/mtd/mtd[mtd block number]
This is done in command prompt and then you have to manually open another command prompt and type in:
Code:
adb forward tcp:5555 tcp:5555
nc 127.0.0.1 5555 | dd of=[chosen file name].bin -- progress
This copies the memory block over without any problems when done manually and even shows you in real time how much data has been transferred.
The problem I have is with automating the process in C#. Specifically, I can get every stage of it to work through using a process to write the commands to standard input and using a tcp listening port to receive the data. Apart from this crucial element of the process:
Code:
adb shell "busybox nc –l –p 5555 –e dd if=/dev/mtd/mtd[mtd block number]"
For some reason, no matter how I try to phrase it or do it, C# hates that command and won't execute it. I can manually type the exact same thing into the command prompt and it works fine but trying to do it in C# just leads to busybox acting as though I typed the command in incorrectly - this is what it gives me:
Code:
BusyBox v1.15.2 <2009-11-27 10:38:30 GMT> multi-call binary
Usage: nc [-in] [-wN] [-l] [-p Port] [-f FILENAME|PADDR PORT] [-e PROG]
Open a pipe to IP:port or file
Options:
-e PROG Run prog after connect
-i SEC Delay interval for lines sent
-w SEC Timeout for connect
-f FILE Use file <ala /dev/ttyS0> instead of network
-l Listen mode, for inbound connects
<use -l twice with -e for persistent server>
-p PORT Local port
The problem appears to be particularly with the use of bs=[bytes] but I've no idea why - and I've spent several hours searching all over the web for solutions.
So basically, I was wondering whether anyone else might have encountered this issue before and if anyone has any ideas to get around it? At the moment I'm using a script to send the commands to the command prompt but that's a kludge that I'd really prefer not to have to use.
Thanks in advance for any suggestions or comments and apologies if I've posted this in the wrong place.
Click to expand...
Click to collapse
zeppelinrox said:
Probably has to do with syntax.
In the first instance you don't have it in quotes.
Code:
busybox nc –l –p 5555 –e dd if=/dev/mtd/mtd[mtd block number]
Then you do have quotes the second time.
Code:
adb shell "busybox nc –l –p 5555 –e dd if=/dev/mtd/mtd[mtd block number]"
Sometimes, using a newer busybox helps too... 1.15.2 is kinda old
Click to expand...
Click to collapse
NOTE: you have to use unix paths with cygwin, not DOS ones. Use cygpath to convert:
Code:
cygpath -u "C:\your path\folder\archive"
Thanks man, you saved my life! I just deleted some pictures from my Nexus 7 and I had to find a way to dump the internal storage to my computer in order to use it with PhoroRec...
scandiun said:
Suppose that I do the following command from windows:
Code:
adb shell cat /sdcard/myfile.zip > c:\file.zip
The result is that the two files don't match, even they have much different file size. Using 'adb pull' works but is not compatible with pipelining or fifos.
Any help?
EDITED: here is the solution:
Click to expand...
Click to collapse
can't seem to get the -- progress part to work it kicks back error of invalid command
Code:
" adb forward tcp:5555 tcp:5555 "
" adb shell "
" su "
" busybox nc 127.0.0.1 5555 | dd of=C:\Users\PB-2\Desktop\GN-3_MJ5_Full.raw.img bs=4096 "
After inputting the last line I get:
: cannot open for write: Read-only file system
any Ideas? I don't understand how my pc desktop could be read only
Thanks in Advance
Phatboyj420 said:
can't seem to get the -- progress part to work it kicks back error of invalid command
Code:
" adb forward tcp:5555 tcp:5555 "
" adb shell "
" su "
" busybox nc 127.0.0.1 5555 | dd of=C:\Users\PB-2\Desktop\GN-3_MJ5_Full.raw.img bs=4096 "
After inputting the last line I get:
: cannot open for write: Read-only file system
any Ideas? I don't understand how my pc desktop could be read only
Thanks in Advance
Click to expand...
Click to collapse
You can't use DOS paths on cygwin, you have to use unix ones:
Code:
busybox nc 127.0.0.1 5555 | dd of=/cygdrive/c/Users/PB-2/Desktop/GN-3_MJ5_Full.raw.img bs=4096
You can convert any DOS path to unix with cygpath if you don't figure out directly (even on other drives):
Code:
cygpath -u "C:\Users\PB-2\Desktop\GN-3_MJ5_Full.raw.img"
Result:
Code:
/cygdrive/c/Users/PB-2/Desktop/GN-3_MJ5_Full.raw.img
scandiun said:
You can't use DOS paths on cygwin, you have to use unix ones:
Code:
busybox nc 127.0.0.1 5555 | dd of=/cygdrive/c/Users/PB-2/Desktop/GN-3_MJ5_Full.raw.img bs=4096
You can convert any DOS path to unix with cygpath if you don't figure out directly (even on other drives):
Code:
cygpath -u "C:\Users\PB-2\Desktop\GN-3_MJ5_Full.raw.img"
Result:
Code:
/cygdrive/c/Users/PB-2/Desktop/GN-3_MJ5_Full.raw.img
Click to expand...
Click to collapse
Awesome Thanks,
I'm assuming this is true in both cd & dd via cygwin?
I was originally trying to input the commands in DOS because your OP doesn't specify, or say to use cygwin.
I came to the realization of using cygwin after reading other guides.
I've been looking at some of your other guides I owe You many thanks as a Result
Phatboyj420 said:
Awesome Thanks,
I'm assuming this is true in both cd & dd via cygwin?
I was originally trying to input the commands in DOS because your OP doesn't specify, or say to use cygwin.
I came to the realization of using cygwin after reading other guides.
I've been looking at some of your other guides I owe You many thanks as a Result
Click to expand...
Click to collapse
Yes, since cygwin is to be compatible with unix scripts paths must be always in unix format.
You can use dos paths directly
Code:
cd `cygpath -u "C:\your path\folder\archive"`
I've updated the first post
scandiun said:
Yes, since cygwin is to be compatible with unix scripts paths must be always in unix format.
You can use dos paths directly
Code:
cd `cygpath -u "C:\your path\folder\archive"`
I've updated the first post
Click to expand...
Click to collapse
Awesome share Thanks
I still can't get this to work "for the life of me" I know, I now have cygwin setup right, as it works with your example here
Phatboyj420 said:
Awesome share Thanks
I still can't get this to work "for the life of me" I know, I now have cygwin setup right, as it works with your example here
Click to expand...
Click to collapse
Are you still getting "cannot open for write"?
scandiun said:
Are you still getting "cannot open for write"?
Click to expand...
Click to collapse
Nope you set me strait on that one
In the first window I do
Code:
" adb forward tcp:5555 tcp:5555 "
" adb shell "
" su "
" system/xbin/busybox nc –l –p 5555 –e dd if=/dev/block/mmcblk0 bs=4096 "
and get the usage response
Code:
BusyBox v1.22.1-Stericson (2014-01-25 17:27:18 CET) multi-call binary.
Usage: nc [-iN] [-wN] [-l] [-p PORT] [-f FILE|IPADDR PORT] [-e PROG]
Open a pipe to IP:PORT or FILE
-l Listen mode, for inbound connects
(use -ll with -e for persistent server)
-p PORT Local port
-w SEC Connect timeout
-i SEC Delay interval for lines sent
-f FILE Use file (ala /dev/ttyS0) instead of network
-e PROG Run PROG after connect
If I trade out the string from your other example here, " The only problem i'm having with your other example is that I can't specify the " bs=4096 " "
I can get through to the second window
Example
Code:
[email protected] ~
$ adb forward tcp:5555 tcp:5555
[email protected] ~
$ adb shell
[email protected]:/ $ su
su
[email protected]:/ # /system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox dd if=/dev/block/mmcblk0 bs=4096
555 -e /system/xbin/busybox dd if=/dev/block/mmcblk0 bs=4096 <
The second terminal then gives me an error at the last string
Output of second terminal
Code:
[email protected] ~
$ adb forward tcp:5555 tcp:5555
[email protected] ~
$ nc 127.0.0.1 5555 | dd of=/cygdrive/c/Users/PB-2/Desktop/GN-3_Tmp/mmcblk0.raw bs=4096 -- progress
dd: unrecognized operand `progress'
Try `dd --help' for more information.
If I run it with out, " -- progress " it runs but with-out the desired effect of the progress response
Code:
[email protected] ~
$ adb forward tcp:5555 tcp:5555
[email protected] ~
$ nc 127.0.0.1 5555 | dd of=/cygdrive/c/Users/PB-2/Desktop/GN-3_Tmp/mmcblk0.raw bs=4096
I'm at a loss I need to figure out how to run the pv and the dd of= in the same line i guess
or to some how combine
Code:
" nc 127.0.0.1 5555 | dd of=/cygdrive/c/Users/PB-2/Desktop/GN-3_Tmp/mmcblk0.raw bs=4096 "
&
Code:
" nc 127.0.0.1 5555 | pv -i 0.5 > /cygdrive/c/Users/PB-2/Desktop/GN-3_Tmp/mmcblk0.raw "
So as to achieve both the bs= & the Read-out notification
Thanks tremendously, for your assistance thus far.
That's right, some android implementations of dd lack advanced parameters. You can try either installing Busybox from Stericson or just skip the bs option.
Removed all the "bs=4096" from quotations in first post, since it's not needed at all.
I keep getting
write error: File too large, when trying to dump my /data partition to my external sd card.
The external card is exFat formatted, which is supposed to be able to handle larger than 4Gig files
here's my command
Code:
busybox dd if/dev/block/mmcblk0p29 of=/mnt/extSdCard/data.ext4.img
any ideas?
p.s. yes, I do have more than 4G's of software on my phone
kevp75 said:
I keep getting
write error: File too large, when trying to dump my /data partition to my external sd card.
The external card is exFat formatted, which is supposed to be able to handle larger than 4Gig files
here's my command
Code:
busybox dd if/dev/block/mmcblk0p29 of=/mnt/extSdCard/data.ext4.img
any ideas?
p.s. yes, I do have more than 4G's of software on my phone
Click to expand...
Click to collapse
Two ideas:
1 - Try from recovery
2 - If that doesn't work put the sd into a card reader and connect it as otg drive.
scandiun said:
Two ideas:
1 - Try from recovery
2 - If that doesn't work put the sd into a card reader and connect it as otg drive.
Click to expand...
Click to collapse
I can try from recovery sure, but how would #2 solve the issue? (don't know what otg drive means)
kevp75 said:
I can try from recovery sure, but how would #2 solve the issue? (don't know what otg drive means)
Click to expand...
Click to collapse
Search google images for otg
scandiun said:
Search google images for otg
Click to expand...
Click to collapse
didnt work. I get the same issue
Rockin' it from my Smartly GoldenEye 35 NF1 (muchas gracias:* @iB4STiD @loganfarrell @muniz_ri @Venom0642 @ted77usa @rebel1699* @iB4STiD) ~ 20GB free cloud https://copy.com?r=vtiraF
Check me out online @ http://kevin.pirnie.us
kevp75 said:
didnt work. I get the same issue
Click to expand...
Click to collapse
Format a pendrive in NTFS or HFS+ and connect it to your phone via OTG, if it's not detected directly there are some apps on play store.
scandiun said:
Format a pendrive in NTFS or HFS+ and connect it to your phone via OTG, if it's not detected directly there are some apps on play store.
Click to expand...
Click to collapse
NTFS worked. My data partition is over 8Gigs! But I was under the impression that exFat was able to support that... but I guess not...
kevp75 said:
NTFS worked. My data partition is over 8Gigs! But I was under the impression that exFat was able to support that... but I guess not...
Click to expand...
Click to collapse
Next time you can try copying some big data to the exfat from the computer itself, just to see if prompts some error.
scandiun said:
Next time you can try copying some big data to the exfat from the computer itself, just to see if prompts some error.
Click to expand...
Click to collapse
tried that too had a 9.7g dvd imaage i tried with and it failed at the 4g mark. ext4 should be the standard
Rockin' it from my Smartly GoldenEye 35 NF1 (muchas gracias:* @iB4STiD @loganfarrell @muniz_ri @Venom0642 @ted77usa @rebel1699* @iB4STiD) ~ 20GB free cloud https://copy.com?r=vtiraF
Check me out online @ http://kevin.pirnie.us

[GUIDE][TUTORIAL][SHARE] How to make a nandroid backup directly to your computer with

Note: I'm just sharing the work of the XDA member.This guide was tested on Galaxy Y GT-S5360.Here's a little introduction:
scandiun said:
INFORMATION
This guide is intended to make a full backup of your android phone (the entire memory block with all partitions) or a single partition (including sdcards, etc) directly to your computer, in either
Block level (with dd): for single partitions or whole memory block (all partitions in one piece). The backup always has the same size which is the size of the partition.
File level (with tar): only for individual partitions. This only includes files and folders, so occupies much less space, depending on how much filled is the partition.
It can be done with the phone powered on or from ClockWorkMod Recovery (from both ADB works, while in Fastboot doesn't so won't apply). Unless specified the commands meant to be used from Windows. For Linux and Unix is similar.
REQUIREMENTS
Rooted Android Phone
Busybox installed on your phone
If you are using Linux / OS X you have native tools, for Windows download Cygwin, and install with it netcat, pv and util-linux. Get them from Cygwin's setup.exe
ADB installed.
Make sure adb.exe is in your windows' path. See here and here, or use Path Manager.
Android phone with USB Debugging enabled, and the proper drivers installed on Windows so the phone is recognized. Typing 'adb devices' on a terminal should show your device.
PARTITION IDENTIFICATION
You now have to identify the partition or block device that you want to backup. For a single partition you can use either tar or dd, while for the entire memory block you can only use dd.
For example, on Galaxy Nexus you have the list of partitions here and for Galaxy S2 here.
Usually on android, the entire block containing all partitions is located at /dev/block/mmcblk0 and the data partitions is a subpartition of it. You can push parted with GPT support to your device and see all information on a partition or block.
Whole phone memory -> /dev/block/mmcblk0 (may vary, in some phones this is the sdcard)
Subpartitions -> depends on each device. Usually at /dev/block/platform/dw_mmc/by-name/ there are listed by name linking to the real device.
Back up of the whole memory block (via adb)
Connect the phone in ADB mode and unlock the screen.
Open one Cygwin Terminal and enter (replace mmcblk0 if needed):
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox dd if=/dev/block/mmcblk0
You will see the cursor blinking at the left. Now the phone is waiting to send the block over the network.
Open another Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw
You will see how the image size is growing until it finishes. Now you have the whole phone backed up in raw format. You can see the contents of the GPT partition with gptfdisk tool, available for windows, linux and such. See official website and sourceforge to get it. You can do it the same from ClockWorkMod Recovery but you have to mount first the /system partition since the busybox included with clockworkmod does not come with netcat and you have to use the one from the system partition.
With further linux tools you could edit or extract single partitions from the whole block.
You can use adb via wifi as well with applications like WiFi ADB.
Back up of the whole memory block (via wifi)
Original post: [Q] Nandroid directly to computer w/o sdcard
We need to install a FTP server on the computer or the other device, configure a user with a password if we want to, and set some port. It uses by default 21 but this example uses 40. We must set a home dir for the user with write permissions.
Usually is a good idea to put myfifo in /cache not in /data because we may overwrite sensitive data in case we want to use that raw image for data recovery.
Open one Cygwin terminal
Code:
adb shell
su
mkfifo /cache/myfifo
ftpput -v -u user -p pass -P 40 COMPUTER_IP block.raw /cache/myfifo
Open another Cygwin terminal
Code:
adb shell
su
dd if=/dev/block/mmcblk0p12 of=/cache/myfifo
Tips:
- Fifos only can be made on linux native filesystems, for example on a FAT partition is not possible.
- Reading from a partition does not modify it.
Now check on Filezilla Server the speed
Back up of the whole memory block (USB tethering, Wifi tethering)
To use tethering you have to disconnect the computer from all networks and connect it only to the phone with the type of connection you want.
Once you connect it, you can view the IP of the computer and the IP of the phone from connection properties. The ip is the computer ip and the gateway is the phone's ip.
Wifi Tethering: Computer Phone Internet
USB Tethering:
Computer Phone Internet
Conputer Phone Internet
This is exactly the same as via wifi, except that the transfer speed is much higher because the computer and the phone are directly connected, instead of using a router as a gateway. In this case, the gateway is the phone. USB tethering has the highest transfer rate.
Back up of a single partition (raw = every bit of the partition)
It is exactly the same as the the previous but replacing mmcblk0 by the corresponding partition. You can use in this particular case several software to read the partition from windows, depending on partition filesystem: DiskInternals Linux Reader, Ext2Read, Ext2 File System Driver for Windows, Ext4Explore, plugin for Total Commander and ImDisk Virtual Disk Driver. You can also use recovery software on individual partitions like Recuva in combination with VHD Tool or command line tools included with operating systems.
Back up of a single partition (tar = only files and folders)
In this case, you need the partition mounted. To see the list of mounted partitions type on Cygwin Terminal
Code:
adb shell mount
Now you need to know where is mounted the partition you want to backup, for example the firmware is mounted on /system, which is the ROM.
In this case you will have to open three terminals, because of android limitations:
Open one Cygwin terminal and create a fifo, in /cache, for example, and redirect the tar there
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox mkfifo /cache/myfifo
/system/xbin/busybox tar -cvf /cache/myfifo /system
We have to do it this way because redirecting the tar to stdout (with - ) is broken on android and will corrupt the tar file.
Open a second Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox cat /cache/myfifo
Open a third Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > system.tar
You can browse the tar file with Winrar, Total Commander, PeaZip and almost any compression tool. Note that you shouldn't extract files or edit it since the tar format saves the permission and owner data for each file, that is lost when extracted to FAT / NTFS partitions and you will mess things when restoring.
LINKS
[GUIDE] Internal Memory Data Recovery - Yes We Can!
How to Create and Attach a Virtual Hard Disk in Windows 7
[Guide] Types of Android backups
Click to expand...
Click to collapse
Original Thread : http://forum.xda-developers.com/showthread.php?t=1818321
And here is the guide to make nandroid backup through terminal app in android with switching off the phone in sdcard!!!
http://forum.xda-developers.com/showthread.php?t=1620255

How to split the image cloned by dd command?

Hi,
I just use adb to connect to the mobile device, then using dd command to clone and image of the internal storage, as below:
dd if=/dev/block/mmcblk0p18 of=/storage/sdcard1/myclone.img
However, the clone fails after it reaches 4GB limit. Since sdcard is using FAT system and it only support maximum file size at 4GB.
Therefore, I try to split the image into small pieces, as follows:
dd if=/dev/block/mmcblk0p18 bs=1m | gzip -c | split -b 2045m - /storage/sdcard1/myclone.img.gz
However, this time I get an error said "split" is not a reconized command.
If split is not usable under Android, then how to split the large image into small pieces?
Thanks

Self-Erasing Build.prop?

Disclosure: I'm intentionally editing build.prop to feel out the limits one can tweak it, I'm fully aware I can completely brick these devices doing this. ​
With that said, ive encountered an issue that replicates on different devices and have no clue as to how or why.
Target Devices:
Samsung S21 (USA-TMB)
Samsung S22 (USA-XAA)
LG V20 (USA-XAA)
LG Velvet (USA-TMB (MTK))
Google Pixel6 Pro
All devices above have been rooted and i have patched bootloader and VBmeta &/or Preloader.
On ALL of the above devices, when i edit the build prop, it simply edits into a blank build.prop. This was replicated using Root Explorer Pro, Rom ToolBox Pro & SmartPack Kernel Manager (F-Droid)
I also tried making a backup before edit, then restore. The system still Bricks upon reboot.
Even if i don't edit the build prop directly, but rather replace it, even with an identical one. The system refuses to read it next boot.
On Most of the listed devices - System is A/B - Also worth noting is the build.prop in /system references importing the build.prop and default.props from /Vendor and /Product. Could that have anything to do with it?
Trouble-Shooting steps taken:
Ensured /System is mounted
Tried Different methods for editing build.prop "on-device"
pull to pc, edit, push back.
Google - XDA Search (duh)
is this DM-Verity? TF am I missing?
So if I understand correctly:
You mount -o rw,remount /system
You adb pull some-text-file
You edit some-text-file
You adb push some-text-file
Did you subsequently adb pull some-text-file to make sure that it was actually changed?
This isn't a super (dynamic partition) with /system /vendor /product all together, is it?
Do:
Code:
dd if=/dev/block/by-name/system of=/sdcard/check skip=big-number
Big number = count of sectors in system partition - 8 // for eMMC
Big number = count of sectors in system partition - 1 // for UFS
You should end up with a file exactly 4096 bytes. If you don't play with the numbers.
Hexedit that file, does it start with fe cf ec fe? Then it has FEC.
Renate said:
So if I understand correctly:
You mount -o rw,remount /system
You adb pull some-text-file
You edit some-text-file
You adb push some-text-file
Did you subsequently adb pull some-text-file to make sure that it was actually changed?
This isn't a super (dynamic partition) with /system /vendor /product all together, is it?
Do:
Code:
dd if=/dev/block/by-name/system of=/sdcard/check skip=big-number
Big number = count of sectors in system partition - 8 // for eMMC
Big number = count of sectors in system partition - 1 // for UFS
You should end up with a file exactly 4096 bytes. If you don't play with the numbers.
Hexedit that file, does it start with fe cf ec fe? Then it has FEC.
Click to expand...
Click to collapse
Super - yes. is this same as system as root? (Sorry if it's an obvious question, I'm learning)
Yes , correct, i ever tried changing Owner and permissions (chmod 777)
Thats the weird part, when i did pull the file from the device it actually came out the other end on my pc intact with all the props - i then proceeded back to device and checked the file in /system and it was blank, as well as the build.bak.
At first thought it was the file explorer (Root Explorer Pro) but when tried manually, same result.
Don't know if its relevant or not to the issue, but i WAS able to use setprop on some props, but only select ones, and I'm not able to figure out the bias as to which one I can or can't.
Persisitent props are stored in /data, so those would work.
Do the dd and tell me if you have FEC. This is for me, your numbers will be different.
Code:
Poke3:/ # dd if=/dev/block/by-name/system of=/sdcard/check skip=6291448
8+0 records in
8+0 records out
4096 bytes (4.0 K) copied, 0.000839 s, 4.6 M/s
Numbers too high will say "Can't skip". Numbers too low will give you a file that's too big.
Do:
Code:
dd if=/dev/block/by-name/system of=/sdcard/check skip=big-number
Big number = count of sectors in system partition - 8 // for eMMC
Big number = count of sectors in system partition - 1 // for UFS
You should end up with a file exactly 4096 bytes. If you don't play with the numbers.
Hexedit that file, does it start with fe cf ec fe? Then it has FEC.
Click to expand...
Click to collapse
Came back weird, does this need to be run as root?
Code:
$ dd if=/dev/block/by-name/system of=/sdcard/check skip=big-number
dd: not integer: big-number
K0mraid3 said:
Came back weird, does this need to be run as root?
Code:
$ dd if=/dev/block/by-name/system of=/sdcard/check skip=big-number
dd: not integer: big-number
Click to expand...
Click to collapse
dumb question lol disregard. same result.
ill go check in /data now
/data is fine. Just check system partition. Using real numbers. Actually integers.
Bump...

Categories

Resources