/etc/hosts busy??

James Cameron quozl at laptop.org
Sun Sep 7 22:44:30 EDT 2014

On Sat, Sep 06, 2014 at 11:58:02PM -0700, Hal Murray wrote:
> When I tried to update /etc/hosts, it says busy.  I thought I'd been
> doing this for years, so I'm a bit surprised and/or confused.
> bash-4.2# mv hosts /etc/hosts
> mv: inter-device move failed: 'hosts' to '/etc/hosts'; unable to
> remove target: Device or resource busy

On OLPC OS /etc/hosts is a file mount point, you can find it in
/proc/mounts, and the problem is that you cannot move your file hosts
into that filesystem from another filesystem.

# grep hosts /proc/mounts
/dev/disk/mmc/mmc1p2 /etc/hosts ext4 rw,noatime 0 0

Instead, you must copy into and replace the contents of the file.

It is a side-effect of the olpc-update feature.

> bash-4.2# rm /etc/hosts
> rm: cannot remove '/etc/hosts': Device or resource busy
> bash-4.2# mv /etc/hosts /etc/hostsx
> mv: cannot move '/etc/hosts' to '/etc/hostsx': Device or resource busy
> bash-4.2#
> It used to work.  I did it sometime after early June.

No idea why, sorry.  It should have always done this.

> bash-4.2# ls -l /etc/hosts
> -rw-r--r-- 1 root root 1504 Jun  4 22:07 /etc/hosts
> bash-4.2# 
> My usual approach for things like this is to find the program that has the 
> file open, but I can't find it with lsof.  ??

No, lsof won't help.

> bash-4.2# lsof | wc
> lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
>       Output information may be incomplete.
>    4658   44081  503329
> bash-4.2# lsof | grep hosts
> lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
>       Output information may be incomplete.
> bash-4.2# 
> Does anybody know if something is hiding in that error message
> and/or how to find out what's going on?
> cp -p worked, but I'm still curious.  I'm pretty sure I used mv last
> time, but maybe it's been busy for ages.

The behaviour you see was set by olpc-os-builder
modules/base/kspost.10.core.inc which adds /etc/hosts and certain
other files to /etc/statetab.d/olpc with comment:

# Things to store separately in persistent storage
# This means these files can be writable at runtime without breaking the
# pristine-ness of /versions/pristine. It also means they are retained
# over upgrades.

If you don't plan to use olpc-update to maintain the laptop population
in a deployment, you can disable the feature in olpc-os-builder by
setting base.versioned_fs=0 in the builder configuration file.

James Cameron

More information about the Devel mailing list