-
-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Not an issue per se, but perhaps some information that may inform future releases.
Workload is as home backup. The NAS should turn on once a day (via wake-on-lan) to accept backup files from other Windows machines on the LAN, and then it should turn off to save power and component life.
Spindown_timer script worked well for version 13, but after upgrading TrueNAS to 25... it was not working anymore.
Solutions so far have been:
1.
In the script, change the shutdown method to "systemctl poweroff":
# Handle shutdown timeout
if [ ${SHUTDOWN_TIMEOUT} -gt 0 ]; then
if all_drives_are_idle "${IDLE_DRIVES}"; then
SHUTDOWN_COUNTER=$((SHUTDOWN_COUNTER - POLL_TIME))
if [[ ! ${SHUTDOWN_COUNTER} -gt 0 ]]; then
log_verbose "Shutting down system"
# case $HOST_PLATFORM in
# "FreeBSD") shutdown -p now ;;
# *) shutdown -h now ;;
# esac
systemctl poweroff
fi
else
SHUTDOWN_COUNTER=${SHUTDOWN_TIMEOUT}
fi
log_verbose "Shutdown timeout: ${SHUTDOWN_COUNTER}"
fi
Rather than using System - Advanced Settings - Init/Shutdown Scripts
...now using Systemd service, ensuring the service waits for the pool to start.
/etc/systemd/system/spindown_timer.service
[Unit]
Description=Spindown Timer Service
After=network.target local-fs.target
RequiresMountsFor=/mnt/Pool1
[Service]
ExecStart=/mnt/Pool1/Admin/truenas-spindown-timer-master/run_spindown.sh
Restart=always
User=root
[Install]
WantedBy=multi-user.target
Start service:
sudo systemctl daemon-reload
sudo systemctl restart spindown_timer
sudo systemctl status spindown_timer
Monitor service activity:
sudo journalctl -u spindown_timer -f
Could run spindown_timer.sh directly in the service, but this way allows to easier tweaking of parameters.
/mnt/Pool1/Admin/truenas-spindown-timer-master/run_spindown.sh
#!/usr/bin/bash
/mnt/Pool1/Admin/truenas-spindown-timer-master/spindown_timer.sh -l -t 1200 -p 60 -s 1800 -m -i sda -i sdb -i sdc -i sdd
** NB - beware of Windows line endings - paste into SSH
Thank you!!!