Picture this. You've got your hot new rooted android phone and you want to mess with the OS. Say, replace the hosts file with something like this, to block all those pesky ads that pop up so inopportunely in every app you've ever installed.
Ok, you've logged into to your phone with adb shell
or run su -
from the terminal emulator.
The downloaded hosts filehas just finished after you ran something like this:
cd /mnt/sdcard/download && wget http://someonewhocares.org/hosts/zero/hosts
You've backed up your hosts file (like this cp /etc/hosts /mnt/sdcard/hosts-original
) in case something goes wrong you can just cp /mnt/sdcard/hosts-original /etc/hosts
to restore your original host file.
Now you're ready to install your freshly downloaded super ad-blocking epic and awesome new host file.
You run cp /mnt/sdcard/download/hosts/etc/hosts
only to find you've got a read only file system on your hands.
Have no fear, remount is here.
First, lets figure out what we need to remount, running ls -lah
tells us where /etc
is symlinked to:
drwxrwx--x 1 system system 2.0K Jan 26 09:44 data
-rw-r--r-- 1 root root 118 Dec 31 1969 default.prop
drwxr-xr-x 12 root root 1.3K Feb 14 09:27 dev
lrwxrwxrwx 1 root root 11 Feb 14 09:27 etc -> /system/etc
-rwxr-x--- 1 root root 92.2K Dec 31 1969 init
-rwxr-x--- 1 root root 1.6K Dec 31 1969 init.goldfish.rc
Ok. We need to remount /system
, lets figure out where that is by running cat /proc/mounts | grep system
/dev/block/mtdblock4 /system yaffs2 ro,relatime 0 0
Now that we know /system is mounting /dev/block/mtdblock4, we can run the magical remount command:
mount -o rw,remount -t yaffs2 /dev/block/mtdblock4
we just need to run the copy once more:
cp /mnt/sdcard/download/hosts.txt /etc/hosts
and voila! your android is now ad-free (mostly)
comment with questions or a how to for iPhone