[G2 and Desire Z Android Development] ianmcquinn:
After seeing lots of users struggle to root their phone with the existing guides (or worse, brick their phones), often times because of an inability to install/use ADB correctly (so they hobble together steps from multiple guides), I decided to write up a guide for rooting without the need for ADB. This guide uses the Visionary program to achieve temporary root and then gfree to achieve permanent root. Visionary is used only for the temporary root and nothing else (since many on these forums are wary of the app for permanent rooting). All of the gfree steps were scripted together to make things more convenient (and allow less room for user error in typing things in). This has been tested to work with multiple G2s and theoretically should work with the Desire Z as well (if you have the 1.72 OTA though, you will need to downgrade first in order to root as per the instructions in the wiki). All credit goes to the original developers of these programs and those others who aided in achieving root originally (I didn't add anything new content-wise, just bundled it up nicely).

WARNING: A few Desire Z users have reported being stuck on the HTC logo after following this guide. Without having a Desire Z myself, it is difficult to figure out why (since this simple automates known working methods). For the time being, I recommend Desire Z users obtain permanent root using one of the other guides out there.

Instructions

1. Install Terminal Emulator and a file manager (such as Astro File Manager) from the Market.

2. Extract the contents of the zip file to the SD card (this will create a directory called root_files on the card). When done, make sure you unmount your SD card from your computer if you had mounted it as a storage device to transfer the files.

3. Enable Unknown Sources (under Settings->Applications) and USB Debugging (under Settings->Applications->Development).

4. Using your file manager, navigate to the root_files directory on your SD card and select "com.modaco.visionaryplus.r14.apk" to install the Visionary app.

5. Start the Visionary app.

6. Click on "Temproot now." Leave all other settings unchecked.

7. Start the Terminal app.

8. Type the following commands (the $ and # symbols represent the command prompt and should not be typed):

$ su
# cp /sdcard/root_files/perm_root /data/local/perm_root
# chmod 777 /data/local/*
# /data/local/perm_root

You will see multiple messages scroll by as the programs run. Once you are returned to the prompt in terminal, you will have permanent root (S-OFF), as well as subsidy unlock and SuperCID. At this point, you can also choose to flash the engineering hboot as explained in the wiki. Flashing this hboot allows you to use the flashboot program to flash images from your computer to your phone (which can be very helpful when stuck in a bootloop for example). Note, this is often times the step that bricks people's phones when following other guides. To help mitigate the danger involved, I created a script that first checks the md5 of the hboot file to ensure it didn't get corrupted and then actually performs the flash (many times the bricking occurs because of a typo in this command). If you wish to flash the engineering hboot, type the following command in terminal if you have a G2:

# /data/local/tmp/flash_hboot

Or this command if you have a Desire Z

# /data/local/tmp/flash_hboot_z

If you get a verification failed message, you should re-download the files, re-extract them to your SD card, and run the flash_hboot script again.

If you don't want the engineering hboot, just reboot your phone. You can verify you have permanent root by holding volume down while powering on (you'll see S-OFF in the first line of the bootloader). You are now free to install a new recovery and start flashing custom ROMs. If you don't want to flash a new ROM, it's safe to uninstall the Visionary app at this point.

And if you are curious, you can open the perm_root and flash_hboot files in a text editor to see what they are actually doing...