NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
HuwSy
Feb 05, 2023Guide
Ready Nas 516 drive sleep issues with readynasd
Hi Im a new Readynas user, just as they are retired and because my work decided to throw the 516 unit out with 5x 2TB drives included because they didn’t have the required support going forward. It...
HuwSy
Apr 17, 2023Guide
The spin down noflushd does change a lot of the caching so only writes are likely to spin the disk up. But I have a feeling it’s the writes to Readynas logs about temperatures, networking etc that wake it, or writing data. If I could move the os to run from a flash it would be better, I’ve noticed some other manufacturers ones have this arrangement.
HuwSy
Sep 06, 2023Guide
After much tinkering I have given up with readynasd as a service and made the parts I want to work. It was not a quick process but now I average 16+ hours between spin down and up.
Changed caching to 80% and removed the byte versions
/etc/sysctl.conf
vm.swappiness=1
vm.vfs_cache_pressure = 10
vm.dirty_background_ratio = 80
vm.dirty_ratio = 80
# vm.dirty_background_bytes
# vm.dirty_bytes
sysctl --system
Made sure it emails root on errors
/etc/mdadm/mdadm.conf
MAILADDR root
MAILFROM root
And add this at the end of the exec to trigger emails
/etc/systemd/system/multi-user.target.wants/mdadm.service
Exec... -m root
Updated the scheduled tasks all to 5-6am in /etc/crontab
Run snapper for all 0-5 shares I have
crontab -e
45 5 * * * for i in $(seq 0 5); do snapper --config=$i --quiet create --description="timeline" --cleanup-algorithm="timeline" ; done
Updated all the timers to about 5-6am, fresh clam about 5 min before daily scan
/lib/systemd/system/*.timer
Use as appropriate something like these in the above
OnCalendar=Thu 5:0
OnCalendar=*-*-* 04:55:00
And also remove any
OnUnitActiveSec=
Remove any unused services
systemctl mask fvbackup-q rn-update.timer radar.timer smb rpcbind.socket rpcbind
systemctl disable dev-md1.swap
Firewall and fan control app
/usr/sbin/noreadynas
#!/bin/bash
## Variables ##
FANPWMPATH=/sys/devices/platform/nct6775.2608/hwmon/hwmon1/pwm1
FANPWMENABLE=/sys/devices/platform/nct6775.2608/hwmon/hwmon1/pwm1_enable
FANSPEEDPATH=/sys/devices/platform/nct6775.2608/hwmon/hwmon1/fan1_input
CORETEMPPATH=/sys/devices/platform/nct6775.2608/hwmon/hwmon1/temp7_input
INTERNALDRIVES=/dev/sd[a-e]
MAXFAN=100 # Maximum operable speed
MINFAN=0 # Minimum operable speed
MINPWM=75 # PWM Limit
MAXPWM=255 # PWM Limit
MINTEMP=40 # Min temp -> Fan slowest
MAXTEMP=75 # Max temp -> Fan fastest
MINTEMPD=35 # Min drive temp -> Fan slowest
MAXTEMPD=60 # Max drive temp -> Fan fastest
NEWSPEED=65 # Initial fan speed (%)
## Functions ##
function getReadings {
FANPWM=$(cat $FANPWMPATH)
FANSPEED=$(cat $FANSPEEDPATH)
CORETEMP=$(cat $CORETEMPPATH)
if [ $CORETEMP -gt 1000 ]; then
CORETEMP=$(expr $CORETEMP / 1000)
fi
DRIVETEMP=$(/sbin/hdparm -H $INTERNALDRIVES | sed -nr 's/[^0-9]*([0-9]+)/\1/p' | sort -r | head -n 1)
echo "$CORETEMP,CPU,$DRIVETEMP,HDD,$(/sbin/hdparm -C $INTERNALDRIVES | grep active | wc -l),ACT,$FANSPEED,FAN" | systemd-cat -t fancontrol -p info
}
function calcFanPercent {
TEMPRAN=$(expr $MAXTEMP - $MINTEMP)
TEMPREL=$(expr $CORETEMP - $MINTEMP)
TEMPPER=$(expr $TEMPREL \* 100 / $TEMPRAN)
NEWSPEED=$TEMPPER
TEMPRAN=$(expr $MAXTEMPD - $MINTEMPD)
TEMPREL=$(expr $DRIVETEMP - $MINTEMPD)
TEMPPER=$(expr $TEMPREL \* 100 / $TEMPRAN)
if [ $TEMPPER -gt $NEWSPEED ]; then
NEWSPEED=$TEMPPER
fi
}
function setFanSpeed {
if [ $NEWSPEED -lt $MINFAN ]; then
NEWSPEED=$MINFAN
fi
if [ $NEWSPEED -gt $MAXFAN ]; then
NEWSPEED=$MAXFAN
fi
NEWPWM=$(expr $MAXPWM - $MINPWM)
NEWPWM=$(expr $NEWPWM \* $NEWSPEED)
NEWPWM=$(expr $NEWPWM / 100)
NEWPWM=$(expr $NEWPWM + $MINPWM)
echo 1 > $FANPWMENABLE
echo $NEWPWM > $FANPWMPATH
}
function ensureFirewall {
if [ "$(/sbin/iptables -S | grep 'A INPUT -p tcp -m tcp --dport 22 -j ACCEPT')" = "" ]; then
/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 443 -j ACCEPT
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -P INPUT DROP
fi
}
###################
ensureFirewall
if [ "$1" != "" ]; then sleep "$1"; fi
systemctl stop apache2 apache2-safe readynasd radar dev-md1.swap
if ! cmp -s /etc/clamd.conf /etc/clamav/clamd.conf ; then
cp /etc/clamd.conf /etc/clamav/
systemctl restart clamav-daemon clamav-clamonacc
fi
while true
do
getReadings
calcFanPercent
setFanSpeed
ensureFirewall
sleep 10
done
###################
chmod +x /usr/sbin/noreadynas
A service to run the app above
/lib/systemd/system/noreadynas.service
[Unit]
After=readynasd.service
[Service]
ExecStartPre=/bin/sleep 15
ExecStart=/usr/sbin/noreadynas 300
ExecStop=/sbin/iptables -P INPUT ACCEPT
ExecStopPost=/bin/systemctl start readynasd apache2
Restart=always
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable noreadynas
Email on virus errors
/usr/sbin/clamsendmail
#!/bin/bash
echo -e "Subject: Virus Event $1\n$(journalctl | grep clamd | grep FOUND | tail -n 3)" | sendmail root
chmod +x /usr/sbin/clamsendmail
Because readynasd overwrites the clam config then copy and edit to be copied back as needed, main change is the self check and email sending but also swaping this to include paths so access prevention can be enabled
cp /etc/clamav/clamd.conf /etc/
/etc/clamd.conf
...
SelfCheck 86400
...
VirusEvent ... ; /usr/sbin/clamsendmail %v
...
# OnAccessMountPath
OnAccessIncludePath /root
OnAccessIncludePath /home/
OnAccessIncludePath /data/
OnAccessPrevention yes
OnAccessExtraScanning true
ExcludePath ^/var/lib/clamav/
ExcludePath ^/var/lib/clamav-unofficial-sigs/
ExcludePath ^/var/log/frontview/clamscan.log$
Because I dont want swap enabled then only raise with clam update then end after clam scan all around 5-6am
/lib/systemd/system/clamav-freshclam.service
ExecStartPre=/bin/systemctl start dev-md1.swap
/lib/systemd/system/antivirus-sched-scan.service
ExecStop=/bin/systemctl stop dev-md1.swap
Install vmtouch, wither from downloading from buster repo or from adding tbe repo to /etc/apt/sources.list and removing after
crontab -e
@reboot sleep 120 && /usr/bin/vmtouch -F /bin /dev /etc /lib* /opt /proc /run /sbin /sys /usr /var -i nfs4 -I snmpconf
54 4 * * * vmtouch -F /bin /dev /etc /lib* /opt /proc /run /sbin /sys /usr /var -i nfs4 -i snmpconf
15 6 * * * vmtouch -e /data/ && vmtouch -F /bin /dev /etc /lib* /opt /proc /run /sbin /sys /usr /var -i nfs4 -i snmpconf
Related Content
NETGEAR Academy
Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!