I need to create a file /etc/init/start_swift.conf with following commands:

description "mount swift drives"
start on runlevel [234]
stop on runlevel [0156]
exec /opt/swift/bin/mount_devices

But the problem is that I even don't have the init directory. I have put start_swift.conf into /etc/init.d/ but it doesn't work. How to create this type of upstart files in CentOS7?

2 Answers 2


There are two answers for this question.

On CentOS 7 systemd is how you can run a service or script on start You put a .service file under /etc/systemd/system, which can look like this:

; /etc/systemd/system/swift.service


; Runlevel here: 

But actually systemd can be used for mounting devices directly, if this is the intention of your script.

For a (non-rpm-packaged) service you would put the a ".mount" file under /etc/systemd/system, e.g. /etc/systemd/system/var-lib-docker.mount. You might also want look into auto-mount options of systemd, see references.

In order to load the files, use systemd daemon-reload.

; /etc/systemd/system/var-lib-docker.mount
Description="Mount a volume"


There is a lot you can tune, please refer to:

References - https://www.freedesktop.org/software/systemd/man/systemd.service.html - https://www.freedesktop.org/software/systemd/man/systemd.mount.html - https://www.freedesktop.org/software/systemd/man/systemd.automount.html


Centos uses systemd, not Upstart. Systemd is backward compatible with SysV init scripts. According to LSB 3.1, the init script must have informational Comment Conventions, defining when the script has to start/stop and what is required for the script to start/stop. I would recommend checking this guide and rewriting your upstart script to systemd unit.

  • Welcome to U&L, can you post revelent part of the link ?
    – Archemar
    May 16, 2016 at 9:13
  • Relevant part? This is the official RedHat documentation on how to write systemd units. May 16, 2016 at 9:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .