You are not logged in.
I have a headless NAS with BTRFS.
I want to simply hard cut power supply with the switching socket after work.
But of course I don't want the BTRFS get damaged :-)
The idea is:
Put the BTRFS into ro on inactivity.
sudo mount -o remount,ro ...Put it back to rw when needed.
sudo mount -o remount,rw ...Users use ssh, sftp, rsync over ssh, these should be the trigger.
The NAS is used only occasionally, most time it's idle and has no remote users connected.
Is this idea feasible?
What are the options to check for inactivity/activity?
Thanks very much!
Last edited by ua4000 (2019-03-06 17:23:46)
Offline
Hello there,
Why would you want to turn off the NAS?
Regards
Offline
Energy Saving !
Preventive fire protection !
While I'm sleeping or during day at the office the NAS is unused.
Offline
It is not really safe to pull the plug even with the fs in ro mode, power down the nas before you pull the plug. Or just have the nas suspend and don't pull the plug?
Last edited by Mr.Elendig (2019-03-02 08:15:56)
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
The NAS is a self made arch box, the hardware is not entirely suspend capable.
Also suspend won't solve all my points at #3.
Last edited by ua4000 (2019-03-02 08:19:54)
Offline
I'm sure you could hack a shell script that would do this but I don't see why.... just spin down the HDDs for power savings. Fire prevention?? Never heard of NAS catching fire.
Offline
https://www.ksta.de/wohnhaus-laptop-ver … d-12277502
All power supplies could break down, overheat and cause a fire.
Back to my topic:
I think I can use the sshd pam, like I found here :
https://wiki.archlinux.org/index.php/Dm … g_at_login
as trigger for switching to rw mode.
And for switching to ro mode I could use a timer, checking every minute the ps -eaf output.
Any better ideas ?
Offline
This will state the number of remote ssh users:
users() {
ps -eaf | egrep -i ' sshd: ' | egrep -v ' grep ' | wc --lines
}If it's 0 a periodic systemd timer can put the system into ro mode.
And this one will set rw mode on remote logins:
# sudoedit /etc/pam.d/system-remote-login
session optional pam_exec.so quiet /usr/local/sbin/s-rw rwBetter ideas are still welcome.
Offline