[Q] Export / Import Apps-Data from / to data.img - HD2 Android Q&A, Help & Troubleshooting and Genera

Hello,
I would like to get some help with my SD-Build Android MccM MIUI.
First it started random crashes of the lockscreen. I could power on the display but it kept being black. I only could reset my HD2 and reboot my Android.
Now my Android doesn't boot anylonger. It opens the HTC-Boot-Animation und nothing happens. I waited about an hour.
I replaced the Android-folder on my SD-Card and Android booted again. But my contacts and the apps (their stored data) which I installed after the backup aren't available. With the old version, Android don't boot. If I only replace data.img with my backup, Android boots but without the apps.
My question ist, how do I get the apps-data (e.g savegames) exported from data.img and imported in my backup version?
Could please someone help me?
Greetings Marco
PS: Sorry, my English is a little bit rusty.

Kaschparl79 said:
I replaced the Android-folder on my SD-Card and Android booted again. But my contacts and the apps (their stored data) which I installed after the backup aren't available. With the old version, Android don't boot. If I only replace data.img with my backup, Android boots but without the apps.
My question ist, how do I get the apps-data (e.g savegames) exported from data.img and imported in my backup version?
Click to expand...
Click to collapse
I am a little confused. Did you overwrite your data.img file or do you still have the original one? If you still have it your apps and data should be contained in there.
You should be able to read/view the file in Linux if you have a bootable Linux CD.
If you only have Windows copy the original data.img file to your PC and download/install this old program and unzip it. It should allow you to view the content of your data.img and extract things from it.

NYLimited said:
I am a little confused. Did you overwrite your data.img file or do you still have the original one? If you still have it your apps and data should be contained in there.
You should be able to read/view the file in Linux if you have a bootable Linux CD.
If you only have Windows copy the original data.img file to your PC and download/install this old program and unzip it. It should allow you to view the content of your data.img and extract things from it.
Click to expand...
Click to collapse
I'm sorry about your confusion.
I backuped the data.img file before overwriting it with an older backup to get Andoid working again. So I still have the file which seem a little bit corrupt.
These were my thoughts that the apps should be stored in there. I think I'll try both suggestions. Thanks.
Edit: Thanks for your help. I already had ext2explorer on my PC. And I could open data.img. Now I have to find the place where the apps stored (savegames ) their data and my phonebook. Any suggestions where to look for the phonebook and maybe the game tribez?
Greetings from Germany

Kaschparl79 said:
I'm sorry about your confusion.
I backuped the data.img file before overwriting it with an older backup to get Andoid working again. So I still have the file which seem a little bit corrupt.
These were my thoughts that the apps should be stored in there. I think I'll try both suggestions. Thanks.
Edit: Thanks for your help. I already had ext2explorer on my PC. And I could open data.img. Now I have to find the place where the apps stored (savegames ) their data and my phonebook. Any suggestions where to look for the phonebook and maybe the game tribez?
Click to expand...
Click to collapse
That gets a little more complicated.. Generally, the contacts are stored in a SQLite database. The location can vary depending on the ROM that is installed.
The simplest attempt, without getting too technical and installing a SQLite CLI is to look for the contacts database. Try something like this in the terminal window:
Code:
su
find /system -iname '*.db' |grep ontact
Hopefully, you will see something like this as a result:
Code:
/dbdata/databases/com.android.providers.contacts/contacts.db
/data/data/com.android.providers.contacts/databases/contacts2.db
You can try copying the files and see if they help.
Good luck!

NYLimited said:
That gets a little more complicated.. Generally, the contacts are stored in a SQLite database. The location can vary depending on the ROM that is installed.
The simplest attempt, without getting too technical and installing a SQLite CLI is to look for the contacts database. Try something like this in the terminal window:
Code:
su
find /system -iname '*.db' |grep ontact
Hopefully, you will see something like this as a result:
Code:
/dbdata/databases/com.android.providers.contacts/contacts.db
/data/data/com.android.providers.contacts/databases/contacts2.db
You can try copying the files and see if they help.
Good luck!
Click to expand...
Click to collapse
Thanks again.
Found the contacts in data/... but copying it into the other data.img caused some shutdown of ...acore process/program. The same problem with the savegame. Process tribez is unsepected stopped...
Maybe I'm doing something wrong mounting the data.img. Do know the exact command for mounting the file correctly for writing data?

Kaschparl79 said:
Thanks again.
Found the contacts in data/... but copying it into the other data.img caused some shutdown of ...acore process/program. The same problem with the savegame. Process tribez is unsepected stopped...
Maybe I'm doing something wrong mounting the data.img. Do know the exact command for mounting the file correctly for writing data?
Click to expand...
Click to collapse
You are asking good questions but not easy ones to answer. The mount command is specific to your device and rom. I do not have any sd roms to look at.
Let's try a few things.
First, try to clear cache for the contact apps. You can use ROM Toolbox or the system's app manager. This may help.
Second, you can try to look in the ROM's system folder and see if you have something like init.rc (probably in root, if there) If you find it look at it with a text viewer and search for Mount. You may find the proper command line.
Last, and this one needs to be modified, you can try something like these in the terminal window. Keep in mind that your device names and file systems are most likely different!
Code:
mount yaffs2 [email protected] /mnt/cache nosuid nodev
mount ext4 /dev/block/mmcblk0p2 /NativeSD wait noatime nodiratime barrier=0
---
Duct tape is like the force. It has a light side and a dark side and it holds the universe together. (via Tapatalk)

