VPS boot overrides some configuration files

Problem: I bought a new VPS and did some configuration changes (e.g. hostname setting). I’ve installed some software and wanted to test if my settings are boot resistant. And every time the VPS was  booting the files /etc/hosts and /etc/hostname was overridden by the defaults of the provider.

Reason: Virtuozzo (the software which virtualises my VPS) overrides those files at every  time the VPS is booting.

Solution: Replacing the files /etc/hosts and /etc/hostname at boot-time.

The following description is applied for Ubuntu 14.04. Both replacements are implemented as upstart jobs.


Copy the /etc/hosts (e.g. /etc/hosts_my) and adapt it to your needs. Then create the file /etc/init/hosts.conf with the following content:

description "restore my hosts"
start on startup
exec cp /etc/hosts_my /etc/hosts


Copy the /etc/hostname (e.g. /etc/hostname_mod) and adapt it to your needs. Then edit the file /etc/init/hostname.conf and change the last exec command to:
exec hostname -b -F /etc/hostname_mod

That’s it!

, ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: