71

so, i'm trying to push some files to /system on android device (zte) I've rooted, connected with ADB,

adb remount -> I get permission denied adb shell su -> I'm able to access shell and create folders etc and edit filesystem

(but in shell I can't copy a file from my computer to device)

Any help please

IanO.S.
  • 1,362
  • 1
  • 10
  • 20
  • 10
    Have you tried `adb root`, then `adb remount` ? – Michael Oct 26 '12 at 15:20
  • 9
    running adb root getting -> adbd can't run as root in production builds – IanO.S. Oct 26 '12 at 15:33
  • 2
    it's your boot.img - the default.prop or kernel must not be set up for adb remount permissions. Are you trying to push to /system somewhere? Then just run `adb shell mount -o rw,remount /system` to mount system as r/w – Drake Clarris Oct 26 '12 at 15:50
  • 2
    adb shell mount -o rw,remount /system , is giving me a 'not permitted' error, when I goto into adb shell and do SU , I can run "shell mount -o rw,remount /system" but afterwords trying to adb push to system I still get permission denied @DrakeClarris – IanO.S. Oct 26 '12 at 16:48
  • 1
    then your boot.img or kernel needs to be changed to allow it. Are you stock and rooted? If so, try a custom rom. If you're on a custom rom, try another. Or look up how to mod a boot.img to change the ro.secure parameter - here's a guide I found on a quick google search: http://roguedroid.blogspot.com/2012/01/modding-bootimg.html (edit: don't use the dd command in the opening paragraph - you'll need to find what partition your device uses for that command) – Drake Clarris Oct 29 '12 at 13:03
  • I was on a zte u930 in china (pretty customized os) and it got stuck in boot loop and I got a replacement :-) @drakeclarris , maybe I'll just get a nexus next time – IanO.S. Oct 29 '12 at 20:08
  • related: https://android.stackexchange.com/questions/110927/how-to-mount-system-rewritable-or-read-only-rw-ro – Ciro Santilli OurBigBook.com Jan 30 '19 at 16:25

9 Answers9

97

In case anyone has the same problem in the future:

$ adb shell
$ su
# mount -o rw,remount /system

Both adb remount and adb root don't work on a production build without altering ro.secure, but you can still remount /system by opening a shell, asking for root permissions and typing the mount command.

MartinodF
  • 8,157
  • 2
  • 32
  • 28
  • @Michael at which step are you getting the error? Is your phone rooted? What root app are you using (SuperSU, Superuser, ...)? – MartinodF Mar 26 '13 at 14:49
  • Step two, when I try to run "su" from the adb shell. Phone is rooted. I am using the Superuser app. Is there something I need to do to tell Superuser to allow adb root access? – Michael Mar 26 '13 at 14:51
  • 4
    Not that I know of! When you run "su" you should get a Superuser popup on the phone asking if you want to authorize it. Are you sure that Superuser is working fine and that it's not configured to block adb root? – MartinodF Mar 26 '13 at 14:59
  • Thanks, that was it! It *was* popping up a dialog, but I didn't see it before (screen brightness auto-dimmed so I didn't notice anything there). Apparently after a bit it would time out and fail. – Michael Mar 26 '13 at 15:59
  • 14
    I'm not able to run `su` on my Android device, I get: `/system/bin/sh: su: not found`. I guess it's cause my device is not rooted. – Matt Huggins May 05 '13 at 15:46
  • @Jayesh No, you need to be rooted to run `su`. That's pretty much the point of rooting ;) – MartinodF Sep 23 '13 at 23:50
  • ok, I have rooted device but I have some issue, My device is not being switched on and in offline mode id display in Eclipse device list (by connecting with usb cable in PC), but I cant push one font file(DroidSans.ttf) please read this http://android.stackexchange.com/questions/53699/how-to-change-system-fonts-directory-permission-to-writable-in-switch-off-mode/53704?noredirect=1#53704 – Jayesh Sep 24 '13 at 06:51
  • 61
    I get `mount: '/system' not in /proc/mounts` on an emulator. – noname May 12 '19 at 17:23
  • @BeanstheWizard they changed in API 29 I believe, it helped me to create a different emulator with older API (I used 25, android 7.0.0), that might help you. – Kemal Tezer Dilsiz Oct 04 '19 at 20:42
  • 3
    @Kemal Tezer Dilsiz In API 28, I also got this – tigertang Nov 05 '19 at 13:49
  • 2
    @tigertang I was able to do API 28 by launching emulator through cmd with --writable-system tag and then just using adb shell to go in and edit manually. I don't know if that'd work for your case. Good luck. I'm my case I only had to edit the hosts file – Kemal Tezer Dilsiz Nov 05 '19 at 23:46
  • 1
    @Kemal Tezer Dilsiz, that only works for your emulator, rather than the real device. – tigertang Nov 20 '19 at 14:07
  • 1
    @KemalTezerDilsiz When I try to start my API 28 emulator using `--writable-system`, I get `PANIC: Missing emulator engine program for 'x86' CPU.` And I'm not even at the disco. – Ash Dec 16 '19 at 07:48
  • I also get `mount: '/system' not in /proc/mounts` with `API 30`, but it still works somehow when I connect to my database. – Mario Codes Mar 19 '21 at 20:01
  • Use the emulator from /android-sdk/emulator/ instead of the one in /android-sdk/tools/emulator – JiTHiN Oct 24 '21 at 10:13
26

emulator -writable-system

For people using an Emulator: Another possibility is that you need to start the emulator with -writable-system. That was the only thing that worked for me when using the standard emulator packaged with android studio with a 4.1 image. Check here: https://stackoverflow.com/a/41332316/4962858

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
francis duvivier
  • 2,056
  • 11
  • 17
  • 1
    Yes, this removes the `read-only` option from QEMU's `-drive` option: https://android.stackexchange.com/questions/110927/how-to-mount-system-rewritable-or-read-only-rw-ro/207200#207200 But note that it also points to a qcow2 overlay instead of the image itself, so you must then pass this option of future runs. – Ciro Santilli OurBigBook.com Jan 31 '19 at 15:14
19

Try

adb root
adb remount

to start the adb demon as root and ensure partitions are mounted in read-write mode (the essential part is adb root). After pushing, revoke root permissions again using:

adb unroot
Suuuehgi
  • 4,547
  • 3
  • 27
  • 32
user2670032
  • 305
  • 5
  • 5
15

Some newer builds require the following additional adb commands to be run first

adb root
adb disable-verity
adb reboot

Then

adb root
adb remount
Quanlong
  • 24,028
  • 16
  • 69
  • 79
9

you can use:

adb shell su -c "your command here"

only rooted devices with su works.

  • 1
    Thanks man, it worked on android 11, IDK why they forgot to place the remount file under bin dir. :) – HackRx Sep 20 '21 at 22:56
6

Start /w Writable System

Using Emulator Images without Google Play

This does not work with production Android images, i.e. ones with Google Play

Use non-Google Play images for root access & writeable system

Start your emulator from a command prompt as a writable system, using its AVD Name (Pixel3a in this example, see AVD Name below to find or change yours. Make sure another emulator instance is not running when using this command):

emulator @Pixel3a -writable-system

(Keep this command handy. You will need to use it any time you want to access your emulator as 'writable'. I use an alias in gitbash to start my emulator from a gitbash terminal, everytime.)

This launches the emulator.

When startup is complete, open another command prompt/terminal (this one is stuck running the emulator) and:

adb root

Result should be:

$ adb root
restarting adbd as root

Then:

adb remount

Result:

$ adb remount
remount succeeded

When you:

adb shell

and:

su

You should now have full root/writable access:

$ adb shell
generic_x86_arm:/ # su
generic_x86_arm:/ # 

To add a domain to hosts file

$ cd /etc
$ cp hosts hosts.bak1
$ cat hosts
127.0.0.1       localhost
::1             ip6-localhost

$ echo '10.0.2.2 my.newdomain.com' >> hosts
$ cat hosts
127.0.0.1       localhost
::1             ip6-localhost
10.0.2.2        my.newdomain.com

10.0.2.2 is "localhost" for an Android emulator. It will delegate to your Windows/Mac hosts file & DNS services. Any domain you add to your development machine's hosts file, will work as 10.0.2.2 on your Android Emulator hosts file.

AVD Name

In Android Studio AVD Manager can be launched from menu:

Tools > AVD Manager

AVD List

If your emulator name has spaces, you can change that by clicking the pencil icon on right hand side.

I named my emulator 'Pixel3a' without spaces for ease of typing. AVD Details

Baker
  • 24,730
  • 11
  • 100
  • 106
  • 1
    These are the only instructions I've found that work. Set up a new emulated Pixel 4a device w/ Android 12.0, and I was able to update the hosts to access a local development server running on Vagrant. Thank you! (If anyone's curious, because of how Vagrant works I used the *same* IP I have in my host machine's `/etc/hosts` file: 192.168.56.5. – Andron Mar 29 '22 at 20:13
0

I rebooted to recovery then

adb root; adb adb remount system; 

worked for me my recovery is twrp v3.5

Saeb Molaee
  • 109
  • 15
-1

Try with an API lvl 28 emulator (Android 9). I was trying with api lvl 29 and kept getting errors.

SudoPlz
  • 20,996
  • 12
  • 82
  • 123
-5
@echo off
color 0B
echo =============================================================================
echo.
echo              ClockworkMod Recovery for SAMSUNG GALAXY SIII E210L
echo.
echo                  ClockworkMod Recovery (v6.0.1.2 Touch)
echo.
echo     ¡ô¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¡ô
echo     ¨U                                                                  ¨U
echo     ¨U SAMSUNG GALAXY SIII E210L                                        ¨U
echo     ¡ô¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¨T¡ô
echo.
echo  1) (Settings\Developer options©¥ USB debugging)
echo.
echo  2) CWM SAMSUNG GALAXY SIII E210L 
echo.
echo  3) THANK!!!!!!
echo.
echo =============================================================================
echo                           ARE YOU READY? GO! ¡·¡·¡·
@pause
echo.
echo adb...
adb.exe kill-server
adb.exe wait-for-device
echo wiat¸!
echo.
echo conect...
adb.exe push IMG /data/local/tmp/
adb.exe shell su -c "dd if=/data/local/tmp/GANGSTAR-VEGAS-1.3.0-APK-Andropalace.net.apk of=/mnt/sdcard/Android/GANGSTAR-VEGAS-1.3.0-APK-Andropalace.net.apk
adb.exe shell su -c "rm /data/local/tmp/bootloader.img"
adb.exe shell su -c "rm /data/local/tmp/recovery.img"


echo ===============================================================
echo     ClockworkMod Recovery!
echo.
@pause
bansi
  • 55,591
  • 6
  • 41
  • 52