1. Are you ready for the Galaxy S20? Here is everything we know so far!

modify /system/etc/hosts ? [solved]

Discussion in 'Android Devices' started by hstroph, Jul 3, 2013.

  1. hstroph

    hstroph Android Enthusiast
    Thread Starter

    From a Linux laptop using the most recent Android SDK, I am trying to push a modified /system/etc/hosts file to the rooted, "SuperSU"-enabled N4, but am meeting with permission problems:

    $ ps auxw | grep adb
    root 10924 0.1 0.0 29188 1428 pts/0 Sl 11:29 0:00 adb fork-server server
    $ adb -d push hosts.mod /system/etc/hosts
    failed to copy 'hosts.mod' to '/system/etc/hosts': Read-only file system
    $ adb -d shell
    shell@android:/ $ ls -l -d / /system /system/etc /system/etc/hosts
    drwxr-xr-x root root 2013-07-02 23:20
    drwxr-xr-x root root 2013-05-21 12:48 system
    drwxr-xr-x root root 2013-02-15 12:13 etc
    -rw-r--r-- root root 1025804 2013-01-21 22:34 hosts

    The intent is to temporarily grant "others" write permission to the hosts file, but that also meets with the problem, even for root:

    shell@android:/ $ su -
    root@android:/ # chmod 0326 /system/etc/hosts
    Unable to chmod /system/etc/hosts: Read-only file system

    How can I modify the /system/etc/hosts file please? The new hosts file is too large to use an in-phone app to manually edit the existing file; I need to "adb push" it.

    What's missing please?

    As usual, the messages are telling us exactly what's happening. The filesystem needs to be remount rw to push the file:

    root@android:/ # mount | grep system
    /dev/block/platform/msm_sdcc.1/by-name/system /system ext4 ro,relatime,data=ordered 0 0
    root@android:/ # mount -o rw,remount /dev/block/platform/msm_sdcc.1/by-name/system /system
    root@android:/ # chmod 0326 /system/etc/hosts
    root@android:/ #

    $ adb -d push hosts.mod /system/etc/hosts
    562 KB/s (1026030 bytes in 1.779s)

    Restore Android:
    root@android:/ # chmod 0644 /system/etc/hosts
    root@android:/ # ls -l /system/etc/hosts
    -rw-r--r-- root root 1026030 2013-07-03 12:27 hosts
    root@android:/ # mount -o ro,remount /dev/block/platform/msm_sdcc.1/by-name/system /system
    root@android:/ #


    1. Download the Forums for Android™ app!



Nexus 4 Forum

The Nexus 4 release date was November 2012. Features and Specs include a 4.7" inch screen, 8MP camera, 2GB RAM, Snapdragon S4 Pro processor, and 2100mAh battery.

November 2012
Release Date

Share This Page