PVE HDD Sleep (Suspend): Difference between revisions
Line 93: | Line 93: | ||
dstat -D sdc -ta --top-bio | dstat -D sdc -ta --top-bio | ||
</syntaxhighlight><syntaxhighlight lang="shell-session"> | </syntaxhighlight><syntaxhighlight lang="shell-session"> | ||
----system---- --total-cpu-usage-- --dsk/sdc-- -net/total- ---paging-- ---system-- ----most-expensive---- | ----system---------total-cpu-usage-------dsk/sdc------net/total------paging-------system--------most-expensive-------- | ||
time | time | usr sys idl wai stl | read writ | recv send | in out | int csw | block i/o process | ||
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | |||
02-04 09:25:42| 2 0 97 0 0| 160k | 02-04 09:25:42 | 2 0 97 0 0 | 160k 208k | 0 0 | 170B 835B | 1951 7955 | systemd 1285k 1569k | ||
02-04 09:25:43| 2 1 97 0 0| 0 | 02-04 09:25:43 | 2 1 97 0 0 | 0 0 | 66k 57k | 0 0 | 2614 5033 | pvestatd 1280k 0 | ||
02-04 09:25:44| 2 1 98 0 0| 0 | 02-04 09:25:44 | 2 1 98 0 0 | 0 0 | 16k 21k | 0 0 | 2830 7131 | kvm 0 32k | ||
02-04 09:25:45| 2 1 98 0 0| 0 | 02-04 09:25:45 | 2 1 98 0 0 | 0 0 | 45k 54k | 0 0 | 2347 5187 | kvm 0 320k | ||
02-04 09:25:46| 3 1 96 0 0| 0 | 02-04 09:25:46 | 3 1 96 0 0 | 0 0 | 24k 29k | 0 0 | 2686 8578 | ceph-mon 0 64k | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 21:07, 28 August 2022
In order to force HDDs to sin down when they are idle at my system I was perfumed few steps. Note at the system The HDDs are used only for media and backup files, so all LVM partitions (where the virtual machines and containers are located) are on SSDs and pvscan
doesn't need to touch them.
Setup Homemade Script
The first attempt was by a homemade script. This approach have a particular success (because pvscan
must be setup as it is shown below) and it is not the most proper way to push the HDDs to sleep (because it the script is triggered by Cron and doen't check does the drive is actually in use). However the script detects which of the attached storage devices are HDDs properly.
nano /usr/local/bin/hdd-sleep.sh
#!/bin/bash
# @author: Spas Z. Spasov <spas.z.spasov@metalevel.tech>
# @name: hdd-sleep.sh
# @decription: Detect the HDDs on the system and push them to sleep.
main() {
for sdX in /sys/block/sd*
do
if [[ $(cat "${sdX}/queue/rotational") == 1 ]]
then
sdX="${sdX//sys\/block/dev}"
echo -n "Device:"
if /usr/sbin/hdparm -C "$sdX" | grep -q 'active'
then
/usr/sbin/hdparm -y "$sdX"
else
/usr/sbin/hdparm -C "$sdX"
fi
echo ''
fi
done
echo 'OK'
}
main #>/dev/null 2>&1
crontab -e
# Turn off HDDs
*/30 * * * * /usr/local/bin/hdd-sleep.sh > /var/log/cron.hdd-sleep.log 2>&1
watch cat /var/log/cron.hdd-sleep.log
man hdparm
: Get/Set SATA/IDE device parameters.
sudo hdparm -B /dev/sda # Get SSD AMP level
sudo hdparm -B 127 /dev/sda # SET SSD AMP level
sudo hdparm -t /dev/sda # SSD Timing buffered disk reads
sudo hdparm -t --direct /dev/sd # SSD Timing buffered disk reads direct
sudo hdparm -S 1 /dev/sdb /dev/sdc /dev/sdd # Set multiple devices to sleep
Setup Proxmox Vgscan/Pvestatd
nano /etc/lvm/lvm.conf
devices {
# added by pve-manager to avoid scanning ZFS zvols
# global_filter=["r|/dev/zd.*|"]
# added by Spas Z. Spasov
global_filter=["r|/dev/zd.*|", "r|/dev/sdc.*|", "r|/dev/sdd.*|", "r|/dev/sdf.*|", "r|/dev/sdg.*|", "r|/dev/sdh.*|"]
}
vgscan
Install and Setup Hd-idle
wget https://github.com/adelolmo/hd-idle/releases/download/v1.16/hd-idle_1.16_amd64.deb
dpkg -i hd-idle_1.16_amd64.deb
nano /etc/default/hd-idle
#START_HD_IDLE=false
START_HD_IDLE=true
#HD_IDLE_OPTS="-i 180 -l /var/log/hd-idle.log"
HD_IDLE_OPTS="-i 60 -l /var/log/hd-idle.log"
The same steps are done at the gust virtual machines, which have direct access to the HDDs.
Get Statistic of a Data Drive Usage
apt install dstat
dstat -D sdc -ta --top-bio
----system---------total-cpu-usage-------dsk/sdc------net/total------paging-------system--------most-expensive--------
time | usr sys idl wai stl | read writ | recv send | in out | int csw | block i/o process
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
02-04 09:25:42 | 2 0 97 0 0 | 160k 208k | 0 0 | 170B 835B | 1951 7955 | systemd 1285k 1569k
02-04 09:25:43 | 2 1 97 0 0 | 0 0 | 66k 57k | 0 0 | 2614 5033 | pvestatd 1280k 0
02-04 09:25:44 | 2 1 98 0 0 | 0 0 | 16k 21k | 0 0 | 2830 7131 | kvm 0 32k
02-04 09:25:45 | 2 1 98 0 0 | 0 0 | 45k 54k | 0 0 | 2347 5187 | kvm 0 320k
02-04 09:25:46 | 3 1 96 0 0 | 0 0 | 24k 29k | 0 0 | 2686 8578 | ceph-mon 0 64k
References
- Proxmox Forum: Putting HDD to sleep
- Proxmox Forum: Disk prevent from spinning down because of pvestatd [
dstat
] - GitHub: Adelolmo/hd-idle
- RedHat Customer Portal: Controlling LVM device scan with filters
- Linux and Unix: Edit
/etc/lvm/lvm.conf
and add a new global filter - Ask Ubuntu: How to turn off hard drive in Ubuntu?
- OSTechnix: How To Find If The Disk Is SSD Or HDD In Linux
- Educba.com: Bash Replace String
- I/O Monitoring and Analyze