4

In the past, I've used a modified hosts file on my system that I place at /system/etc/hosts. The process is pretty straightforward

  • Boot into recovery using a custom recovery.
  • Mount /system read-write
  • Use adb push to copy a hosts file to /system/etc/hosts
  • Reboot and the hosts file takes effect.

Note that the above process doesn't require rooting. It does, of course, modify the system partition.

However, after upgrading to Nougat, I'm seeing some weird behavior where once I reboot, the hosts file is just the standard one with only localhost in it. This never used to happen on Marshmallow or below.

I thought at first that the system was overwriting my hosts file on each boot, but the strangest part is that if I go back to recovery, the file I copied is still there at /system/etc/hosts. My guess is that the system is doing a mount at boot time that's hiding my file.

Does anyone have any experience with this or have a way to fix it?

1
  • As far as i know, the nougat partition table has duplicate partitions. Which means, you might have copied to the first one, but system might boot from the second one. androidheadlines.com/2016/09/…
    – Mike N.
    Sep 23, 2016 at 14:33

1 Answer 1

0

I got this problem, too.

After my searching and try for hours, finnally it worked.

Just use adb push to copy a hosts file to both /system/etc/hosts and /etc/hosts

I think /etc/hosts probobaly overrides /system/etc/hosts when the phone rebooting.

1
  • /etc is in ramdisk (tmpfs) which is cleared on reboot. On main Android OS it just point to /system/etc, not a separate directory. Oct 3, 2019 at 7:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .