2

I'm trying to setup hosts file for android emulator. I saw this advice:

 adb remount 
 adb push hosts /etc/system/hosts (most tutorials suggest
 this file) 
 adb push hosts /system/etc/hosts (some VM systems seem to
 prefer this file instead!, for me this worked)

But when I do adb remount it writes "remount of the / superblock failed: Permission denied". I'm going to adb shell, but it also writes an error.

generic_x86:/ # mount -o remount,rw /system
mount: '/system' not in /proc/mounts
1|generic_x86:/ # mount -o rw,remount,rw /system
mount: '/system' not in /proc/mounts
generic_x86:/ # mount -o remount,ro /system
mount: '/system' not in /proc/mounts
1|generic_x86:/ # whoami
root

I reinstalled Android Studio twice it didn't help. Could anyone help pls?

Ida
  • 41
  • 1
  • 3
  • [same answer is already answered so plz check the link](https://stackoverflow.com/a/61637955/5219642) – Amit May 06 '20 at 14:43

2 Answers2

2

Usage of -writable-system flag made ADB remount work. Hosts were replaced with the new file.

Launched emulator as: emulator.exe -writable-system -avd Nexus_5X_API_28_x86

dKen
  • 3,078
  • 1
  • 28
  • 37
Ida
  • 41
  • 1
  • 3
0

The hosts file is located at a directory that is not allowed to write over a file. So, you should first copy hosts to somewhere else, edit it, and then copy it back.

For example, let's work on the standard emulator:

Run the following command while the emulator is open:

adb devices

This command will show the running emulators. Run the following command to disable the emulator's read-only behaviour:

adb -s emulator-5554 remount

After this step, it should log remount succeeded. Then you should copy the emulator to another directory for editing:

adb -s emulator-5554 pull /system/etc/hosts ~/Desktop/

After this step, it will log about the file transfer's success. Now you can edit the hosts file. After the edit, you should push the file back. First of all, you should reboot the adb:

adb reboot

Emulator will restart itself. After this, you can remount the adb:

adb -s emulator-5554 remount

After the remount, you can push back hosts file:

adb -s emulator-5554 push ~/Desktop/hosts /system/etc/hosts
Faruk Yazici
  • 2,344
  • 18
  • 38
  • ...\Android\Sdk\tools>adb -s emulator-5554 remount, same error remount of the / superblock failed: Permission denied remount failed – Ida Aug 09 '18 at 08:59
  • Any ideas how to enable adb shell commands above? It writes in the internet it can overcome permission denied... – Ida Aug 10 '18 at 07:33
  • Actually this is not supposed to happen, but maybe you could require to be a super user, have you tried as a super user? – Faruk Yazici Aug 10 '18 at 07:50
  • I'm root in adb shell. – Ida Aug 10 '18 at 09:55