[GUIDE] Persistent Temp Root for G2 to SD Card - G2 and Desire Z Android Development

Problem: Changes to the system partition are lost when Linux flushes the disk cache: http://pastebin.com/cm75Z9UA
These instructions are a workaround to provide temp root like normal plus persistence because /system /data and /cache are partitions on your SD card. This lets you reboot and even factory reset, while being able to easily restore your settings and such by re-rooting and mounting your SD card partitions back over the internal partitions.
Prerequisites:
SD card partitioned with four partitions:
6GB as fat (for your data, can be bigger or small depending on your card size)
400MB ext3 for /system
1.3GB ext3 for /data
200MB ext3 for /cache
On the phone, enable "USB debugging" in Menu -> Settings -> Applications -> Development
On a PC with the Android SDK tools (adb) installed and working:
adb push Superuser.apk /data/local
adb push busybox /data/local
adb push rage /data/local
adb push resume /data/local
adb push root /data/local
adb push rsync /data/local
adb push setup /data/local
adb push su /data/local
adb install Term.apk
adb shell chmod 755 /data/local/busybox /data/local/rage /data/local/setup /data/local/resume /data/local/rsync /data/local/root
On the phone, open "Terminal Emulator" and type:
/data/local/rage
Wait for it to say "[+] Forked NNNN childs." then press the back button.
Open "Terminal Emulator" again and it should force close.
Open it one more time and the prompt should display "#". Then type:
/data/local/root
/data/local/setup
You may need to re-root after it reloads the GUI, but then it will stick. setup is a script that mounts your SD card partitions and copies the existing. It should only be run once unless you want to erase what you have there previously. This step wont work if you SD card is not partitioned properly.
On future power-ons, run this after temp-root instead of setup:
/data/local/resume
and you should get your Android back how it was.

is it suppose to scan through all apps on phone then reboot

