{"id":16079,"date":"2026-10-09T16:12:22","date_gmt":"2026-10-09T14:12:22","guid":{"rendered":"https:\/\/monodes.com\/predaelli\/?p=16079"},"modified":"2026-10-09T16:12:24","modified_gmt":"2026-10-09T14:12:24","slug":"nas-with-autosuspend-wakeonlan-and-sshfs-automount","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2026\/10\/09\/nas-with-autosuspend-wakeonlan-and-sshfs-automount\/","title":{"rendered":"NAS with Autosuspend, WakeOnLAN and SSHFS Automount"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/blog.jklr.org\/2020\/05\/30\/nas-automation.html\">NAS with Autosuspend, WakeOnLAN and SSHFS Automount<\/a><\/p>\n\n\n\n<!--more-->\n\n\n\n<!--nextpage-->\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<h1 class=\"wp-block-heading\">NAS with Autosuspend, WakeOnLAN and SSHFS Automount<\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">May 30, 2020<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This post describes the setup of some convenient features that I deployed for the NAS, to automatically save power, make it wake up and mount it on the client only when needed.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Autosuspend<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Autosuspend is a nice tool to let a server suspend if it is idle (with configurable conditions). For Fedora there is no official package available, so I installed it from source:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>git clone https:\/\/github.com\/languitar\/autosuspend.git; cd autosuspend\npython3 setup.py install --prefix=\/usr\nmv \/usr\/local\/lib\/python3.7\/site-packages\/autosuspend-3.0.0.dev0-py3.7.egg\/etc\/* \/etc\nmv \/usr\/local\/lib\/python3.7\/site-packages\/autosuspend-3.0.0.dev0-py3.7.egg\/lib\/systemd\/system\/* \/usr\/local\/lib\/systemd\/system\/\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Starting with usual git clone and python module install, unfortunately the setup does not install the config and service files, so I had to move them manually afterwards.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Based on the default config this is resulting the <code>\/etc\/autosuspend.conf<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;general]\ninterval = 30\nidle_time = 900\nsuspend_cmd = \/usr\/bin\/systemctl suspend\nwakeup_cmd = sh -c 'echo 0 &gt; \/sys\/class\/rtc\/rtc0\/wakealarm &amp;&amp; echo {timestamp:.0f} &gt; \/sys\/class\/rtc\/rtc0\/wakealarm'\nwoke_up_file = \/var\/run\/autosuspend-just-woke-up\nlock_file = \/var\/lock\/autosuspend.lock\nlock_timeout = 30\n\n# This will use the Users check with the custom name RemoteUsers.\n# Custom names are necessary in case a check class is used multiple times.\n# Custom names can also be used for clarification.\n&#91;check.RemoteUsers]\nclass = Users\nenabled = true\nname = .*\nterminal = .*\nhost = &#91;0-9].*\n\n# Custom\n&#91;check.SSH]\nclass = ActiveConnection\nports = 22\nenabled = true\n\n&#91;check.NetworkBandwidth]\nenabled = true\ninterfaces = eno1\nthreshold_send = 200\nthreshold_receive = 400\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Three checks are enabled here, RemoteUser checks is someone is currently logged in over ssh, the ActiveConnection check on port 22 will reliably detect SSHFS connections. Also if there are other services causing some bandwidth usage it will detect it and not suspend with the last check.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After starting\/enabling with <code>systemctl enable --now autosuspend.service<\/code> it should look like this in <code>systemctl status autosuspend.service<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u25cf autosuspend.service - A daemon to suspend your server in case of inactivity\n   Loaded: loaded (\/etc\/systemd\/system\/autosuspend.service; disabled; vendor preset: disabled)\n   Active: active (running) since Fri 2020-05-15 12:23:19 CEST; 8h ago\n     Docs: https:\/\/autosuspend.readthedocs.io\/en\/latest\/systemd_integration.html\n Main PID: 1348 (autosuspend)\n    Tasks: 1 (limit: 4536)\n   Memory: 15.4M\n   CGroup: \/system.slice\/autosuspend.service\n           \u2514\u25001348 \/usr\/bin\/python3 \/usr\/bin\/autosuspend -l \/etc\/autosuspend-logging.conf daemon\n\nMay 15 20:50:50 nas-server autosuspend&#91;1348]: 2020-05-15 20:50:50,740 - autosuspend.Processor - INFO - Starting new check iteration\nMay 15 20:50:50 nas-server autosuspend&#91;1348]: 2020-05-15 20:50:50,752 - autosuspend.Processor - INFO - Check SSH matched. Reason: Ports &#91;22] are connected\nMay 15 20:50:50 nas-server autosuspend&#91;1348]: 2020-05-15 20:50:50,753 - autosuspend.Processor - INFO - System is active. Resetting state\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here we see that it currently detects the SSH connection and does not suspend when I am logged in.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Wake On LAN<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First make sure WOL is set up on the server and works from the client with <code>wol xx:xx:xx:xx:xx:xx<\/code> using the MAC address of the server. This usually has to be enabled in the BIOS and might also need some software, read more <a href=\"https:\/\/wiki.archlinux.org\/index.php\/Wake-on-LAN\">here<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we want the client to wake up the server automatically. I searched for some guidance and found <a href=\"https:\/\/rolandtapken.de\/blog\/2017-02\/how-wake-lan-remote-host-demand-using-systemds-sockets\">this blog post<\/a>, he used a custom socket that triggers WOL on connection. It works, but I observed reduced performance with this approach: instead of &gt;900 Mbit\/s it delivered only about 300 Mbit\/s, because all data must go through netcat and the local socket.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I came up with a solution where the data does not get intercepted and therefore does not impact the performance. For that an extra systemd service is running to check if the server is already up and if not sends the WOL packet. For example on ArchLinux custom services should be placed into <code>\/etc\/systemd\/system<\/code>, I created there a <code>nas-online.service<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=Continuously check if the host is up, otherwise try WOL on start\nAfter=network.target network-online.target\nPartOf=mnt.mount\n\n&#91;Service]\nEnvironment=HOST=nas-server\nEnvironment=PORT=22\nEnvironment=MAC=xx:xx:xx:xx:xx:xx\n\nExecStartPre=\/bin\/sh -c 'for n in `seq 1 6`; do nc -z ${HOST} ${PORT} &amp;&amp; break || wol $MAC &amp;&amp; sleep 10; done'\nExecStart=\/bin\/sh -c 'while :; do (nc -z -w 1s ${HOST} ${PORT} &amp;&amp; echo \"Host is up!\" &amp;&amp; sleep 30) || break; done'\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In the [Unit] section it is defined as PartOf <code>mnt.mount<\/code> (which we will create in the next section), this makes systemd propagate start\/stop commands from the mount to this unit. The [Service] contains 2 small shell scripts. Pre start runs a maximum of 6 times a loop where it checks with <code>nc -z<\/code> (netcat zero IO) if the target is up, otherwise it sends the WOL packet and waits 10 secs. Then the main script just check every 30 secs if the target is still online and logs it. Per default this runs indefinitely, but as described above it does get stopped if <code>mnt.mount<\/code> gets inactive.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Test it with <code>systemctl start nas-online.service<\/code>, <code>systemctl stop nas-online.service<\/code> and <code>systemctl status nas-online.service<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>* nas-online.service - Continuously check if host is up, otherwise try WOL on start\n     Loaded: loaded (\/etc\/systemd\/system\/nas-online.service; static; vendor preset: disabled)\n     Active: inactive (dead) since Sat 2020-05-30 16:06:16 CEST; 4min 3s ago\n    Process: 3589 ExecStartPre=\/bin\/sh -c for n in `seq 1 6`; do nc -z ${HOST} ${PORT} &amp;&amp; break || wol $MAC &amp;&amp; sleep 10; done (code=exited, status=0\/SUCCESS)\n    Process: 3768 ExecStart=\/bin\/sh -c while :; do (nc -z -w 1s ${HOST} ${PORT} &amp;&amp; echo \"Host is up!\" &amp;&amp; sleep 30) || break; done (code=killed, signal=TERM)\n   Main PID: 3768 (code=killed, signal=TERM)\n\nMay 30 16:05:01 pc-arch systemd&#91;1]: Starting Continuously check if host is up, otherwise try WOL on start...\nMay 30 16:05:04 pc-arch sh&#91;3617]: Waking up xx:xx:xx:xx:xx:xx...\nMay 30 16:05:14 pc-arch systemd&#91;1]: Started Continuously check if host is up, otherwise try WOL on start.\nMay 30 16:05:14 pc-arch sh&#91;3774]: Host is up!\nMay 30 16:05:44 pc-arch sh&#91;4140]: Host is up!\nMay 30 16:06:15 pc-arch sh&#91;4198]: Host is up!\nMay 30 16:06:16 pc-arch systemd&#91;1]: Stopping Continuously check if host is up, otherwise try WOL on start...\nMay 30 16:06:16 pc-arch systemd&#91;1]: nas-online.service: Succeeded.\nMay 30 16:06:16 pc-arch systemd&#91;1]: Stopped Continuously check if host is up, otherwise try WOL on start.\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Automount<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The Systemd automount feature can automatically mount it when an access to the mountpoint is detected and unmount if it was idle for a specified time.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First it is important to login as root with SSH and accept the fingerprint for the server, otherwise it will not work because it is not in the known hosts list (like describe <a href=\"https:\/\/wiki.archlinux.org\/index.php\/SSHFS\">here<\/a>):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo -i\nssh -p 2222 jk@nas-server\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Also it is of course not possible to enter a password, so make sure pubkey authentication is properly configured on the server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then an mount entry in <code>\/etc\/fstab<\/code> can be added:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>jk@nas-server:\/mnt   \/mnt    fuse.sshfs  noauto,x-systemd.requires=nas-online.service,identityfile=\/home\/jk\/.ssh\/nas_ed25519,user,allow_other,default_permissions  0 0\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Here we need a few options:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><em>noauto:<\/em> Disable direct mount on boot<\/li>\n\n\n\n<li><em>x-systemd.requires=:<\/em> Require online check\/WOL to start<\/li>\n\n\n\n<li><em>identityfile=:<\/em> Specify the SSH keys, it will run as root and does not read the user ssh config<\/li>\n\n\n\n<li><em>user:<\/em> Allow user to mount\/unmount<\/li>\n\n\n\n<li><em>allow_other:<\/em> Allow other users (than root) to access<\/li>\n\n\n\n<li><em>default_permissions:<\/em> Use permissions from the server<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>systemd-fstab-generator<\/code> will automatically produce an unit for the mountpoint, in this case <code>mnt.mount<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we need another unit: <code>mnt.automount<\/code> with the simple content:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Automount]\nWhere=\/mnt\nTimeoutIdleSec=60\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>Where<\/code> just specifies the mountpoint, also the filename must match the mount unit filename, which is based on the path. <code>TimeoutIdleSec<\/code> enables the automatic unmount, if it was idle for at least 60 secs in this case, you might want to set this higher.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note: With the <em>x-systemd.automount<\/em> fstab option the generator could also create the automount.service, but then the requires is applied to the automount and that would wake up the NAS always at the boot. We want to have it on the mount, because that wakes up the NAS only if it is actually mounted\/used.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Finally start and enable it with <code>systemctl enable --now mnt.automount<\/code>. On any access to <code>\/mnt<\/code> the automount will trigger the mount.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can see if it triggered with <code>systemctl status mnt.automount<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u25cf mnt.automount\n     Loaded: loaded (\/etc\/fstab; generated)\n     Active: active (running) since Fri 2020-05-15 19:49:22 CEST; 28min ago\n   Triggers: \u25cf mnt.mount\n      Where: \/mnt\n       Docs: man:fstab(5)\n             man:systemd-fstab-generator(8)\n\nMai 15 19:49:22 pc-arch systemd&#91;1]: Set up automount mnt.automount.\nMai 15 19:49:27 pc-arch systemd&#91;1]: mnt.automount: Got automount request for \/mnt, triggered by 55768 (dolphin)\nMai 15 20:02:14 pc-arch systemd&#91;1]: mnt.automount: Got automount request for \/mnt, triggered by 59368 (nvim)\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">and <code>systemctl status mnt.mount<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u25cf mnt.mount - \/mnt\n     Loaded: loaded (\/etc\/fstab; generated)\n     Active: active (mounted) since Fri 2020-05-15 20:30:41 CEST; 9min ago\nTriggeredBy: \u25cf mnt.automount\n      Where: \/mnt\n       What: jk@localhost:\/mnt\n       Docs: man:fstab(5)\n             man:systemd-fstab-generator(8)\n      Tasks: 7 (limit: 19042)\n     Memory: 2.3M\n     CGroup: \/system.slice\/mnt.mount\n             \u251c\u250061440 ssh -x -a -oClearAllForwardings=yes -oport=2222 -oidentityfile=\/home\/jk\/.ssh\/nas_ed25519 -2 jk@localhost -s sftp\n             \u2514\u250061448 \/usr\/bin\/mount.fuse.sshfs jk@localhost:\/mnt \/mnt -o rw,noexec,nosuid,nodev,port=2222,identityfile=\/home\/jk\/.ssh\/nas_ed25519,allow_other,default_permissions,user\n\nMai 15 20:30:40 pc-arch systemd&#91;1]: Mounting \/mnt...\nMai 15 20:30:41 pc-arch systemd&#91;1]: Mounted \/mnt.\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">I hope it was helpful, let me know if it worked in the comments!<\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">NAS with Autosuspend, WakeOnLAN and SSHFS Automount<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2026\/10\/09\/nas-with-autosuspend-wakeonlan-and-sshfs-automount\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"federated","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[72,278],"tags":[],"class_list":["post-16079","post","type-post","status-publish","format-standard","hentry","category-documentations","category-tricks"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-4bl","jetpack-related-posts":[{"id":13892,"url":"https:\/\/monodes.com\/predaelli\/2025\/08\/20\/beelink-me-mini-6-slot-home-storage-nas-mini-pc\/","url_meta":{"origin":16079,"position":0},"title":"Beelink ME mini 6-slot Home Storage NAS Mini PC","author":"Paolo Redaelli","date":"2025-08-20","format":false,"excerpt":"Beelink | Beelink ME mini 6-slot Home Storage NAS Mini PC I think I've found my next NAS!","rel":"","context":"In &quot;Hardware&quot;","block_context":{"text":"Hardware","link":"https:\/\/monodes.com\/predaelli\/category\/hardware\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":11589,"url":"https:\/\/monodes.com\/predaelli\/2024\/04\/10\/cwwk-nas-mini-itx-motherboard-features-six-sata-connectors-three-2-5gbps-ethernet-ports-cnx-software\/","url_meta":{"origin":16079,"position":1},"title":"CWWK NAS mini-ITX motherboard features six SATA connectors, three 2.5Gbps Ethernet ports &#8211; CNX Software","author":"Paolo Redaelli","date":"2024-04-10","format":"quote","excerpt":"Source: CWWK NAS mini-ITX motherboard features six SATA connectors, three 2.5Gbps Ethernet ports - CNX Software","rel":"","context":"In &quot;Hardware&quot;","block_context":{"text":"Hardware","link":"https:\/\/monodes.com\/predaelli\/category\/hardware\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8934,"url":"https:\/\/monodes.com\/predaelli\/2021\/11\/20\/the-wiretrustee-sata-pi-board-is-a-true-sata-nas-jeff-geerling\/","url_meta":{"origin":16079,"position":2},"title":"The Wiretrustee SATA Pi Board is a true SATA NAS | Jeff Geerling","author":"Paolo Redaelli","date":"2021-11-20","format":"link","excerpt":"Source: The Wiretrustee SATA Pi Board is a true SATA NAS | Jeff Geerling","rel":"","context":"In &quot;Hardware&quot;","block_context":{"text":"Hardware","link":"https:\/\/monodes.com\/predaelli\/category\/hardware\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":11577,"url":"https:\/\/monodes.com\/predaelli\/2024\/04\/07\/the-ultimate-raspberry-pi-5-nas-youtube\/","url_meta":{"origin":16079,"position":3},"title":"The ULTIMATE Raspberry Pi 5 NAS &#8211; YouTube","author":"Paolo Redaelli","date":"2024-04-07","format":"video","excerpt":"","rel":"","context":"In &quot;Hardware&quot;","block_context":{"text":"Hardware","link":"https:\/\/monodes.com\/predaelli\/category\/hardware\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":13127,"url":"https:\/\/monodes.com\/predaelli\/2025\/04\/17\/it-will-not-be-a-synology\/","url_meta":{"origin":16079,"position":4},"title":"It will not be a Synology!","author":"Paolo Redaelli","date":"2025-04-17","format":false,"excerpt":"Synology Locks Key NAS Features Behind Proprietary Drive Requirement Dear Synology\u2026 I'm going to buy a NAS. Now I'm sure it will not be a Synology! Synology Locks Key NAS Features Behind Proprietary Drive Requirement (tomshardware.com) 38 Synology's upcoming Plus Series NAS systems will restrict full functionality to users who\u2026","rel":"","context":"In &quot;Ethics&quot;","block_context":{"text":"Ethics","link":"https:\/\/monodes.com\/predaelli\/category\/ethics\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7185,"url":"https:\/\/monodes.com\/predaelli\/2020\/05\/07\/nas-performance-nfs-vs-smb-vs-sshfs-jakes-blog\/","url_meta":{"origin":16079,"position":5},"title":"NAS Performance: NFS vs. SMB vs. SSHFS | Jake\u2019s Blog","author":"Paolo Redaelli","date":"2020-05-07","format":"link","excerpt":"NAS Performance: NFS vs. SMB vs. SSHFS | Jake\u2019s Blog In trusted home networks NFS without encryption is the best choice on Linux for maximum performance. If you want encryption i would recommend SSHFS, it is a much simpler setup (compared to Kerberos), more cpu efficient and often only slightly\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/16079","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=16079"}],"version-history":[{"count":1,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/16079\/revisions"}],"predecessor-version":[{"id":16080,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/16079\/revisions\/16080"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=16079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=16079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=16079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}