8

I'm using LineageOS 14.1 and don't want nor need to root it. How can I remount /system rw and edit /system/etc/hosts?

All answers in "How to edit 'etc/hosts' file?" expect a rooted phone.

8

Unless I missed something, that is not possible. Without root access only the mechanism of flashing an update (via recovery or OTA) can modify /system. To be accepted, such an update archive must be signed with the same key as the ROM – which is something only the developer of the ROM (here: the LOS team) can do.

There might be a way via a custom recovery which lets you edit all file systems directly (see e.g. ). But without knowing what device it is, it cannot be said if a matching recovery exists (you can check that in the Devices section of their website for official images, and search XDA for unofficial ones). Apart from that, it's either the device or not editing any file within /system.

  • Thanks. twrp looks like a very good solution. It has everything needed for small manual changes or full hosts replacements. I'm running the latest stable which ships with BusyBox: vi, cat, chmod and chown are there. – berbt May 9 '17 at 23:19
  • 1
    What is more, you don't have to install it – you can simply boot the image (fastboot boot twrp.img). Which leaves unlocking the bootloader as the only device modification (otside the one you just want to perform, of course ;) – Izzy May 10 '17 at 6:55
1

It is possible to use a VPN profile* to affect hostname resolution. There are a number of apps now available on the Play Store that provide a convenient way to do this, such as Hosts Go. Note that, since this technique requires the use of a VPN profile, you won't be able to use an actual VPN in conjunction with this technique.


*As of Android 4.0 (API Level 14) — https://developer.android.com/guide/topics/connectivity/vpn

-1

Warning: this will work only if ADB can get root access, which isn't the case for most ROMs. It works in in LineageOS 14.1.

Requirements:

  • Developer options enabled in phone
  • adb installed in computer

Steps

Apply the following settings in Developer options:

  • Root access -> ADB only
  • Android debugging -> on

Connect the phone to the computer. Grant permission in your phone if asked. In the computer, launch a terminal and run

$ adb root

Grant permission in your phone. Remount with

$ adb remount

Start a remote rooted shell

$ adb shell

In the adb shell, edit your hosts file

# nano /etc/hosts

When ready, disconnect

# exit
  • 3
    Huh? On LOS root is only available if you flash the additional root package, which OP doesn't want to (i.e. "Root access = ADB only" cannot be achieved). So how should your steps work without root if they require root? Could you please clarify? – Izzy May 9 '17 at 12:46
  • adbd cannot run as root in production build. – iBug May 9 '17 at 13:18
  • Also, how can you get nano? cat is all that you've got. Android does not even ship with a basic vi. – iBug May 9 '17 at 13:19
  • @Izzy just borrowed a phone with stock Android to confirm and yes, it seems to be a LOS thing. I didn't flash the root package. I'll modify my answer and the question title to reflect this fact. – berbt May 9 '17 at 13:43
  • @iBug same as my previous comment: most likely a LOS thing. nano is in /system/xbin/nano. vim--version (in /system/xbin/ too, no vi alias) says it was "Compiled by tpruvot@CyanogenMod". – berbt May 9 '17 at 13:55

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.