Thanks muchly, I'll try this when my G2 arrives.
I have a question about this method. It looks to me that what setup does is copy the entire system, data, and cache to the SD card. Then, when you run resume, it uses rsync to bring the main system (in the onboard flash) up to date from the SDcard version, and then any changes, even if not actually written to the main system partition due to the HTC copy protection, get written to the sdcard copy of the system. Very clever (if I'm reading this write, otherwise, still clever, but me not so clever as I mis-understood).
The question is this: Are there any glitches or instabilities generated by suddenly changing the system files after the OS is already booted? Do I have to make sure to do this before I begin using my phone after boot or risk making changes that I will then loose when I run resume?
Thanks again for the work putting this together!
Sheep

Sheep, you understand almost completely. Setup does copy the existing data from the internal phone memory to the SD card. However, it then (like resume) doesn't copy anything back, it just mounts the system, data, and cache partitions from the SD card on top of the internal ones.
I had issues with the internal memory reverting back after I make changes to it. It seemed to happen over a short time, or was triggered by things like mounting the SD card to a computer.
I've been using this for about 24 hours with no problems. I've done a couple fresh boots and ran resume. But I didn't test the instructions from scratch, so if anyone tests and finds a problem, let me know!

Any performance hit because of running from SD?

I haven't really noticed any.

How does this impact battery life?
Sent from my T-Mobile G2 using XDA App

Can't say, I've had my phone hooked up most of the time through adb looking for root. Just did this for fun and because I was sick of re-rooting all the time.

looks interesting I'll try it out tomorrow
Sent from my T-Mobile G2

so your sd card has to be partitioned pryor to trying this

pre-partitioned card?
thatruth132 said:
so your sd card has to be partitioned pryor to trying this
Click to expand...
Click to collapse
yes it does

texasaggie1 said:
yes it does
Click to expand...
Click to collapse
and how do i do this on a non-rooted device

thatruth132 said:
and how do i do this on a non-rooted device
Click to expand...
Click to collapse
Use your G1 to partition the card.
Brad

You can also connect your phone to a Linux computer (a LiveCD would be fine) and use gparted or fdisk. Don't forget to backup the contents of your card first!

Pretty cool. But I think I'm gonna wait for a more permanent solution....

sheek360 said:
Pretty cool. But I think I'm gonna wait for a more permanent solution....
Click to expand...
Click to collapse
There are no roms available yet any ways, so to a non dev, non cook like me, the Root is pretty much useless

I'd read that the currently available root was good until a reboot, then I saw this thread that made rerooting after a reboot much easier. Since then I've seen some posts that seem to indicate that a root may spontaneously disappear even without rebooting. Is this the case, some permissions may be lost even if you don't reboot?
I was ready to pull the trigger on this permanent-temporary root until I read that. I'd like to be able to import my old wpa_supplicant.conf file and get my corp ipsec vpn working. I'd also like to be able to get wifi-tether working (although I rarely use it), but if root won't stay 100% until a reboot, then I'm not going to bother.

Dalamak said:
There are no roms available yet any ways, so to a non dev, non cook like me, the Root is pretty much useless
Click to expand...
Click to collapse
Not true. I'm not a dev or a cook, but there are things that you can make the phone do with root besides adding a theme or ROM.
wifi tether
ipsec vpn
backups
etc...

smasraum said:
I'd read that the currently available root was good until a reboot, then I saw this thread that made rerooting after a reboot much easier. Since then I've seen some posts that seem to indicate that a root may spontaneously disappear even without rebooting. Is this the case, some permissions may be lost even if you don't reboot?
I was ready to pull the trigger on this permanent-temporary root until I read that. I'd like to be able to import my old wpa_supplicant.conf file and get my corp ipsec vpn working. I'd also like to be able to get wifi-tether working (although I rarely use it), but if root won't stay 100% until a reboot, then I'm not going to bother.
Click to expand...
Click to collapse
With temp root on the internal system partition, writes would revert back after certain things (after mounting the sd card to a computer through the phone and disconnecting it, I'd always loose root). When running /system from an sd card, no writes can be reverted because none are made, so I've never had to re-root.

how to partition an SD card?
thatruth132 said:
and how do i do this on a non-rooted device
Click to expand...
Click to collapse
I used gparted in ubuntu to do mine. Like SAINTH said, the install disk for ubuntu is also a livecd so you dont even have to install ubuntu if u dont want to

Related

New (hybrid) Hero root method

I have a slightly different Hero root method that persists the unlocked boot.img so you can do 'adb remount' to remount RW the file system... this was a key requirement for me!
Details:
http://android.modaco.com/content/h...oting-the-hero-step-by-step-my-hybrid-method/
Kudos to those who have gone before... I plan to add more stuff to the update.zip used here going forward.
P
yeah, adb as root is a must. it's the first thing i did when i received my hero
maybe it's better if you include wlan.ko in the update, because if someone who uses the update had a different kernel version wifi will not work
I´m receiving my HERO in a couple of hours. I´m going to use the 2Gb card that comes with the phone untill my new 16Gb class6 card arrives next week.
One question, do I need to "re-root" my device when I swap the cards next week?
I read something about that I have to have a card inserted during the root proccess.
I guess it is only used during the job...?!
modaco said:
Details:
http://android.modaco.com/content/h...oting-the-hero-step-by-step-my-hybrid-method/
Click to expand...
Click to collapse
To confirm, you do step 4 without the Hero connected to the PC?
Also, once rooted, what are my benefits? I understand I can move apps to the SD card? Is this done through the phone?
Well spotted, rejigged the instructions!
P
It seems to work...Thnx! no we will wait for a rom
Weird.. I keep getting "error: device not found" while in Device Manger I have a directory called "ADB Interface" with a device called "HTC Dream". Shouldn't that be "HTC Hero"?
So I do have a ADB device connected, but there's a fault somewhere..
EDIT: Found what I was doing wrong. I updated the driver for the SD card instead of the actual phone.. Stupid me. Great tutorial, but not fool-proof yet
As I enter 'adb push update-hero-signed.zip /sdcard/update.zip' I get the following error -
The program can't start because AdbWinApi.dll is missing from your computer. Try reinstalling the program to fix this problem.
What have I done wrong?
Okay, while typing this I realise I actually need to go to the folder I unzipped this too and then into the Hero folder. Maybe add this to instructions? Or is it just me being stupid?
Okay, seemed very easy (how do I check it worked).
I'm now looking at this about how to move apps to the SD card -
http://android-dls.com/wiki/index.php?title=Haykuro_Apps_to_SD
What does it refer to when it says "Setup in 5.0.1 onwards"?
Looks a little complex to me
I assume there are no custom ROM's out just yet...?
What is the difference with that method? Why hybrid? What is adb remount for?

Moving Files From SD Card To Internal Memory Possible?

Hey guys, I love this site and the outpour of support. This is really the first issue I've run into with my evo thus far.
I want to move some files I made into ringtones from my SD card into the internal memory in the location of the stock ringer sounds. I want to do this so if I ever take out or swap SD cards I never have to worry about losing my ringers. I have been using the astro file browser but it apparently does not let me move or copy and paste the file(s) where I want them.
Is there any way to do this?
thanks a lot!
Also follow up question. My SD Card always mounts when I plug my phone into my PC. Is there a way to stop this? even when I put the phone to charge only, the SD card shows up in Win7.
You need to have root and NAND unlock if you want to do anything like that, but it is possible.
If you have NAND unlocked, you can do it with your phone running normally, but I would use ADB in your particular situation. You can also use something like Root Explorer, but it costs money.
If you do not have NAND unlocked, but you have toast's root, you must go into recovery first.
If you know how to use ADB and you have full root (w/ NAND unlock), you should be able to use a command line in Windows to this effect.
For ringtones:
Code:
adb shell cat /sdcard/ringtone.mp3 > /system/media/audio/ringtones/
For notification sounds:
Code:
adb shell cat /sdcard/notification.mp3 > /system/media/audio/notifications/
For the files on your SD.
Otherwise you can push from the Windows itself. In command line, navigate to the area in Windows where you have the sounds and do something like this:
Code:
adb push ringtone.mp3 /system/media/audio/ringtones/
or
Code:
adb push notification.mp3 /system/media/audio/notifications/
If you do not have NAND unlocked, but you have root and a custom recovery, go into the custom recovery, then apply this command.
Code:
adb shell mount /dev/block/mtblock4 /system
After that, the commands above should work normally.
Is it possible to copy the 8GB SD files to your computer, insert a 16GB into the phone, and them paste the files from the computer to the new SD card? Will I have to re-root?
I'm currently running Damage Control (full root) along with other root tweaks.
@Jykinturah- Won't he need to mount the file system first?
dang, I was hoping to do it without rooting. I was seriously contemplating rooting my phone before 2.2 was announced to be coming out "soon" but I am a little hesitant to take the plunge knowing that we should all have froyo soon. I may still consider this or may try and do some more research. Thanks for the help though! It is greatly appreciated.
GumboChief said:
@Jykinturah- Won't he need to mount the file system first?
Click to expand...
Click to collapse
If you are booted into the OS, no. If you are in recovery, yes.
Code:
adb shell mount /dev/block/mtblock4 /system
Not usually a great idea to write to system when booted up, but if its just a ringtone or something, meh.
rockdrummersrock said:
dang, I was hoping to do it without rooting. I was seriously contemplating rooting my phone before 2.2 was announced to be coming out "soon" but I am a little hesitant to take the plunge knowing that we should all have froyo soon. I may still consider this or may try and do some more research. Thanks for the help though! It is greatly appreciated.
Click to expand...
Click to collapse
I am not the best person to ask about whether you MUST be rooted to do this, but I think you need to.
Not sure if you can write to /system in recovery without being rooted.

JP3 Lag Fix- ext3 partition via script = 1610 quadrant

This is early, hacky, and built from the work of the guys on the Vibrant forums: http://forum.xda-developers.com/showthread.php?t=739647
anomalous3 figured out that "there was only one thing running as root that could safely be replaced; the boot logo player. So, all this does is replace the boot logo player with a script that calls userinit.sh from /data/local and then calls the (now renamed) bootlogo player for those of you who want that nifty startup screen"
What this does is allows the phone to mount an ext3 partition on boot so we can have a lag fix on JP3. I'm getting 1610 on quadrant and it's pretty stable. Please someone improve this!! shaunm89 and I just hacked this together from other's work.
Directions:
1.) Create an EXT3 partition on your external SD card of 2gb. It should be the second partition after the fat32 partition
2.) Flash Modaco's pre-rooted JP3 through Odin: http://android.modaco.com/content/s...insecure-boot-clockworkmod-recovery-for-odin/
3.) Boot the phone up. Open market and install Root Explorer (costs $) and Busybox. Update busybox
4.) Download these files: http://www.megaupload.com/?d=ONGUDAIJ
Copy them across to the SD card. Move playlogos1 and playlogosnow to /system/bin. Move userinit.sh to /data/local. Use root explorer to set permissions read (all 3) write (user only) execute (all 3). 0755 for those who know linux. You can use adb to push if you wanna get fancy.
5.) Reboot. Use root explorer to see if /sd-ext exists, and if so, whether /sd-ext/data and /sd-ext/dalvik-cache exist. If so it worked! If not, reboot again and then check.
That's it. Maybe someone can package this into an update.zip, maybe someone can take it and make it more stable and even faster (ext4 for example)
great! hope we could find an easier way
Sent from my GT-I9000
Is it a must to get the pre-rooted version of firmware? However using the original SP3 then root by myself?
On the other hand, I think I will modify your init.rc as I would rather to do all the moving by myself
Great job, hope we can get EXT4 soon.
In step 4, " Move userinit.sh to /local/data" should be data/local. Quadrant benchmark 1700.
seems like the script is calling busybox, but is it necessary to use root explorer. Could one substitute root explorer with adb?
I assume root explorer is just to do things adb can do, but locally on the device instead of attached via USB.
I tried this and it and i can see sd-ext and the subfolders but is this all we need to do?
is /data/data linked to the sdcard?
I am asking because i tried to reboot the phone without the sdcard in it and i can still see all my apps and everything is working fine.
Thoughts?
Also there is an error in section 4 of your instructions. there is no /local/data, it is /data/local.
Also playlogos1 and playlogosnow files needs to be renamed with a capital P for this to work.
No need to install root explorer if you can use adb to push the files. I just wasn't sure how to use adb to push to those directories.
I fixed the other mistake, thanks
This is not ideal but gets the job done. I'm hoping you guys can make it better!
Are you able to download anything from the market after doing this?
My market is just stuck on "starting download" and that's it.
clubtech said:
Are you able to download anything from the market after doing this?
My market is just stuck on "starting download" and that's it.
Click to expand...
Click to collapse
Protected apps don't show but i've been able to get all my other purchased and free apps installed and running fine.
Strange.
I'll flash again and try again.
Yea i don't know.
The market will download some and won't others.
Also my Quadrant test is getting stuck at 3/4 stage of the I/O test so it might be my SDCard which sucks.
I used a 16GB SanDik class 4 card.
clubtech said:
Yea i don't know.
The market will download some and won't others.
Also my Quadrant test is getting stuck at 3/4 stage of the I/O test so it might be my SDCard which sucks.
I used a 16GB SanDik class 4 card.
Click to expand...
Click to collapse
sandisk are one of the best cards you can get, kingston are known to get stuck at this stage, are you sure you don't have a fake sandisk card?
anyway if you leave it running after about 10 minutes quadrant will finish and still give you a massive score of over 1500.. just shows how reliable the quadrant scores are .
does it mean that quadrant is good but speed isnt?
Tried this fix on my JP3 but no luck. I don't get these folders.
Maybe it must be MoDaCo?
If I manually execute the script I get these folders, but after reboot they are gone.
Pretty new to this maybe I'm doing something wrong?
drygmasken said:
Tried this fix on my JP3 but no luck. I don't get these folders.
Maybe it must be MoDaCo?
If I manually execute the script I get these folders, but after reboot they are gone.
Pretty new to this maybe I'm doing something wrong?
Click to expand...
Click to collapse
Ok, did it from scratch today. Format, flashed MoDaCo prerooted JP3 and everything. Stilll I don't get this to work (
Please, any ideas?
Finally got it to run faster with this fix, thanks for sharing!
drygmasken said:
Ok, did it from scratch today. Format, flashed MoDaCo prerooted JP3 and everything. Stilll I don't get this to work (
Please, any ideas?
Click to expand...
Click to collapse
Also happened to me initially. /sd-ext won't show up or if it does, it doesn't contain the correct folders though it is listed when you run 'mount'. Laggy with Quadrant result at 975.
So, went back and reformatted SD w/Fat32 then EXT3, cleared cache/data, re-flashed Modaco's JP3, installed the latest Busybox, copied files per OP and I finally got it working after a couple of re-boots (3, i think). It is running smooth so far w/quadrant 1622. GPS seems to be getting locks on SATs quickly but you still can't get to LBSTest via the keypad. Still can't write to the external sd when mounted/shared to PC.
Also tried JAC's work (see this thread: [KERNEL/RECOVERY] Vibrant EXT2/3/4 with init.d support) since it has the nifty feature allowing user to put startup scripts on boot up. I flashed his kernel but i got stuck on the 'Vibrant' boot screen. anyways, will give it another try later.
titovic said:
Also happened to me initially. /sd-ext won't show up or if it does, it doesn't contain the correct folders though it is listed when you run 'mount'. Laggy with Quadrant result at 975.
So, went back and reformatted SD w/Fat32 then EXT3, cleared cache/data, re-flashed Modaco's JP3, installed the latest Busybox, copied files per OP and I finally got it working after a couple of re-boots (3, i think). It is running smooth so far w/quadrant 1622. GPS seems to be getting locks on SATs quickly but you still can't get to LBSTest via the keypad. Still can't write to the external sd when mounted/shared to PC.
Also tried JAC's work (see this thread: [KERNEL/RECOVERY] Vibrant EXT2/3/4 with init.d support) since it has the nifty feature allowing user to put startup scripts on boot up. I flashed his kernel but i got stuck on the 'Vibrant' boot screen. anyways, will give it another try later.
Click to expand...
Click to collapse
Which method do you use for making the ext3? I made my on my hero using Amon RA could that be a problem?
drygmasken said:
Which method do you use for making the ext3? I made my on my hero using Amon RA could that be a problem?
Click to expand...
Click to collapse
I used GParted Live CD as Paragon fails to format my AData card and sorry but I am not familiar with AMON RA.
1646 thanks, very fast!
Sent from my GT-I9000 using XDA App
Would this procedure work for ext4 partitioned SD Card?