Thanks, solved
NYLimited said:
You are asking good questions but not easy ones to answer. The mount command is specific to your device and rom. I do not have any sd roms to look at.
Let's try a few things.
First, try to clear cache for the contact apps. You can use ROM Toolbox or the system's app manager. This may help.
Second, you can try to look in the ROM's system folder and see if you have something like init.rc (probably in root, if there) If you find it look at it with a text viewer and search for Mount. You may find the proper command line.
Last, and this one needs to be modified, you can try something like these in the terminal window. Keep in mind that your device names and file systems are most likely different!
Code:
mount yaffs2 [email protected] /mnt/cache nosuid nodev
mount ext4 /dev/block/mmcblk0p2 /NativeSD wait noatime nodiratime barrier=0
Click to expand...
Click to collapse
Thanks for your help. I made it work.
As I use an older SD-Version of Android your last code I couldn't use.
For those who will have a similar problem:
With the programm file I checked the data.img and it is an ext4 image which I mounted in linux. I mounted the workung data.img file, too.
Next I deleted the folders which contained the contacts and of cause the savegame from the good data.img. Then I copied these folders from the faulty data.img into the good data.img. But I had to use the terminal and cp with option -a to preserve the ownerships of the files and folders.
After that I used fsck on the unmounted data.img and copied the file back on my sd card. Everything worked fine.
Thanks again and greetings from Germany

Related

How do you delete a stale NFS file

Wallpaper set and save, I tried the rm command it wont work for a stale file is there any way to do this.
unless you really mounted a network drive, there's no way you can get a "stale NFS file", so the file system is corrupted.
billc.cn said:
unless you really mounted a network drive, there's no way you can get a "stale NFS file", so the file system is corrupted.
Click to expand...
Click to collapse
So I have wallpaper set and save as being stale, does that mean more files will become like this, and that my ext2 partition is bound to fail, cause I can live without that wallpaper program, as long as the rest of my stuff is stable. Does this mean more files will eventually become corrupt.
Joeriginal said:
So I have wallpaper set and save as being stale, does that mean more files will become like this, and that my ext2 partition is bound to fail, cause I can live without that wallpaper program, as long as the rest of my stuff is stable. Does this mean more files will eventually become corrupt.
Click to expand...
Click to collapse
Not necessarily. nfs stale file handle just means that nfs cannot resolve the nfs file handle that ext2 encoded for it. there could be many reason for it. lots of time, remount would fix the problem.
knaries2000 said:
Not necessarily. nfs stale file handle just means that nfs cannot resolve the nfs file handle that ext2 encoded for it. there could be many reason for it. lots of time, remount would fix the problem.
Click to expand...
Click to collapse
How would I do this remount process exactly? And would I be risking anything?
What exactly are you doing. Where are you getting this error?
knaries2000 said:
What exactly are you doing. Where are you getting this error?
Click to expand...
Click to collapse
I'm trying to install the program wallpaper set and save but the phone won't let me cause its a stale nfs file on my memory card ext2 partition, and I wanted to know if there is any way to fix that
Rebooting the phone does not solve it? If not then u might have an issue with your sdcard.
No reboot didn't help, this is the only app that does this so I don't think its the sdcard. I think it was a bad installation, and now its stuck somehow, oh well hopefully someone might find a resolution for this.
I was wondering would it be possible to move my apps back to the phone, and then delete the wallpaper set and save from a program like linda file manager then put them back on the sd card.
Joeriginal said:
I was wondering would it be possible to move my apps back to the phone, and then delete the wallpaper set and save from a program like linda file manager then put them back on the sd card.
Click to expand...
Click to collapse
do you have adb setup?
just do "adb shell ls /data/app/" and see if that wallpaper app is there... if it is try to remove it "adb shell rm /data/app/<name.apk>
knaries2000 said:
do you have adb setup?
just do "adb shell ls /data/app/" and see if that wallpaper app is there... if it is try to remove it "adb shell rm /data/app/<name.apk>
Click to expand...
Click to collapse
nope that didnt work, will it be possible to move them back to the phone, I used recovery mode to put them on my sdcard, and Im on RC33mod, can I do the undo copy.sh app or do I have to use recovery again.
I dont know about the copy.sh script, but u can do it by removing the symlink in /data/app
And then copy the app dir from sd back to /data
knaries2000 said:
I dont know about the copy.sh script, but u can do it by removing the symlink in /data/app
And then copy the app dir from sd back to /data
Click to expand...
Click to collapse
Sorry Im not to savy with all this, How would I go about doing that.
so there is no other way of me getting rid of wallpaper set save stale nfs, and reinstalling it, cause I cant get it on my phone. thats the only program and I like using to set my wallpapers is there another way.
you could always mount it in linux and run fdisk. delete that partition and remake it. that is what I had to do to clean up my /system/sd directory from stale NFS handles. If you need more help with this let me know.

