How can I remount my Android/system as read-write in a bash script using adb?

Andrew picture Andrew · Jan 18, 2015 · Viewed 121.2k times · Source

For info

adb remount 

returns "remount failed: Operation not permitted"

adb shell 'su -c  mount -o rw,remount /system'

returns unknown option -- o

My device is rooted.

Answer

Saurabh Meshram picture Saurabh Meshram · Jan 19, 2015

Probable cause that remount fails is you are not running adb as root.

Shell Script should be as follow.

# Script to mount Android Device as read/write.
# List the Devices.
adb devices;

# Run adb as root (Needs root access).
adb root;

# Since you're running as root su is not required
adb shell mount -o rw,remount /;

If this fails, you could try the below:

# List the Devices.
adb devices;

# Run adb as root
adb root;

adb remount;
adb shell su -c "mount -o rw,remount /";

To find which user you are:

$ adb shell whoami