[Solved][Q] Recovering dead/dying SD card, fixing A2SD permissions

Hi,
I was organising my computer today (ironically in preparation for a backup) and plugged in my phone to copy files and it wouldn't mount or ask for the type of connection. I went to unmount it in Android and it said the size was '00'. I put the card in a card reader and did a check and it seems a few sectors have gone bad (which implies the reserve pool has filled too). That would explain the way it has been pausing for long periods of time when copying files (haven't done that in a month or so).
I've managed to copy all but one of the .apk files in /sd-ext/app and /sd-ext/app-data. If I put these (plus an empty dalvik-cache) on a new partition on a new card will A2SD+ be happy (apart from the one broken app of course)? Does each .apk have special permissions per app or anything? I should probably do a full wipe but I'm trying to hold out for official gingerbread. I tried to do a nandroid backup but clockworkmod says 'cannot stat /sdcard'
I haven't managed to get much of the FAT32 partition as it keeps dying after a few I/O errors and requires me to re-plug it (every sector comes up with I/O errors even when they are fine). I managed to get some files that I have nowhere else using ddrescue on individual files (a full image doesn't work because of the endless errors after a while). I think I may have made things worse as I stupidly didn't mount the drive in read-only mode. Now android mounts the SD card in read-only mode too, where it wasn't doing that earlier today. I did notice a few I/O errors in the android system log when I was trying to figure out the problem.
I'm misisng some (fairly unimportant) photos because the DCIM/100MEDIA folder seems to have lost it's directory listing. Does anyone have any suggestions for tools to recover these? I tried photorec but it only seems to find the thumbnails. I can't get the partition to mount on Windows but it more or less works on linux. According to HD Tune disk scan (chkdsk just freezes), the number of bad blocks is actually fairly small.
I did a whole pile of app updates yesterday which must have pushed it over the edge (many of which failed due to 'insufficient space' on the A2SD partition). The phone still mostly works (since most apk files are readable and the settings are stored on the phone).
Does dalvik-cache get updated much? I'm worried it might hugely shorten the life of a new card.
Thanks
Running Leedroid 2.4 A2SD+
Ok, I've got a new 16GB MicroSD card.
I can't get Android to recognize the apps in the A2SD partition, it regenerates the dalvik cache though. I've tried setting the .apk files to be globally readable and writeable.
Any ideas?
Yay, got it working
It turns out you need to run fix_permissions.sh, as Android does care about apk files and data files having the same permissions. fix_permissions did some strange changes to data permissions but it all seems to work bar needing to re-add most of my widgets to GoLauncher. Leedroid doesn't include fix_permissions but after much hunting (most links I found were broken), I managed to find it on cyanogenmod github.
https://github.com/CyanogenMod/android_vendor_cyanogen/raw/gingerbread/prebuilt/common/bin/fix_permissions
Just copy it to the SD card and run from ADB shell (or a terminal):
Code:
su
chmod +x /mnt/sdcard/fix_permissions
sh /mnt/sdcard/fix_permissions
Note that you must use sh, just ./fix_permissions gives permission denied for some reason.
Edit: seems it didn't correctly fix apps in app-private (of which I only had 2). I just reinstalled them (probably possible to fix them manually by looking at the owner in /data/data and chown the apk).