extract nandroid backups?

I flashed my phone to JF 1.5 and in the process some how managed to screw up my sd card and lost all my apps. i did do a nandroid backup of jf 1.41 so i ahve those img files. I tried to restore to that to recover everything but it wont boot past the g1 logo. I tried downgrading firmware to 1.43 (couldnt find 1.41) and using the same restore for nandroid and still wouldnt boot. I also tried jsut applying the user data img to see if i could jsut grab that and it fialed on both firmware revisions 1.5 , 1.43.
In the end im stuck with a backup i cant use, the only thing i need off of it is the apps. I read that you can use the emulator to mount it but i couldnt figure that out. I also looked at yaffs extractor from the google code site but i wasnt quite sure how to compile/run it.
Anyone have a simple solution or a complex one i can follow to getting my apps out?
did you follow this?
http://forum.xda-developers.com/showpost.php?p=3311708&postcount=2
darkrangr said:
I also looked at yaffs extractor from the google code site but i wasnt quite sure how to compile/run it.
Click to expand...
Click to collapse
You go into the source directory, type "gcc -o unyaffs unyaffs.c", then you (create and) go to some directory where you want to extract the contents ("mkdir ~/extract") "cd ~/extract", and finally you extract the image "/path/to/unyaffs /path/to/data.img".
I tried the standard nandroid restore and it failed.
Trying the yaffs thing now and i got an error.
I placed the yaffs files all in a folder on the sdcard and put the img in that folder as well.
I open the terminal on the phone and did cd /sdcard/nan nan being the directory i made
I then tried to run that command "gcc -o unyaffs unyaffs.c" and i get gcc not found. what did i do wrong?
Unless your backup was corrupted, flashing the backup should have been fine.
Code:
fastboot flash boot boot.img
fastboot flash system system.img
fastboot flash userdata data.img
You said it failed - what error did it give? Did it say it couldn't find the command? Be sure you're running these commands on your PC with your G1 connected via USB, the correct drivers are loaded, and you have the fastboot program.
As for using unyaffs - I don't think you understand what you have to do to use it. You have to compile it on your PC...all you get is the source code. I haven't looked on the google code site, but I would imagine there isn't a version for windows.
EDIT: After reading your original post for a second time, I have to ask: if you screwed up your SD card and lost all of your apps, does that mean you were using Apps2SD? That's a bit of an important detail to leave out, if so. Unless I'm mistaken (and someone correct me if I'm wrong), your apps wouldn't be in the backup anyway, you're wasting your time. If your backup is just restoring the symlinks to the SD card and the SD card is screwed up, then no wonder it's hanging at boot. You'd need to wipe your SD card and start from scratch. I'd recommend doing that either way - would you rather have to redownload a few apps or continue having a bricked phone for days?
it didnt fail on the restore with fastboot, it loaded up everything fine and then when i rebooted it just sat on the boot screens forever and never loaded.
I am feeling nice so darkrangr if you want to PM your image files I will unyaffs it on my ubuntu box for you.
TemporalShadows said:
EDIT: After reading your original post for a second time, I have to ask: if you screwed up your SD card and lost all of your apps, does that mean you were using Apps2SD? That's a bit of an important detail to leave out, if so. Unless I'm mistaken (and someone correct me if I'm wrong), your apps wouldn't be in the backup anyway, you're wasting your time. If your backup is just restoring the symlinks to the SD card and the SD card is screwed up, then no wonder it's hanging at boot. You'd need to wipe your SD card and start from scratch. I'd recommend doing that either way - would you rather have to redownload a few apps or continue having a bricked phone for days?
Click to expand...
Click to collapse
no, my apps were installed normally. I am running curent jf firmwar enow while i try to get my stuff back, but some of the apps i had are no longer available or have converted to pay apps, plus i forgot a lot of apps i had.
http://forum.xda-developers.com/showthread.php?t=497034
In the other tools archive on this post you can find the unyaffs tool fully compiled. Just move your image to the same folder, drag and drop it on the unyaffs.exe and watch the files appear.
How about YOU DIDN'T INSTALL GCC!!!
darkrangr said:
I tried the standard nandroid restore and it failed.
Trying the yaffs thing now and i got an error.
I placed the yaffs files all in a folder on the sdcard and put the img in that folder as well.
I open the terminal on the phone and did cd /sdcard/nan nan being the directory i made
I then tried to run that command "gcc -o unyaffs unyaffs.c" and i get gcc not found. what did i do wrong?
Click to expand...
Click to collapse

Location of apps after app2sd?

With root explorer, i see that my apps are saved to something like '/system/sd/app,' but when I mount my G1, I can't find that folder. I can't even find the "system" folder. Anyone have any ideas?
Also, I pressed the "R/W" button on that folder in Root Explorer, but now I can't switch it back to R/O. It gives me an error saying, "Remount Failed: Device or resource busy."
what is it you want to do with the apps?
My gmail app is force closing, and I haven't found a way to reinstall it through market. I was going to try to replace the .apk.
I don't believe the gmail app is on the SD, it should be under /system/app/Gmail.apk
For the most part, the system apps install on the phone, the rest are on SD.
That still leads me to my first question, lol. I can't find the "system" folder after mounting my G1.
??
I don't know. I use the rooted file browser SUFBS and have never had a problem seeing the system folder.
Might have been associated with other changes you made to the system.
For me, if all else fails, I re-partition, wipe & re-flash.
Hopefully someone else can offer some better info.
I find it fine on my G1 via Root Explorer. It's just that I can't seem to locate it on my computer (i.e something like h:\system\app), after plugging my G1 in.
Sorry for any confusion.
You must be on a windows machine. You can not nativly see an ext partition under windows.
Look at the guides that tell you how to set up adb and adb push the application to the folder you want.
adobrakic said:
I find it fine on my G1 via Root Explorer. It's just that I can't seem to locate it on my computer (i.e something like h:\system\app), after plugging my G1 in.
Sorry for any confusion.
Click to expand...
Click to collapse
You can do these things right from recovery console, and probably terminal, I like recovery better though. place the file you want to use on the root of the SDcard. Since it is the Gmail.apk you want to replace you would go about it like this:
mount system
mount sdcard
cp /sdcard/Gmail.apk /system/app/Gmail.apk
reboot
thats pretty much it.

Minimal UI for LUKS encryption on the Wildfire

This is a basic gui I wrote to unlock my encrypted partitions during boot.
I'm running my /data and /sdcard partitions encrypted, and the "luksunlock" binary is launched from init.rc to read the password and unlock the encrypted partitions.
I have included my somewhat modified init.rc for those interested.
For more information about LUKS on Android see this blogpost, written by shawn (Seems I'm not allowed to have urls in the post, but Google for 'android luks' , first hit)
This works good on Wildfire, altough it should work fine on other phones as well. Just remember that you need to set up your partitions as in the luksunlock.c (or change the defines).
Dont forget to backup before you start playing around!
Good luck!
Thanks! i'll give a try!
Hi,
I tried to use your cryptsetup binary from your blog, but I have some issues that you'll sure have an answer:
I run ./cryptsetup luksFormat -c aes-plain /dev/block/loop2 and after i put the luks password it says 'Command failed', no logs, no other output, even using the -v flag...
Any clue?
Thanks in advance!
PS: the module dm-crypt is necessary for cryptsetup? could be this the error? I don't have it installed on the system because I can't find it for 2.6.35.9-cyanogenmod
tusabe said:
Hi,
I tried to use your cryptsetup binary from your blog, but I have some issues that you'll sure have an answer:
I run ./cryptsetup luksFormat -c aes-plain /dev/block/loop2 and after i put the luks password it says 'Command failed', no logs, no other output, even using the -v flag...
Any clue?
Thanks in advance!
PS: the module dm-crypt is necessary for cryptsetup? could be this the error? I don't have it installed on the system because I can't find it for 2.6.35.9-cyanogenmod
Click to expand...
Click to collapse
CM6.1 for wildfire uses a 2.6.32 kernel (see HCDR.jacob's post about his custom kernel for more info)
tusabe said:
PS: the module dm-crypt is necessary for cryptsetup? could be this the error? I don't have it installed on the system because I can't find it for 2.6.35.9-cyanogenmod
Click to expand...
Click to collapse
Yeah you really need dm-crypt support, either compiled into the kernel or as a module. You also need the AES ciphers support.
sigkill1337 said:
Yeah you really need dm-crypt support, either compiled into the kernel or as a module. You also need the AES ciphers support.
Click to expand...
Click to collapse
Hi! Yeah, that's what I was afraid of.... ok, but the problem is that i'm running CM6.1 with 2.6.35.9 which has no dm-crypt module neither compiled in kernel... where can i find some kernel with this modules included? Is for an HTC Desire (@Sympnotic )
Thanks in advance!
Great work and thanks for sharing @Sigkill. Working on building it here for my NexusOne with CM6.1.
BTW, I’m the lead on a project working on general secure Android distro – we’ve ported Tor, have an OTR IM app, and have supported other projects along those lines. Would love to talk more about supporting anyone working on this specific capability.
wow! awesome work!!! Very exciting news. Gonna give this a go on my MyTouch Slide
NathanFreitas said:
Great work and thanks for sharing @Sigkill. Working on building it here for my NexusOne with CM6.1.
BTW, I’m the lead on a project working on general secure Android distro – we’ve ported Tor, have an OTR IM app, and have supported other projects along those lines. Would love to talk more about supporting anyone working on this specific capability.
Click to expand...
Click to collapse
Seems really nice. I like the secure phone concept.
New Makefile and wiki info up
_hc from the @guardianproject has a new build process up for Crypsetup/LUKS which includes a Makefile compatible with Android NDK r5.
We have new instructions up on our wiki, as well.
I cannot post links under this account, but you can find the info on github if you search "LUKS" or just under our guardianproject account.
How did you create the encrypted partitions? Could you give some pointers for that. I am familiar with using dmcrypt/cryptsetup on desktop linux, I guess this works similar. What are the relevant device names? Did you run into any problems?
Calavera1 said:
How did you create the encrypted partitions? Could you give some pointers for that. I am familiar with using dmcrypt/cryptsetup on desktop linux, I guess this works similar. What are the relevant device names? Did you run into any problems?
Click to expand...
Click to collapse
Hi, sorry for the late answer,
/dev/block/mtdblock5 is the "userdata" partition. I formatted it and mount it to /encrypted-data during init:
mount yaffs2 [email protected] /encrypted-data nosuid nodev
The only file on this partition is "data.encrypted" file, which gets created in init.rc as a loopback device:
exec /system/bin/losetup /dev/block/loop0 /encrypted-data/data.encrypted
I created the "data.encrypted" file on my computer with cryptsetup and losetup, and copied all files from my old unencrypted userdata partition to it and then copied it back as a file to the formated userdata partition.
The sdcard "/dev/block/mmcblk0p2" partition is formated with "cryptsetup luksFormat", I did this also on my computer, saves some time. And then copy everything from the old unencrypted sdcard.
I did run in to one problem recently, my phone hung during boot, about 4 months after I started encrypting my phone.
Had to copy my data.encrypted file to my computer, mount it as a loopback device and do a fsck, and then copy it back to my phone.
I suspect this has to do with the filesystem not being umounted properly. (I have had this on my to do list for a while hehe)
Probably should make a script run during shutdown to cleanly "luksClose" the encrypted partition and then umount them. Not doing this is probably very crazy
I also want to fix it so my "/dev/block/mmcblk0p2" partition gets presented to my computer when i attach my usb cable (as it should do), so i can unlock it in ubuntu and copy images and files. Right now i have to take my memorycard out and put it into the computer.
I hope this post makes sense, it was written in haste =) Good luck!
sigkill1337 said:
Hi, sorry for the late answer,
/dev/block/mtdblock5 is the "userdata" partition. I formatted it and mount it to /encrypted-data during init:
mount yaffs2 [email protected] /encrypted-data nosuid nodev
The only file on this partition is "data.encrypted" file, which gets created in init.rc as a loopback device:
exec /system/bin/losetup /dev/block/loop0 /encrypted-data/data.encrypted
I created the "data.encrypted" file on my computer with cryptsetup and losetup, and copied all files from my old unencrypted userdata partition to it and then copied it back as a file to the formated userdata partition.
The sdcard "/dev/block/mmcblk0p2" partition is formated with "cryptsetup luksFormat", I did this also on my computer, saves some time. And then copy everything from the old unencrypted sdcard.
I did run in to one problem recently, my phone hung during boot, about 4 months after I started encrypting my phone.
Had to copy my data.encrypted file to my computer, mount it as a loopback device and do a fsck, and then copy it back to my phone.
I suspect this has to do with the filesystem not being umounted properly. (I have had this on my to do list for a while hehe)
Probably should make a script run during shutdown to cleanly "luksClose" the encrypted partition and then umount them. Not doing this is probably very crazy
I also want to fix it so my "/dev/block/mmcblk0p2" partition gets presented to my computer when i attach my usb cable (as it should do), so i can unlock it in ubuntu and copy images and files. Right now i have to take my memorycard out and put it into the computer.
I hope this post makes sense, it was written in haste =) Good luck!
Click to expand...
Click to collapse
I figured most of that out without your post and tried it on my desire (I created the luks partitions with adb on the phone though, worked anyway ). Then I couldn't figure out where my regular init.rc is stored (I could only find the one used by Clockwork Recovery), and then I figured I already spent enough time, tried a reboot (which of course didn't work). Then I couldn't even get into recovery (probably because its init.rc tries to mount /data which doesn't work? I didn't investigate any further). Flashed my backup with fastboot and was stuck again with my un-encrypted pre-experiment state
Oddly enough, it was no problem to unlock my encrypted SD-card from my computer (running ubuntu) while in recovery (clockword has an option to present the sd card to a computer connected via usb). Maybe the booted system handles this differently than recovery though? I didn't get a chance to try, as I couldn't boot after my encryption attempt.
I will try again after my algorithm and data structure exam this friday and report back
Is anybody using the UI on another device than the Wildfire? Does it work?
How much is the performance drain when using an encrypted /data partition?
Amazing work!
Did anyone manage to make sigkill1337's luksunlock build from source ?
I would like to change the path of the data/sdcard partitions to match my device but I tried many ways using the NDK and I can't get it to compile properly.
Is there any way to do this ?
I have been trying for days, I am getting literaly insane !
@sigkill1337 : could you give me some pointers ? I would appreciate a lot.
mount manpage said:
The bind mounts.
Since Linux 2.4.0 it is possible to remount part of the file hierarchy somewhere else. The call is
mount --bind olddir newdir
or shortoption
mount -B olddir newdir
or fstab entry is:
/olddir /newdir none bind
After this call the same contents is accessible in two places. One can also remount a single file (on a single file).
This call attaches only (part of) a single filesystem, not possible submounts. The entire file hierarchy including submounts is attached a second place using
mount --rbind olddir newdir
or shortoption
mount -R olddir newdir
Note that the filesystem mount options will remain the same as those on the original mount point, and cannot be changed by passing the -o option along with --bind/--rbind. The mount options can be changed by a separate remount command, for example:
mount --bind olddir newdir
mount -o remount,ro newdir
Click to expand...
Click to collapse
If nothing helps, you should always be able to bindmount it
I'd rather get sigkill1337's UI to compile...
Lots of nice security tweaks and settings could be done with a pre-boot GUI
Anyway, concerning encryption, I'll use the bind option for now, thanks for the tip.
But if anyone here could give me some pointers about compiling this stuff it would be great.
I managed to compile it by integrating luksunlock in Android source externals and main.mk but when I push it to my phone and modify init.rc to call it, it just does not work...
Other modifications are working (mount, mkdir, etc.) but the GUI won't show up
Sorry for the late reply.. But you could try running it from a shell when the phone is booted, just to verify that the binary starts (thats how I tested it without having to reboot my phone all the time)
My environment for building the source was setup using one of the tutorials online, nothing out of the ordinary
Im still running this on my phone, for almost 8 months now, I havent noticed that much in performance problems, the Wildfire was slow before i started using luks.
When i get a new phone (maybe SE Arc) i will be easier to see if performance is affected
There is an Issue for getting CM support for encrypted filesystems during boot:
Issue 2736: support encrypted filesystem from boot
If you want to get that feature, just "star" it, so it may get more attention.

[MOD][SCRIPT] Get More Storage by Relocating Dalvik Cache!

DISCLAIMER: YOU AGREE TO TAKE FULL RESPONSIBILITY FOR YOUR DEVICE IF YOU PROCEED.
The original thread (http://forum.xda-developers.com/moto-g/general/mod-save-data-space-cache-partition-t2942765) was getting to cluttered up with development and testing so I decided to start a new thread with the "finished" product. The original thread will be renamed to Q&A/Development. We might even ask for the old thread to be closed down. (up to @Bert98, the thread's creator.)
Moto G's internal eMMC card has a ~600Mb partition called /cache, which is not used since the apps' cache is stored in /data, so the latter fills up and the first one stays empty.
Owning a 8Gb model, having 600Mb not available for storage really bugged me, because my phone's memory (/data partition) was always full because it's a 5.7Gb space shared between apps and microSD files.
Now, it may not work for you if:
a) you have A LOT of apps installed.
And by "a lot", I mean more than 90-100 apps, but if you have a 8Gb model, you probably don't
b) you're running ART (this is default in lollipop and newer)
Since ART uses a lot more space than dalvik, the space in the /cache partition probably won't be enough. When I was running ART, it used 1Gb more than dalvik.
Original post by @Bert98
Click to expand...
Click to collapse
This was tested on my moto g 16GB which is running RetailUS_4.4.4 kitkat with CWM recovery. The custom ROM procedure was tested on the same phone but with cm11 Nightly installed.
Prerequisites:
1. You must have "adb root" functioning. If you don't head to this thread: http://forum.xda-developers.com/showthread.php?t=1687590 and there is a free download link at the bottom of the post.
Download and install the apk on your phone. Open up adbd insecure (the new app) and grant it superuser rights PERMANENTLY. Check the box that says "enable insecure binary" and make sure to check the box
that says "enable at boot."
2. You must have a recovery that can accept adb shell commands.
3. Root Access Duh?!
4. A windows machine capable of running batch files.
5. A decent text editor, notepad will work but notepad++ is strongly recommended. (Only needed if you are using STOCK ROM procedure)
Please, please make a nandroid backup before you continue!!!!
Stock ROM procedure:
Read the directions very carefully and then read them again, before continuing.
1. Download the cachemover_v1.3.zip from: LINK REMOVED DUE TO SCRIPT ISSUES.
2. Extract the contents.
3. Connect device to PC and navigate to the extracted folder.
4. Double click/Run the cachemover_Stock.bat
5. Follow the onscreen instructions until you get to the part where it says to edit a file.
6. About halfway through the script it will pull a file called "init.qcom.post_boot.sh" to the folder.
7. Open it with a TEXT editor and navigate to about line 487 (Might be different for 8gb model). Look here for a better understanding: https://www.dropbox.com/s/jr5lyl5s5i2jtpg/where to paste code.PNG?dl=0
8. Start a new line and paste this code in the file: (Refer to the image above for help)
Code:
chmod 655 /cache
chmod 655 /cache/dalvik-cache
chmod 655 /cache/dalvik-cache/*
9. Make sure to save the file in the same folder as the cachemover_Stock.bat
10. Press any key to continue on the script and let it do its thing.
11. It will reboot several times and land you on the home screen/lock screen.
12. If the script hangs after a reboot, you need to unlock the device to reestablish a connection with your computer.
13. There might be one or two force closes but once you close the notifications they will not come back.
Custom ROM procedure:
USE THIS FOR ROMS THAT DO NOT REMOUNT OR CHANGE PERMISSIONS OF /CACHE ON BOOT
1. Download the cachemover_v1.3.zip from: https://www.dropbox.com/s/bzj34g4q1s61ojz/cachemover_v1.3.zip?dl=0
2. Extract the contents.
3. Connect device to PC and navigate to the extracted folder.
4. Double click/Run the cachemover.bat
5. Follow the onscreen instructions.
If anything goes wrong:
Go to recovery, wipe cache, then wipe dalvik-cache and reboot. This should get your device back to how it was.
(If you used STOCK ROM procedure)
The script made a backup of the "init.qcom.post_boot.sh" file to /sdcard/init_backup
You can restore the shell script to /system/etc/ via shell commands or by using a root browser. To restore permissions:
Code:
chmod 740 /system/etc/init.qcom.post_boot.sh
chown root:root /system/etc/init.qcom.post_boot.sh
Custom ROM procedure already has a restore script!
I am currently working on an auto restore script for stock and that will be relased soon, hopefully! :good:
Changelog:
v1.0 - First stable release. Does not work on STOCK ROM.
v1.1 - Added a restore script.
v1.3 - Added support for STOCK ROM. There are still a few bugs.
How it works?!?!
Coming soon...
Huge thanks to @Bert98 and @dd043
Hit the thanks button if it worked! I went through about 50 factory resets, and reflashed the ROM about 25 times, and put about 10 hours of work into this script! Really motivates me for future projects. :laugh:
Thanks for your help man and effort.
I encountered a problem, everything works up until my device boots in CWM to fix permissions, then just sits there doing not alot I don't even see the option in my CWM.
Any ideas? cheers
Sent from my XT1032 using XDA Free mobile app
When it reboots to cwm unplug the cable and replug it, if it hangs just type these commands manually from a command window.
chmod 655 /cache
chmod 655 /cache/dalvik-cache
chmod 655 /cache/dalvik-cache/*
reboot
If this does not work you may ned to go into mounts & storage in the cwm menu and click mount /cache. Then try the commands again.
I'm having some issues on stock.
I thought 0655 fixed everything but no, I can't install any app after moving the dalvik-cache to /cache. I tried chmoding 0777 on the new cache folder, on /cache itself, to no avail.
Code:
E/dexopt cannot open '/data/dalvik-cache/[email protected]' for output
Anyone can confirm it's not only my device? And/or can help find a fix?
Also does someone knows how to execute commands on a particular init step? Real init.rc scripts can do:
Code:
on post-fs-data
mount -o bind /cache/dalvik /data/dalvik-cache
It there was a way to achieve the same from post_boot/init.d we could mount -o bind /cache/dalvik /data/dalvik-cache and all permissions issues would disappear as well as the need for symlink.
You have a typo in the threads title. Just a heads up.
Vuciz said:
You have a typo in the threads title. Just a heads up.
Click to expand...
Click to collapse
Thanks for letting me know!
dd043 said:
I'm having some issues on stock.
I thought 0655 fixed everything but no, I can't install any app after moving the dalvik-cache to /cache. I tried chmoding 0777 on the new cache folder, on /cache itself, to no avail.
Code:
E/dexopt cannot open '/data/dalvik-cache/[email protected]' for output
Anyone can confirm it's not only my device? And/or can help find a fix?
Also does someone knows how to execute commands on a particular init step? Real init.rc scripts can do:
Code:
on post-fs-data
mount -o bind /cache/dalvik /data/dalvik-cache
It there was a way to achieve the same from post_boot/init.d we could mount -o bind /cache/dalvik /data/dalvik-cache and all permissions issues would disappear as well as the need for symlink.
Click to expand...
Click to collapse
Let me try and do that right now... Ill get back to you if it does!
My script works on stock btw... But the mount way seems a bit easier and might cause less errors than my way.
Try it please.
skyguy126 said:
Let me try and do that right now... Ill get back to you if it does!
My script works on stock btw... But the mount way seems a bit easier and might cause less errors than my way.
Try it please.
Click to expand...
Click to collapse
Yes I've tried your script, all went well but the result is the same. The script itself works nicely btw
Applications present before moving cache work perfectly, but I can't install anything new. I suspect it might be my device but before wiping everything I'd prefer feedback from others :fingers-crossed:.
I cannot install new apps as well. The mount command you showed me has the same effect too. I honestly don't know anymore, the sym link did not allow the install of new apps nor did the mount command you sent me. Correct me if I am wrong.
Edit: Going through all the init files on my phone to see which one remounts /cache at boot.
Why does the init.rc get overwritten at boot. Is it because the kernel (boot.img) is the one that copies it over? I have found by changing the perms/locations in this file and init.target.rc you can achieve what this mod is trying to acomplish.
I don't see the mount cache command in CWM strange
I've managed to get back to normal, thanks for everyone's help though, I will keep and eye on the thread
Sent from my XT1032 using XDA Free mobile app
non-windows version?
Thanks for this tool. It's a great idea and our Motos really need it.
However, I have a problem - I do not own a windows license (os x and ubuntu user) and I would prefer not to spend $120 just to use it for this script. Pirating is out of the question for me.
I was wondering if there is any chance of having this script written for linux and/or mac. If impossible, is there a LEGAL way of running windows in a virtual machine? Something like a trial or similar?
If you know how just convert it to shell script for osx and Linux. I give you permission to do this but you may not take credit or rehost your creation.
Ok so I have the kernel extracted and we could modify and flash that, but I believe that it's not really necessary. There are a lot of risks to flashing kernels and I am not willing to take it. So is there a way we can modify dalvik so it creates it's cache in /cache instead.
skyguy126 said:
Why does the init.rc get overwritten at boot. Is it because the kernel (boot.img) is the one that copies it over? I have found by changing the perms/locations in this file and init.target.rc you can achieve what this mod is trying to acomplish.
Click to expand...
Click to collapse
Yes the init.rc is in the boot ramdisk. I don't think it would be worth the trouble to rebuild a boot.img. The moto g is fairly unbrickable but it's quite a lot of work to setup an environment to rebuild an image :/.
Too bad for the mount command, I was sure it was working but maybe I had changed something else and don't quite remember the steps to reproduce
We could possibly implement a shell script toggler for when we need to install new apps, but I'm afraid it'd become annoying fairly quickly: I noticed the issue initially because google play services decided to update itself, failed, and broke all google apps. As far as I know this autoupate can't be disabled.
Thanks for trying!
dd043 said:
Yes the init.rc is in the boot ramdisk. I don't think it would be worth the trouble to rebuild a boot.img. The moto g is fairly unbrickable but it's quite a lot of work to setup an environment to rebuild an image :/.
Too bad for the mount command, I was sure it was working but maybe I had changed something else and don't quite remember the steps to reproduce
We could possibly implement a shell script toggler for when we need to install new apps, but I'm afraid it'd become annoying fairly quickly: I noticed the issue initially because google play services decided to update itself, failed, and broke all google apps. As far as I know this autoupate can't be disabled.
Thanks for trying!
Click to expand...
Click to collapse
How about making a simple apk that toggles this feature. Something like when you click the icon it doesn't even open but gives a little notification of success. Something like that. I myself am not experienced with apks but I can put together a shell script for the apk.
skyguy126 said:
Ok so I have the kernel extracted and we could modify and flash that, but I believe that it's not really necessary. There are a lot of risks to flashing kernels and I am not willing to take it. So is there a way we can modify dalvik so it creates it's cache in /cache instead.
Click to expand...
Click to collapse
Patching dalvik itself sounds promising. It can probably be done with in a batch script with a command line hex editor.
The path is defined in frameworks/base/cmds/installd/installd.h
Code:
#define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
Not sure if there is another mention in the source tree.
But there's nothing to say we wouldn't face the same issue, the error message in the logcat is pretty generic
dd043 said:
Patching dalvik itself sounds promising. It can probably be done with in a batch script with a command line hex editor.
The path is defined in frameworks/base/cmds/installd/installd.h
Code:
#define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
Not sure if there is another mention in the source tree.
But there's nothing to say we wouldn't face the same issue, the error message in the logcat is pretty generic
Click to expand...
Click to collapse
Ill try it. I don't mind doing a bunch of resets because I am using my moto g as a test bench anyway. My daily driver is the OnePlus One
dd043 said:
Patching dalvik itself sounds promising. It can probably be done with in a batch script with a command line hex editor.
The path is defined in frameworks/base/cmds/installd/installd.h
Code:
#define DALVIK_CACHE_PREFIX "/data/dalvik-cache/"
Not sure if there is another mention in the source tree.
But there's nothing to say we wouldn't face the same issue, the error message in the logcat is pretty generic
Click to expand...
Click to collapse
EDIT: Unfortunately it didn't work. I don't know if I modified the installd file correctly. The program I used is HxD.
Is there a way we can force dalvik to start after the directories are created. And change dalvik to create it in /cache.

Categories

Resources