Disks can not sleep

It's not really possible.

udisk2, pve smart checks, pve rrd graphs, etc. access them regularly.

In addition to that there are almost always services reading/writing files, updating access times etc.

Sleep also stresses them for lifespan it's better to let them run 24/7
 
Unfortunately the lvm.conf edit does not work at the lxc container
Also the:
blktrace -d /dev/sdc -o - | blkparse -i -
command does not work inside the lxc (does not find the device /dev/sdc)

When I run blktrace at the proxmox host I see the /dev/sdc accessed from kworker , jbd2 and loop0 (???)

I undertand that at an office environment maybe sleeping the disks is not so important and it is better
for the lifetime of the disks to be always on
BUT
To make the disks sleep is very important for me (and I think many others) since the disks will be used once or twice
a week for the backup. I do not want to pay the extra money for the electricity bill for nothing and I do not want to hear the disk
spinning day and night.
 
Last edited:
Unfortunately the lvm.conf edit does not work at the lxc container
Also the:
blktrace -d /dev/sdc -o - | blkparse -i -
command does not work inside the lxc (does not find the device /dev/sdc)

When I run blktrace at the proxmox host I see the /dev/sdc accessed from kworker , jbd2 and loop0 (???)

I undertand that at an office environment maybe sleeping the disks is not so important and it is better
for the lifetime of the disks
BUT
To make the disks sleep is very important for me (and I think many others) since the disks will be used once
a week for the backup. I do not want to pay the extra money for the electricity bill for nothing and I do not want to hear the disk
spinning day and night.

please edit "lvm.conf" at the host!
 
Maybe a way to bypass the problem would be to run the vm only when needed to run the backup so it would not keep my
disks spinning since it will be shutdown.

I tried to use the vzdump-hook-script.pl to auto start vm 100 at the start of the backup and auto shutdown the vm
at the end of the backup .
(added at /etc/vzdump.conf:
script: /usr/local/bin/vzdump-hook-script.pl
)

I could not find the vzdump-hook-script.pl that was mentioned at the documentantion so I downloaded one version from git.

Here is my script:

#!/usr/bin/perl -w

# Example hook script for vzdump (--script option)
# This can also be added as a line in /etc/vzdump.conf
# e.g. 'script: /usr/local/bin/vzdump-hook-script.pl'


use strict;

print "HOOK: " . join (' ', @ARGV) . "\n";

my $phase = shift;

if ($phase eq 'job-start' ||
$phase eq 'job-end' ||
$phase eq 'job-abort') {

my $dumpdir = $ENV{DUMPDIR};

my $storeid = $ENV{STOREID};

print "HOOK-ENV: dumpdir=$dumpdir;storeid=$storeid\n";

# do what you want
# example: copy resulting log file to another host using scp
if ($phase eq 'job-start') {
system ("/usr/sbin/pct start 100| sleep 60")
#== 0 ||
# die "pbs start failed";
}

if ($phase eq 'job-end') {
system ("sleep 2200 && /usr/sbin/pct shutdown 100")
#== 0 ||
# die "pbs start failed";
}

if ($phase eq 'job-abort') {
system ("sleep 2200 && /usr/sbin/pct shutdown 100")
}


} elsif ($phase eq 'backup-start' ||
$phase eq 'backup-end' ||
$phase eq 'backup-abort' ||
$phase eq 'log-end' ||
$phase eq 'pre-stop' ||
$phase eq 'pre-restart' ||
$phase eq 'post-restart') {

my $mode = shift; # stop/suspend/snapshot

my $vmid = shift;

my $vmtype = $ENV{VMTYPE}; # lxc/qemu

my $dumpdir = $ENV{DUMPDIR};

my $storeid = $ENV{STOREID};

my $hostname = $ENV{HOSTNAME};
# target is only available in phase 'backup-end'
my $target = $ENV{TARGET};

# logfile is only available in phase 'log-end'
my $logfile = $ENV{LOGFILE};

print "HOOK-ENV: vmtype=$vmtype;dumpdir=$dumpdir;storeid=$storeid;hostname=$hostname;target=$target;logfile=$logfile\n";


} else {

die "got unknown phase '$phase'";

}

exit (0);




The above script works for me
Only receive :
Use of uninitialized value $dumpdir in concatenation (.) or string at /usr/local/bin/vzdump-hook-script.pl line 22.
Use of uninitialized value $logfile in concatenation (.) or string at /usr/local/bin/vzdump-hook-script.pl line 69.

but the script works

I think temporarily is a workable hack till we find a way to enable disk sleep
I have put a sleep 2200 secs at end of backup before shutdown to let it enough time to do garbage collection,pruning,verify ( I have
scheduled to do it every 30min and verify next time 1 month).I hope the server will not try to do all these at the same time and overloads :)
 
Last edited:
I already have edited lvm.conf at the host and the disks sleep when I don't run the proxmox backup lxc.
When I start the lxc the DATASTORE disk stops sleeping.

i've tested and works for me.

Test setup:
  • Host:
    • 4 Disk - ZFS RaidZ-2​
    • /etc/lvm/lvm.conf: global_filter = [ "r|/dev/zd.*|", "r|/dev/mapper/pve-.*|", "r|/dev/mapper/.*-(vm|base)--[0-9]+--disk--[0-9]+|", "r|/dev/sda|", "r|/dev/sdb|", "r|/dev/sdc|", "r|/dev/sdd|", "r|/dev/sde|" ]​
    • /etc/hdparm.conf: /dev/disk/by-id/ata-Hitachi_HDS5C3020BLE630_ {
      spindown_time = 120
      }
      /dev/disk/by-id/ata-TOSHIBA_DT01ABA200_ {
      spindown_time = 120
      }
      /dev/disk/by-id/ata-Hitachi_HDS5C3020BLE630_{
      spindown_time = 120
      }
      /dev/disk/by-id/ata-TOSHIBA_DT01ABA200_ {
      spindown_time = 120
      }​
    • /etc/pve/lxc/123.conf: mp0: /storage/backups,mp=/mnt/backups​
  • PBS LXC Container (unprivileged):
    • Debian+PBS Install​
    • Datastore with: /mnt/backups​
PBS LXC Container Starting, Restarting, all 4 Disks stay asleep.
Code:
hdparm -C /dev/sd[abcd]
/dev/sda: drive state is: standby
/dev/sdb: drive state is: standby
/dev/sdc: drive state is: standby
/dev/sdd: drive state is: standby

Close the PBS GUI in Browser, this can wake up the disks!
 
Last edited:
  • Like
Reactions: mar_565

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!