I want to apply a certain hosts file (that I have on my SD card) when I open a particular app, and restore the original hosts file on exit.
I thought Automagic would be the perfect tool to do it.
My idea was:
App launch -> Copy/rename /etc/hosts to /etc/hosts1 -> Copy /emulated/0/my-hosts to /etc/hosts
App exit -> Rename /etc/hosts1 back to /etc/hosts
I tried using "Move files" hoping to rename /etc/hosts to /etc/hosts1 but it didn't even work (/etc/hosts1: open failed: EROFS (Read-only file system))
Could someone help me please?
(I found this Tasker task that seems to modify hosts file but couldn't find an Automagic one https://forum.xda-developers.com/u/task ... e-t3659602)
How to modify hosts file?
Moderator: Martin
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: How to modify hosts file?
Hello
I don't know how to link you to my earlier posts, but if you search this forum for "Delete files in root folder" this may shed some light on your problem.
Hope this helps
Micky
I don't know how to link you to my earlier posts, but if you search this forum for "Delete files in root folder" this may shed some light on your problem.
Hope this helps
Micky
Crude but it works.
Re: How to modify hosts file?
Thank you Micky it is definitely useful.
I tried this
and I seem to run into the same error:
stderr=mv: bad '/etc/hosts': Read-only file system
I am now trying to make sense of Desmanto's reply to you about mounting as rw...
That produced nothing in the stdout. I guess it is another question, thanks Micky!
I tried this
Code: Select all
mv /etc/hosts /etc/hosts1
stderr=mv: bad '/etc/hosts': Read-only file system
I am now trying to make sense of Desmanto's reply to you about mounting as rw...
Code: Select all
mount | grep /etc
Last edited by aximili on 03 Oct 2020 10:41, edited 3 times in total.
-
- Posts: 179
- Joined: 16 Oct 2019 17:38
Re: How to modify hosts file?
Hello
"I couldn't mount /system as rw but it worked without the word system."
This might help. It did for me.
Good luck
Micky
"I couldn't mount /system as rw but it worked without the word system."
This might help. It did for me.
Good luck
Micky
Crude but it works.
Re: How to modify hosts file?
Thank you Micky for trying to help me! So I've tried this:
That gave me mount: '/system' not in /proc/mounts
Then I tried this:
That seems successful? (nothing in stderr)
But after that, trying
still gave me mv: bad '/etc/hosts': Read-only file system :'(
Code: Select all
mount -o rw,remount /system
Then I tried this:
Code: Select all
mount -o rw,remount
But after that, trying
Code: Select all
mv /etc/hosts /etc/hosts1
Last edited by aximili on 03 Oct 2020 10:31, edited 1 time in total.
Re: How to modify hosts file?
Does your phone have root access?
And enable this: Root functions (Experimental)?
And enable this: Root functions (Experimental)?
Re: How to modify hosts file?
Yes I had already have Root functions enabled, thanks Hit.
AdAway is working fine on my phone (it writes to the hosts file, I can see the hosts file entries changing when I use AdAway)
AdAway is working fine on my phone (it writes to the hosts file, I can see the hosts file entries changing when I use AdAway)