[MOD][GUIDE] AdAway on Write Protected /system Partitions [RECOVERY]

Search This thread

Mantelinho

Senior Member
Oct 22, 2012
75
220
Düsseldorf
Redmi Note 8 Pro
If your /system partition is write protected like on the HTC One (M7) and you try to use an advertisement blocker like AdAway, you will encounter that changes to /system/etc/hosts are lost after reboot and ad blocking doesn't work. You have basically 3 methods to get around this:

A) Link /system/etc/hosts to a partition AdAway can write to
Install symlink_hosts_to_data.zip via your custom recovery (like CWM) to create a symbolic link from /system/etc/hosts to /data/data/hosts. Afterwards you can configure AdAway to use /data/data/hosts (as shown in attached screenshot) and it will work perfectly with updates and everything.

B) Flash the hosts file directly
Install adaway_hosts_2014-04-14.zip via recovery. Now you have the hosts file as AdAway created on April 14th 2014. Disadvantage: you would need to flash again for updates. Advantage: you don't need the AdAway app at all. Note: many custom ROMs include such a hosts file already in their distribution.

C) Make /system partition writable
Use this kernel extension or a custom ROM including it to have the /system partition writable all the time. AdAway will work out-of-the-box then.

If you like to restore original state after having flashed one of the recovery zips above, use the attached restore_original_hosts.zip
 

Attachments

  • restore_original_hosts.zip
    139 KB · Views: 4,159
  • Screenshot_2013-06-20-11-09-13.jpg
    Screenshot_2013-06-20-11-09-13.jpg
    25.4 KB · Views: 11,007
  • adaway_hosts_2015-04-13.zip
    426.2 KB · Views: 4,624
  • symlink_hosts_to_data.zip
    138.5 KB · Views: 9,280
Last edited:

melando

Senior Member
Aug 27, 2010
1,309
215
London
Google Pixel 6
The attached recovery flashable update.zip modifies your /system/etc/hosts file just like AdAway or Adblock Plus would. Useful if your /system partition is write protected like on the HTC One (and changes are lost after reboot).

You need
  • a custom recovery like ClockWorkMod on your device
  • the understanding that you will use this script at your own risk
You could also
  • make the /system partition writable via kernel patch and use the app
  • use a custom ROM which comes with an ad-blocking hosts file already
This uses the hosts list from AdAway as of June 17th 2013. All credits for this to AdAway and its contributors

Can you create a script which creates the symbolic link i.e. the approach recommended in AdAway help (S-ON/S-OFF)? That would allow the file to be updated by the app over time...
 

Mantelinho

Senior Member
Oct 22, 2012
75
220
Düsseldorf
Redmi Note 8 Pro
Can you create a script which creates the symbolic link i.e. the approach recommended in AdAway help (S-ON/S-OFF)? That would allow the file to be updated by the app over time...

This makes sense if you want to keep using the app, thanks for the hint. I uploaded symlink_hosts_to_data.zip and updated the opening post. This will work also after having the other zip already applied.
 
Last edited:

jonny68

Senior Member
Mar 27, 2010
5,747
601
Dublin
Cheers, do I need all 3 zips or just the one dated today?

Sent from my Nexus 7 using xda app-developers app
 

jonny68

Senior Member
Mar 27, 2010
5,747
601
Dublin
Cheers, so should this block all ads then, I had the ad block apk. But it didn't block all annoying ads?

Sent from my Nexus 7 using xda app-developers app
 

Mantelinho

Senior Member
Oct 22, 2012
75
220
Düsseldorf
Redmi Note 8 Pro
Cheers, so should this block all ads then, I had the ad block apk. But it didn't block all annoying ads?

This should block all ads so far (at least it absolutely does for me). However the list of ad servers is actively maintained by hosts-file.net. If you should find an ad host not blocked you can post it there and it will find its way back to AdAway. To be always up-to-date I recommend using AdAway with the symlink method from OP.
 
Last edited:
  • Like
Reactions: Kogam22

jonny68

Senior Member
Mar 27, 2010
5,747
601
Dublin
Dunno why but it doesn't block ads on the goal.com app but for some reason no adblock app ever really did, strange!

Sent from my Nexus 7 using xda app-developers app
 

B BOY DRAW2

Senior Member
Mar 1, 2011
80
22
Wellington
sinna ketskm

Hey, just inquiring...

I've done the "flash host files directly" step, and playing Subway Surfers.

It would seem that ads are only blocked on that game when I have system set to RW...(I think...?...not 100% sure, but it would seem this way)

I was under the impression that it shouldn't matter because I'm flashing the host file directly?

Can anyone offer their thoughts please.
 

Mantelinho

Senior Member
Oct 22, 2012
75
220
Düsseldorf
Redmi Note 8 Pro
Hey, just inquiring...

