A way to avoid the smartmontools systemd service to fail is to switch
the Service type from notify to forking. This after adding the "-q
nodev0" flag to the /etc/default/smartmontools smart_options variable.

systemctl edit smartmontools
[Service]
Type=forking

then systemctl daemon-reload
and restart samrtmontools/

Why is smartd of type notify? Does it send notification to systemd via
sd_notify?

Cheers,
Alban


On Tue, 13 Jun 2023 03:15:06 +0200 Alban Browaeys
<alban.browa...@gmail.com> wrote:
> 
> Even with "-q nodev0" the service ends up in a failed state (but now
> with an exit status of 0/SUCCESS)
> 
> sudo systemctl status smartmontools
> × smartmontools.service - Self Monitoring and Reporting Technology
(SMART) Daemon
>      Loaded: loaded (/lib/systemd/system/smartmontools.service;
enabled; preset: enabled)
>      Active: failed (Result: protocol) since Tue 2023-06-13 03:07:54
CEST; 2s ago
>        Docs: man:smartd(8)
>              man:smartd.conf(5)
>     Process: 4072 ExecStart=/usr/sbin/smartd -n $smartd_opts
(code=exited, status=0/SUCCESS)
>    Main PID: 4072 (code=exited, status=0/SUCCESS)
>      Status: "No devices to monitor"
>         CPU: 29ms
> 
> juin 13 03:07:54 hercule systemd[1]: Starting smartmontools.service -
Self Monitoring and Reporting Technology (SMART) Daemon...
> juin 13 03:07:54 hercule smartd[4072]: smartd 7.3 2022-02-28 r5338
[aarch64-linux-6.2.0-rc3-meson64] (local build)
> juin 13 03:07:54 hercule smartd[4072]: Copyright (C) 2002-22, Bruce
Allen, Christian Franke, www.smartmontools.org
> juin 13 03:07:54 hercule smartd[4072]: Opened configuration file
/etc/smartd.conf
> juin 13 03:07:54 hercule smartd[4072]: Drive: DEVICESCAN, implied '-
a' Directive on line 21 of file /etc/smartd.conf
> juin 13 03:07:54 hercule smartd[4072]: Configuration file
/etc/smartd.conf was parsed, found DEVICESCAN, scanning devices
> juin 13 03:07:54 hercule smartd[4072]: In the system's table of
devices NO devices found to scan
> juin 13 03:07:54 hercule systemd[1]: smartmontools.service: Failed
with result 'protocol'.
> juin 13 03:07:54 hercule smartd[4072]: Unable to monitor any SMART
enabled devices. Try debug (-d) option. Exiting...
> juin 13 03:07:54 hercule systemd[1]: Failed to start
smartmontools.service - Self Monitoring and Reporting Technology
(SMART) Daemon.
> 
> My storage as of now is only EMMC and SD. Though at time I can have
> external USB HDDs to monitor with smartd.
> 
> Cheers,
> Alban
> 
> 
> On Mon, 10 Apr 2023 15:41:10 +0200 Christian Franke
> <christian.fra...@t-online.de> wrote:
> > Possible fix for the package: Add '-q nodev0' or '-q never' to
> ExecStart 
> > in smartmontools.service.
> > 
> > Workaround for users: Add one of these to smartd_opts in 
> > /etc/default/smartmontools.
> > 
> > Option '-q nodev0' is available since smartmontools 7.3. Then
smartd 
> > will exit with status 0 instead of 17 (default '-q nodev') if there
> are 
> > no devices to monitor. Systemd should no longer report this as a
> failed 
> > service.
> > 
> > With '-q never', smartd will keep running and does nothing. This
was
> the 
> > default for '-q' in some previous versions of (only!) the Debian 
> > package. This Debian-specific patch was reverted later, see:
> > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1006630
> > 
> > Regards,
> > 
> > Christian
> > smartmontools.org
> > 

Reply via email to