Bebop_
Bebop_

Reputation: 657

Attempting to gain r/w access to android /system

Working on a root script for the Nexus 4 with the latest stock rom .img for google (occam) and I have the following code snippet:

./adb wait-for-device
echo "remounting system"
./adb shell "mount -o remount,rw /system"
./adb push su /system/bin/
echo "pushing super user"
./adb push Superuser.apk /system/app/
echo "pushing busybox"
./adb push busybox /system/xbin/
./adb shell "chmod 06755 /system/bin/su"
./adb shell "chmod 0644 /system/app/Superuser.apk"
./adb shell "chmod 04755 /system/xbin/busybox"
./adb shell "cd /system/xbin"
./adb shell "busybox --install /system/xbin/"

I keep getting the error

mount: Operation not permitted
failed to copy 'su' to '/system/bin//su': Read-only file system
pushing super user
failed to copy 'Superuser.apk' to '/system/app//Superuser.apk': Read-only file system
pushing busybox
failed to copy 'busybox' to '/system/xbin//busybox': Read-only file system
Unable to chmod /system/bin/su: No such file or directory
Unable to chmod /system/app/Superuser.apk: No such file or directory
Unable to chmod /system/xbin/busybox: No such file or directory
/system/bin/sh: busybox: not found

I've tried using multiple methods of obtaining r/w access, but nothing seems to be working. I have to automate this process due to the fact that other people will use the script so it needs to be automation friendly, but I just can't figure this out.

I've also tried the

#su
#mount
#mount | grep system

followed by inputting the partition with the system mount and changing it to r/w access, but that also hasn't worked.

Really frustrated at this point. Can anyone help?

Upvotes: 3

Views: 33469

Answers (2)

esc0rtd3w
esc0rtd3w

Reputation: 11

Try the commands below

adb shell "su -c mount -o remount,rw /system"
adb shell "su -c chmod 06755 /system/bin/su"

and so on.

Upvotes: 1

Cybercartel
Cybercartel

Reputation: 12592

It gives the error because you aren't root. The system partition is mounted read-only. You can try to push the binary to /data/local/tmp. Then you can make su executable and eventual run it. But it doesn't mean you can have root. To become root you need to push an exploit like psneuter to /data/local/tmp and run it. It crashes the shell and reopen a new one with root rights. Then you can remount the system-partition read-write and install su.

Upvotes: 5

Related Questions