I've done the "flash host files directly" step, and playing Subway Surfers.

It would seem that ads are only blocked on that game when I have system set to RW...(I think...?...not 100% sure, but it would seem this way)

I was under the impression that it shouldn't matter because I'm flashing the host file directly?

Can anyone offer their thoughts please.

Yes, after flashing the hosts files directly no further steps should be necessary and ads be gone. Can you verify that ads also exist in other applications (or websites)? Maybe this is an issue with the app you are using, for example if it loads its apps from its own (unblocked) server.
 
  • Like
Reactions: trungnt0108

B BOY DRAW2

Senior Member
Mar 1, 2011
80
22
Wellington
Yeah, I think you're right about it perhaps being app related. I think maybe I need to monitor it a bit more closely and take random notes...
like sometimes I'm bombarded with advertisments any time I touch to advance or go back through menus...but just in that app...then I'll reboot...and sometimes it'll go a full day without ads...?

I also use a local news app which would normally advertise dating links, but those don't seem to appear...so it's definitely working.

All good though...thanks for answering that for me!
Much appreciated!!!
 

goldenratio

Senior Member
Aug 3, 2010
146
88
Install symlink_hosts_to_data.zip via your custom recovery (like CWM) to create a symbolic link from /system/etc/hosts to /data/data/hosts. Afterwards you can configure AdAway to use /data/data/hosts.

Thanks so much for this info Mantelinho, I had been looking for a solution. When using this 1st method, do I need to flash symlink_hosts_to_data.zip in recovery after every ROM flash? I.e., I'm dirty-flashing CyanogenMod nightlies every other day or so and I'm not sure if need to re-create the symlink after every flash.

edit: I have discovered I DO need to flash symlink_hosts_to_data.zip after every ROM flash.
 
Last edited:

TrainAss

Senior Member
Sep 18, 2009
206
18
Edmonton
Sorry to bump an old thread. Will this work on the new M8 variant of the One, or will it only work on the M7 variant?
 

Top Liked Posts

  • There are no posts matching your filters.
  • 50
    If your /system partition is write protected like on the HTC One (M7) and you try to use an advertisement blocker like AdAway, you will encounter that changes to /system/etc/hosts are lost after reboot and ad blocking doesn't work. You have basically 3 methods to get around this:

    A) Link /system/etc/hosts to a partition AdAway can write to
    Install symlink_hosts_to_data.zip via your custom recovery (like CWM) to create a symbolic link from /system/etc/hosts to /data/data/hosts. Afterwards you can configure AdAway to use /data/data/hosts (as shown in attached screenshot) and it will work perfectly with updates and everything.

    B) Flash the hosts file directly
    Install adaway_hosts_2014-04-14.zip via recovery. Now you have the hosts file as AdAway created on April 14th 2014. Disadvantage: you would need to flash again for updates. Advantage: you don't need the AdAway app at all. Note: many custom ROMs include such a hosts file already in their distribution.

    C) Make /system partition writable
    Use this kernel extension or a custom ROM including it to have the /system partition writable all the time. AdAway will work out-of-the-box then.

    If you like to restore original state after having flashed one of the recovery zips above, use the attached restore_original_hosts.zip
    3
    The attached recovery flashable update.zip modifies your /system/etc/hosts file just like AdAway or Adblock Plus would. Useful if your /system partition is write protected like on the HTC One (and changes are lost after reboot).

    You need
    • a custom recovery like ClockWorkMod on your device
    • the understanding that you will use this script at your own risk
    You could also
    • make the /system partition writable via kernel patch and use the app
    • use a custom ROM which comes with an ad-blocking hosts file already
    This uses the hosts list from AdAway as of June 17th 2013. All credits for this to AdAway and its contributors

    Can you create a script which creates the symbolic link i.e. the approach recommended in AdAway help (S-ON/S-OFF)? That would allow the file to be updated by the app over time...
    3
    Can you create a script which creates the symbolic link i.e. the approach recommended in AdAway help (S-ON/S-OFF)? That would allow the file to be updated by the app over time...

    This makes sense if you want to keep using the app, thanks for the hint. I uploaded symlink_hosts_to_data.zip and updated the opening post. This will work also after having the other zip already applied.
    1
    Cheers, do I need all 3 zips or just the one dated today?

    Either the one dated (and you're fine) OR the symlink one if wanting to use AdAway configured to write to /data/data/hosts. The third file is only for restoring original state.
    1
    Cheers, so should this block all ads then, I had the ad block apk. But it didn't block all annoying ads?

    This should block all ads so far (at least it absolutely does for me). However the list of ad servers is actively maintained by hosts-file.net. If you should find an ad host not blocked you can post it there and it will find its way back to AdAway. To be always up-to-date I recommend using AdAway with the symlink method from OP.