PVE HDD Sleep (Suspend): Difference between revisions
m (Стадий: 6 [Фаза:Утвърждаване, Статус:Утвърден]; Категория:Proxmox) |
m (Text replacement - "mlw-continue" to "code-continue") |
||
(5 intermediate revisions by the same user not shown) | |||
Line 39: | Line 39: | ||
crontab -e | crontab -e | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="bash" line="1" start="25" class=" | <syntaxhighlight lang="bash" line="1" start="25" class="code-continue"> | ||
# Turn off HDDs | # Turn off HDDs | ||
*/30 * * * * /usr/local/bin/hdd-sleep.sh > /var/log/cron.hdd-sleep.log 2>&1 | */30 * * * * /usr/local/bin/hdd-sleep.sh > /var/log/cron.hdd-sleep.log 2>&1 | ||
Line 62: | Line 62: | ||
nano /etc/lvm/lvm.conf | nano /etc/lvm/lvm.conf | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<syntaxhighlight lang="bash" line="1" start="2303" class=" | <syntaxhighlight lang="bash" line="1" start="2303" class="code-continue"> | ||
devices { | devices { | ||
# added by pve-manager to avoid scanning ZFS zvols | # added by pve-manager to avoid scanning ZFS zvols | ||
Line 92: | Line 92: | ||
</syntaxhighlight><syntaxhighlight lang="shell" line="1" class="root-prompt"> | </syntaxhighlight><syntaxhighlight lang="shell" line="1" class="root-prompt"> | ||
dstat -D sdc -ta --top-bio | dstat -D sdc -ta --top-bio | ||
</syntaxhighlight><syntaxhighlight lang=" | </syntaxhighlight> | ||
----system---- --total-cpu-usage-- --dsk/sdc-- -net/total- ---paging-- ---system-- ----most-expensive---- | <syntaxhighlight lang="text" highlight="4"> | ||
time | ----system---------total-cpu-usage-------dsk/sdc------net/total------paging-------system--------most-expensive-------- | ||
02-04 09:25:42| 2 0 97 0 0| 160k | time | usr sys idl wai stl | read writ | recv send | in out | int csw | block i/o process | ||
02-04 09:25:43| 2 1 97 0 0| 0 | ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ | ||
02-04 09:25:44| 2 1 98 0 0| 0 | 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:45| 2 1 98 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:46| 3 1 96 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 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 | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 105: | Line 107: | ||
*Proxmox Forum: [https://forum.proxmox.com/threads/putting-hdd-to-sleep.62367/ Putting HDD to sleep] | *Proxmox Forum: [https://forum.proxmox.com/threads/putting-hdd-to-sleep.62367/ Putting HDD to sleep] | ||
*Proxmox Forum: [https://forum.proxmox.com/threads/disk-prevent-from-spinning-down-because-of-pvestatd.53237/ Disk prevent from spinning down because of pvestatd] | *Proxmox Forum: [https://forum.proxmox.com/threads/disk-prevent-from-spinning-down-because-of-pvestatd.53237/ Disk prevent from spinning down because of pvestatd] [<code>dstat</code>] | ||
*GitHub: [https://github.com/adelolmo/hd-idle Adelolmo/'''hd-idle'''] | *GitHub: [https://github.com/adelolmo/hd-idle Adelolmo/'''hd-idle'''] | ||
*RedHat Customer Portal: [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/lvm_filters Controlling LVM device scan with filters] | *RedHat Customer Portal: [https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/logical_volume_manager_administration/lvm_filters Controlling LVM device scan with filters] | ||
Line 112: | Line 114: | ||
*OSTechnix: [https://ostechnix.com/how-to-find-if-the-disk-is-ssd-or-hdd-in-linux/ How To Find If The Disk Is SSD Or HDD In Linux] | *OSTechnix: [https://ostechnix.com/how-to-find-if-the-disk-is-ssd-or-hdd-in-linux/ How To Find If The Disk Is SSD Or HDD In Linux] | ||
*Educba.com: [https://www.educba.com/bash-replace-string/ Bash Replace String] | *Educba.com: [https://www.educba.com/bash-replace-string/ Bash Replace String] | ||
*[[Linux I/O Monitoring and Analyze]] | |||
<noinclude> | <noinclude> | ||
<div id='devStage'> | <div id='devStage'> |
Latest revision as of 07:30, 26 September 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
- Linux I/O Monitoring and Analyze