4

I need to change /system/etc/hosts file on my emulator, and no matter what I do, I get "read-only file system" error. Does anyone know how to do it?

I tried editing the file manually as su in adb shell, I tried pushing the file in device monitor (in Android studio), also tried adb remount to remount the file system as many online resources suggest.

Thanks! Konstantin

2
  • 1
    Have you tried (as root): mount -o remount,rw /system and then editing the hosts file? – Izzy Jul 16 '16 at 18:38
  • 1
    Maybe ADB isn't running as root ... Try adb kill-server and then adb root – Gadget Guru Jul 17 '16 at 3:33
3

I tried your answer but it didn't work.

Eventually the following Stack Overflow Answer worked.

1) android-sdk-macosx/tools/emulator -avd <avdname> -writable-system
2) ./adb root
3) ./adb remount
4) ./adb push <local>/hosts /etc/hosts

Android file host can be

/etc/hosts <--- This worked for me
/etc/system/hosts
/system/etc/hosts

Check

1) ./adb shell
2) cat /etc/hosts
3) ping customsite.com
2

I found this question Googling for the same issue. I solved with these steps:

(for italian-speaking people: see my full writeup Guida definitiva: come modificare il file hosts di Android tramite PC (senza errori adb: error: failed to copy 'hosts' to '/system/etc/hosts': couldn't create file: Read-only file system oppure Permission denied)

Mount FS as RW

adb shell
su
mount -o remount,rw /system

( credit )

Run ADB as root

adb root

credit: @Noob Food

Push again

adb push hosts /system/etc/hosts

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.