Scheduling Proxmox Storage to Reduce Disk Activity
This year I’ve been enjoying the use of Proxmox as a way to create & manage container & virtual environments for self-hosting my applications and scripts, while also providing a useful location to quickly spin-up development test environments.
To retain backups, I attach my local Synology NAS storage over SMB. There’s a nightly backup task within Proxmox to copy over container images. This was all easy to setup and has been rock-solid since setting it up at the start of the year.
I have found one negative of this approach though. The SMB connection from Proxmox to the NAS seems to query the storage every few seconds. This prevents the disks from ever sleeping, which therefore causes the NAS to consume more power, and it causes the NAS activity LEDs to constantly flash which makes it harder to identify potentially suspicious usage.
To work around these issues, I setup a couple of commands via cron to automatically enable and disable the storage at certain times of the day:
29 1 * * * /usr/sbin/pvesm set storage-name-here -disable 0
45 3 * * * /usr/sbin/pvesm set storage-name-here -disable 1
This is set via accessing the Proxmox host via the shell/ssh, then altering the root crontab
crontab -e, then add these lines to the bottom.
The first line enables the storage at 1:29am, and the second line disables it at 3:45am, leaving
a window between these times where the storage will be active to receive backups, otherwise inactive
for the rest of the day. My backups are scheduled to run at about 2am.
You’ll need to replace
storage-name-here with the unique storage id name shown in Proxmox.
Taking some rough readings from my UPS, allowing HDDs to hibernate seems to reduce power draw by about 10W, which should add up to a fair bit over a year. I’d also imagine that allowing the HDDs to rest most of the time may help their longevity.