How to edit the hosts file on FP2

Hello,

2 years ago, I created a post on this forum detailing all the steps on how to edit the hosts file on Fairphone 1.
Now, with my new Fairphone 2, I would like to do the same!

:warning: DO THIS AT YOUR OWN RISK! It’s not my fault if you’re abducted by :alien:s.

I was doing the following on FP1, I tried it on FP2, but calling “su” on step 5 did not work. So I just added one initial step to root the phone. The rest of the procedure is stricly identical:

  1. Root the phone I followed the Kingroot tutorial to do so (EDIT by @paulakreuzer: Superuser is saver but more complicated)

  2. Download the host file to the phone from Google Drive => OK, the file is in /storage/sdcard0/Download/

  3. Enable USB debugging in developer options =>OK, tapping 7 times on build number in Settings > About Phone

  4. Enable USB storage on the fairphone => OK

  5. Check that the device is visible => OK, with nothing selected in USB debugging options

    adb devices
    eb1ef6e4 device

  6. Start android shell then go root => Requires the phone to be root

    adb shell
    su

  7. Mount the filesystem as readwrite => OK

mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system

  1. Copy the hosts file => OK

cp /storage/sdcard0/Download/hosts /system/etc/hosts

  1. Return the filesystem as readonly => OK

mount -o remount,ro /system

  1. Exit => OK

exit
exit

  1. Eject or unmount the Fairphone
    Disable USB debugging
    DONE!

Thank you!

1 Like

You’ll have to root your phone. The easiest way is at the moment this one.

You mean the safest. The easiest is with Kingroot.

1 Like

Thanks for the Kingroot alternative, I’ll try that first!!!

I just updated the tutorial, adding one required initial step to root the FP2.
As @paulakreuzer mentioned, I used Kingroot and so far it worked perfectly.

Oh yes, @paulakreuzer, you are right. Maybe @Antoinet can add the disadvantages of KingRoot to his post? (NOT open-source (you don’t know what it’s doing exactly), using security vulnerabilities for rooting, IMEI (and propably other sensitive data) is transmitted to developer (in China))

2 Likes

At least it’s difficult to tell if they are trusworthy or not. The topic was already discussed here: https://forum.fairphone.com/t/kingroot-and-fairphone2-share-your-experience-please/11925. I’m really glad that another quite easy y much safer solution to root it was found.

There could be (maybe) a non-root alternative using a local fake VPN (only supported over Lollipop, I think).

NetGuard is an example. It’s main use is to block network traffic for particular apps (or all), but latest version (0.83 as today) has the ability to use a host file downloaded from an URL (I’m currently using the AdAway one) and a strangely disabled option for upload a local hosts file (maybe an upcoming feature?).

EDIT

Today I received an update to version 0.95 on F-Droid and I can confirm the option is enabled for upload local hosts files. So no root needed! \o/

1 Like

@Roboe Interesting, but I still prefer using the hosts file since I spend too much time on news websites, and blocking it from the host file is actually the best way I found to fight procrastination!!!

@paulakreuzer Thanks for the (much) safer alternative, and not that difficult!
I wanted to update step 7 to:

mount -o rw,remount /system

But it seems that I can’t edit the post anymore, could you do it for me?

The NetGuard way was intended for non-root users, and it is more limited, indeed, :wink:

If you have root permissions, AdAway let you easily add custom sites to the blacklist, \o/

PD: FPOS-OS is officially released and pre-rooted! I recommend checking it out if you don’t depend/want to depend less on Google Services, :wink: