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?

  • 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 '16 at 14:33
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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.