26

Is there a way to modify the hosts file in Chrome OS?

­­/etc/hosts

The file is read only, so trying to modify it using sudo vim does not work.

I have read that disabling root filesystem verification would make editing the hosts file possible, but would also make you loose Chrome OS auto update.

­ sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions 2

Is there any way to modify the hosts file without loosing automatic updates?

Thanks for your help.

EDIT: Just to specify, I am using an Acer C7 Chromebook with developer mode enable.

4
  • You should be able to modify the permissions of the file by using sudo cmod have you tried that?
    – Ramhound
    May 14 '13 at 11:46
  • I have tried sudo chmod, does not work and instead outputs chmod: changing permissions of ‘hosts’: Read-only file system.
    – Bricknix
    May 14 '13 at 21:03
  • You will have to use the command you found to do it then.
    – Ramhound
    May 14 '13 at 23:09
  • I ran the above make_dev_ssd command and rebooted, but I sill can't edit anything in /etc with sudo. What else do we need to do? I tried remounting / with rw, but it complains that the partition is write-protected.
    – trusktr
    May 17 '17 at 5:19
10

There are two options available:

1) Edit the hosts file from a Developer Chromebook:

sudo /usr/share/vboot/bin/make_dev_ssd.sh --remove_rootfs_verification --partitions 2

You will lose changes to the hosts file when ChromeOS does update again. Updates can be disabled by creating the file /mnt/stateful_partition/etc/lsb-release that contains the following 2 lines:

CHROMEOS_RELEASE_VERSION=9999.9999.9999.9999
GOOGLE_RELEASE=9999.9999.9999.9999

2) Using a Chrome extension

This topic is discussed thoroughly in this question: Simulate manipulation of the etc/hosts file in Google Chrome -- it is debated as to whether any of the extensions actually work the same as a hosts file modification.

3
  • 4
    Looks like the proxy-extension that is being linked to here has been removed.
    – creuzerm
    Aug 4 '16 at 15:46
  • I've followed this, but I found that my changes to /etc/hosts won't stick after I restart. It took me some time to realize that the hosts file I changed was a copy created by crosdns. I needed to do sudo umount /etc/hosts.d in order to access the underlying hosts file. Jul 24 at 10:34
  • Another option to disable automatic updates is to delete/rename the /etc/init/update-engine.conf file. (as mentioned here)
    – Venryx
    Oct 4 at 17:47
4

Unfortunately, I do not know either how to modify the host file without disabling the auto-update functionality, but depending on what you want to use that host file for, you could try installing a Chrome extension that has similar functionality as the host file.

For instance, there is Block Site for making your own list of sites you want to block. There is AdBlock Plus for blocking ads. And there is Rescue Time Dashboard for keeping track of which sites you spend most of your time on.

3

If you want to change your hosts file so you can point back to 127.0.0.1 then can I suggest http://readme.localtest.me/.

0

did you try remounting the partition as rw? I don't have a chromebook, but have had this issue on other platforms...

mount / -o remount, rw

https://sites.google.com/site/cr48ite/getting-technical/remove-rootfs-verification-make-read-write

hth

0

Recommend adding A records to your DNS server to point to your local resources. For example, CloudFlare managed DNS or other. That way you can easily point any domain name such as "local.yourdomain.com" to 127.0.0.1

0

If you enable Linux on a Chromebook then there is an /etc/hosts file within its container which can be modified. While it does not have any effect on the Chromebook's (Chrome) browser it will be read by any Linux applications.

Thus what I did was install Firefox (sudo apt install firefox-esr) inside Linux and launch it from there. I verified then that it could go to http://penguin/ which is an alias of localhost on my Chromebook as specified in /etc/hosts.

You could also use this method with Chromium.

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.