[HELP] cannot read or write to internal storage (/sdcard)

The title pretty much explains it. I cannot see any of my personal internal files or create an, e.g when it try take a screenshot it won't work as it does not have access to the internal folders.
Even when I boot into TWRP I cannot see all my files. I know all my files are there still as my storage still only has 10gb free even though the file Explorer shows no files visible.
It seems like no app at all has access.
What can I do to get access to my files again, I have some really important stuff I have got in the last few days that I have not backed up yet. As long as I can get some sort of backup of the files I will be happy to reset the phone.
Ok so what I have done since it working fine was.
Copy 2 files from my computer to my phone
Reboot into TWRP and then force shut the phone down after about 1 minute as I was not patient enough (turns out with f2fs you need to wait a bit longer)
After that, booting into the systems had no read or write access in the sdcard folder which is where all the personal data is stored.
Hopefully what I have said has made sense, if you need any other information just ask
P.S I tired to connect a flash drive so I could flash 4.1.1 (as I cannot copy anything to the internal storage) and see if that would fix it but TWRP won't recognize any flash drives and I'm on the latest official version of TWRP
DarkN3ss61 said:
The title pretty much explains it. I cannot see any of my personal internal files or create an, e.g when it try take a screenshot it won't work as it does not have access to the internal folders.
Even when I boot into TWRP I cannot see all my files. I know all my files are there still as my storage still only has 10gb free even though the file Explorer shows no files visible.
It seems like no app at all has access.
What can I do to get access to my files again, I have some really important stuff I have got in the last few days that I have not backed up yet. As long as I can get some sort of backup of the files I will be happy to reset the phone.
Ok so what I have done since it working fine was.
Copy 2 files from my computer to my phone
Reboot into TWRP and then force shut the phone down after about 1 minute as I was not patient enough (turns out with f2fs you need to wait a bit longer)
After that, booting into the systems had no read or write access in the sdcard folder which is where all the personal data is stored.
Hopefully what I have said has made sense, if you need any other information just ask
Click to expand...
Click to collapse
If your phone is visible in adb try this command
adb pull /sdcard
This should transfer all the contents from internal storage to your computer into the same folder where your adb tools program is saved.
pvramk said:
If your phone is visible in adb try this command
adb pull /sdcard
This should transfer all the contents from internal storage to your computer into the same folder where your adb tools program is saved.
Click to expand...
Click to collapse
Thanks for the suggestion, I'm not home for another 10 hours so I will try that when I get home. So if anyone has any other suggestions let me know
pvramk said:
If your phone is visible in adb try this command
adb pull /sdcard
This should transfer all the contents from internal storage to your computer into the same folder where your adb tools program is saved.
Click to expand...
Click to collapse
This doesnt work.
B:\Backups\OnePlus 3\>adb pull -p /sdcard
remote object '/sdcard' not a file or directory
Any other ideas?
DarkN3ss61 said:
This doesnt work.
B:\Backups\OnePlus 3\>adb pull -p /sdcard
remote object '/sdcard' not a file or directory
Any other ideas?
Click to expand...
Click to collapse
I'm not sure about the -p
Did you try without this flag?
you can try adb pull /sdcard/ .
is the phone visible in adb devices ?
pvramk said:
I'm not sure about the -p
Did you try without this flag?
you can try adb pull /sdcard/ .
is the phone visible in adb devices ?
Click to expand...
Click to collapse
I tried with and without the flag, also yes the phone is visible in ADB.
I have given up and wiped phone completely, flashed latest version of TWRP, then 4.1.1 and magisk 12. No problems so far, apart from not having my files that were not backed up.
So you can consider this problem abandoned

Categories

Resources