Re: systemd and smartmontools

Christian Franke <[email protected]>
Newsgroups gmane.linux.utilities.smartmontools
Message-ID <[email protected]>
Al Lau wrote:
> Hi,
>
> I am seeking help and advise on troubleshooting the starting of the 
> smartd daemon. The /usr/sbin/smartd comes from the smartmontools 
> version 6.3.
>
> The /usr/lib/systemd/system/smartd.service file looks like this
>
> # cat /usr/lib/systemd/system/smartd.service
> [Unit]
> Description=Self Monitoring and Reporting Technology (SMART) Daemon
> Documentation=man:smartd(8) man:smartd.conf(5)
> After=syslog.target
>
> [Service]
> Type=forking
> PIDFile=/run/smartd.pid
> ExecStartPre=/bin/rm -f /run/smartd.pid
> EnvironmentFile=/etc/sysconfig/smartmontools
> ExecStart=/usr/sbin/smartd $smartd_opts
> ExecReload=/bin/kill -HUP $MAINPID
> StandardOutput=syslog
>
> [Install]
> WantedBy=multi-user.target
>
> When "systemctl start smartd.service" is called, the process forks 
> into a daemon. The problem I'm seeing is that the forked process 
> received a SIGTERM signal and exited.  How do I resolve this so that 
> the forked process would not get terminated.
>
> # systemctl status smartd.service
> ...
> Apr 02 17:18:20 007 smartd[7456]: Device: /dev/bus/0 
> [megaraid_disk_19], is SMART capable. Adding to "monitor" list.
> Apr 02 17:18:20 007 smartd[7456]: Monitoring 0 ATA and 12 SCSI devices
> Apr 02 17:18:21 007 systemd[1]: PID file /run/smartd.pid not readable 
> (yet?) after start.
> Apr 02 17:18:21 007 smartd[7463]: smartd has fork()ed into background 
> mode. New PID=7463.
> Apr 02 17:19:49 007 systemd[1]: smartd.service operation timed out. 
> Terminating.

Systemd waits for the PID file but smartd does not create one because 
the -p (--pidfile) option is missing.

You could either:
- Add '-p /run/smartd.pid' to smartd command in ExecStart.
or (better):
- Add  '-n' (--no-fork) to smartd command in ExecStart AND remove Type, 
PIDFile and ExecStartPre from smartd.service file.

See smartd.service.in file from smartmontools source code:
http://www.smartmontools.org/browser/trunk/smartmontools/smartd.service.in?rev=4048

Thanks,
Christian


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.