1. Download our Official Android App: Forums for Android!

Root "adb remount" fails; work-around successful

Discussion in 'Android Devices' started by hstroph, Dec 2, 2013.

  1. hstroph

    hstroph Android Enthusiast
    Thread Starter
    98

    Oct 18, 2012
    628
    98
    98
    My goal is to replace /system/etc/hosts file with one that includes my own network hosts, but /system is read-only, and I can't seem to change the permissions on it using adb. All operations are performed as the root (Linux) user.

    Here's how one accomplishes the task, assuming "busybox" and "super-su" are installed on the Nexus 4. On the Linux:

    # ps auxw | grep adb
    root 6518 0.0 0.0 29980 1376 pts/0 Sl 18:53 0:01 adb -P 5037 fork-server server

    # adb devices
    * daemon not running. starting it now on port 5037 *
    * daemon started successfully *
    List of devices attached
    004323648951e5d9 device

    # adb push hosts /system/etc/hosts
    failed to copy 'hosts' to '/system/etc/hosts': Read-only file system

    # adb help 2>&1 | grep remount
    adb remount - remounts the /system partition on the device read-write

    # adb remount
    remount failed: Permission denied

    So I remount the /system partition in rw mode from an adb shell and test it:

    # adb shell
    shell@mako:/ $ su
    root@mako:/ # mount -o remount,rw /system
    root@mako:/ # cp /system/etc/hosts /system/etc/hosts.ORG
    root@mako:/ # exit
    shell@mako:/ $ exit

    Then the file pushes successfully:

    # adb push hosts /system/etc/hosts
    4017 KB/s (1092858 bytes in 0.265s)

    ... and /system is restored to original ro mode:

    # adb shell
    shell@mako:/ $ su
    root@mako:/ # mount -o remount,ro /system
    root@mako:/ # exit
    shell@mako:/ $ exit

    Mission accomplished, in case anyone else needs to know.
     

    Advertisement

  2. Rukbat

    Rukbat Android Expert
    843

    Jan 16, 2012
    10,392
    2,893
    843
    Male
    Being retired and writing Tasker tasks.
    Fayetteville, NC, USA
    mount -o remount,rw /system

    is the normal way of remounting /system as rw. Sometimes some time-saving tools (like adb) make things more complicated than they are.
     
  3. codesplice

    codesplice Elite Recognized Moderator
    Moderator
    1,063

    Oct 29, 2013
    8,088
    9,028
    1,063
    Male
    SysAdmin
    Huntsville, AL
    You can also use the adb root command to restart the adb daemon with root privileges; you should then be able to successfully adb remount.
     
Tags:

Share This Page

Loading...