Magic Root Access

From Android Wiki

Revision as of 01:48, 2 August 2009 by Tonyb486 (Talk | contribs)
Jump to: navigation, searcha

Accessing Root from the Magic/Sapphire Terminal Emulator

Now that you have followed Magic Rooting to root your HTC Magic/Sapphire, you will notice that it is not possible to gain a root from an application running on the phone. The only way to get root access is through the ADB shell. In order to be able to gain root access using su with a Terminal Emulator application the su utility in /system/xbin/su needs to be replaced. In Android 1.5, the su utility was updated to allow only the shell and root users to gain root access[1]. Since the adb shell runs as the shell user, the su utility will give root access through the adb shell. These instructions will also work for G1/ADP1 users who have upgraded to Android 1.5 and rooted their phone.

*** NOTE: Installing the modified su utility opens up a security risk to your phone, since any App can gain root access. You have been warned... ***

  • First, download the modified su utility (ZIP), and unzip it somewhere on your computer. The instructions below assume C:\Android.
  • Make sure you have ADB installed on your PC, and that USB Debugging is enabled on your phone. For details, see this post.
  • Next, open a DOS Command Prompt window, and push a modified su utility to your phone. This utility will then be copied into the proper location to replace the existing su utility.
C:\Android>adb push su /data/local
595 KB/s (76200 bytes in 0.125s)
  • Next, use adb to get a shell prompt on your phone:
C:\Android>adb shell
  • Gain root access using the existing su utility:
$ su
  • Then, remount the /system partition as read/write so you can replace the existing su:
# mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
  • The su utility is located in /system/xbin. The following commands will back up your existing su utility as osu, and install the modified su utility, and change the permissions appropriately.
# cd /system/xbin
# mv su osu
# cat /data/local/su > su
# chmod 6755 su
  • Now, check your work, and make sure the permissions on the new su match those of the original osu.
# ls -l *su
-rwsr-sr-x root     root        76200 2008-08-01 05:00 osu
-rwsr-sr-x root     root        76200 2009-05-30 11:28 su
  • Finally, if everything checks out, sync the filesystem, and reboot your phone:
# sync
# reboot
Personal tools