HDD spinning down on battery

Hi,

I just got a HP Probook 650 G5, and installed Opensuse leap 15.6 with KDE.
Stuff is mostly working fine, but the HDD I installed keeps spinning down when the laptop charger is unplugged. The HDD is a Seagate 2TB driver. (ST2000LM015-2E8174)

Journal log when unplugging the charger, waiting for the drive to spin down and plugging back the power:

Nov 13 17:49:39 localhost plasmashell[1937]: plasma-pk-updates: acPluggedChanged onBattery: false -> true
Nov 13 17:49:39 localhost plasmashell[1937]: plasma-pk-updates: Is on battery: true
Nov 13 17:49:57 localhost kernel: sd 0:0:0:0: [sda] Synchronizing SCSI cache
Nov 13 17:49:57 localhost kernel: sd 0:0:0:0: [sda] Stopping disk
Nov 13 17:49:58 localhost kernel: ata1.00: Entering standby power mode
Nov 13 17:50:05 localhost kernel: ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
Nov 13 17:50:05 localhost kernel: ata1.00: Entering active power mode
Nov 13 17:50:07 localhost kernel: ata1.00: ACPI cmd f5/00:00:00:00:00:e0(SECURITY FREEZE LOCK) filtered out
Nov 13 17:50:07 localhost kernel: ata1.00: ACPI cmd b1/c1:00:00:00:00:e0(DEVICE CONFIGURATION OVERLAY) filtered out
Nov 13 17:50:08 localhost kernel: ata1.00: ACPI cmd f5/00:00:00:00:00:e0(SECURITY FREEZE LOCK) filtered out
Nov 13 17:50:08 localhost kernel: ata1.00: ACPI cmd b1/c1:00:00:00:00:e0(DEVICE CONFIGURATION OVERLAY) filtered out
Nov 13 17:50:08 localhost kernel: ata1.00: configured for UDMA/133
Nov 13 17:50:08 localhost kernel: ata2: SATA link down (SStatus 4 SControl 300)
Nov 13 17:50:08 localhost kernel: sd 0:0:0:0: [sda] Starting disk
Nov 13 17:50:08 localhost plasmashell[1937]: plasma-pk-updates: acPluggedChanged onBattery: true -> false
Nov 13 17:50:08 localhost plasmashell[1937]: plasma-pk-updates: Is on battery: false

I’d like to disable this “power saving feature”, because it is annoying when every 15-20 seconds, the hdd spins down.

I tried hdparm.
hdparm -B 255 /dev/sda - issue still the same
hdparm -B 254 /dev/sda - issue still the same
hdparm -S 0 /dev/sda - issue still the same
hdparm -Z /dev/sda - runs into error: SG_IO: bad/missing sense data

Tried uninstalling “patterns-desktop-mobile” package. I found this suggestion somewhere. But the issue is still the same.

I also looked where I thought I could change any settings, but there are no options for HDD spin down timer.

Thank you very much in advance for any help.

No, it is not HDD. It is kernel that decides to power off the device.

This is pattern. Uninstalling pattern does not remove any package that was installed by this pattern, so it is entirely useless for your purpose. You need to find out what causes this aggressive power saving. Providing full logs may give some hints.

E.g. TLP has AHCI_RUNTIME_PM_ON_BAT setting that powers down idle devices.

Thank you very much for the input.
Could you please let me know what you mean by “full log”?

I just tried tlp without any luck.

Added into /etc/tlp.conf:

TLP_ENABLE=1
DISK_DEVICES=“sda”
DISK_APM_LEVEL_ON_BAT=“255”

issued the command “tlp start”
pulled out the power, went into battery mode, and in 15 seconds, the hdd entered power save mode again

but I found where I can modify manually
The file:
/sys/block/sda/device/power/autosuspend_delay_ms
has the actual timeout after which the hdd enters power saving mode
unfortunately, whenever there’s a switch between AC and battery power, this file gets overwritten

So I’m still trying to figure out what you suggested, the actual process that is modifying this file.

It is better to use SSD for OS:

Post

inxi -aFmz

to avoid incompatibilities.

Hi,

The OS itself is on an nvme SSD. The HDD that is going to sleep quiet agressively is a secondary SATA drive.

TVLaptop-PC:~ # inxi -aFmz
System:
  Kernel: 6.4.0-150600.23.25-default arch: x86_64 bits: 64 compiler: gcc v: 7.5.0
    parameters: BOOT_IMAGE=/boot/vmlinuz-6.4.0-150600.23.25-default
    root=UUID=52e0fb15-505a-4912-ac84-774d43102d11 splash=silent
    resume=/dev/disk/by-uuid/676735b6-5e2e-4e43-aeb6-b396a3c7e336 preempt=full quiet
    security=apparmor mitigations=auto
  Console: pty pts/2 DM: SDDM Distro: openSUSE Leap 15.6
Machine:
  Type: Laptop System: HP product: HP ProBook 650 G5 v: SBKPF serial: <filter> Chassis: type: 10
    serial: <filter>
  Mobo: HP model: 856E v: KBC Version 54.4A.00 serial: <filter> UEFI-[Legacy]: HP
    v: R72 Ver. 01.29.01 date: 08/28/2024
Battery:
  ID-1: BAT0 charge: 33.7 Wh (94.4%) condition: 35.7/48.0 Wh (74.3%) volts: 12.2 min: 11.4
    model: Hewlett-Packard Primary type: Li-ion serial: <filter> status: not charging cycles: 22
  Device-1: hidpp_battery_0 model: Logitech Wireless Touch Keyboard K400 serial: <filter>
    charge: 55% (should be ignored) rechargeable: yes status: discharging
Memory:
  System RAM: available: 14.85 GiB used: 3.11 GiB (20.9%)
  Array-1: capacity: 32 GiB slots: 2 EC: None max-module-size: 16 GiB note: est.
  Device-1: Bottom-Slot 2(under) type: DDR4 detail: synchronous size: 16 GiB speed:
    spec: 2667 MT/s actual: 2400 MT/s volts: curr: 1.2 width (bits): data: 64 total: 64
    manufacturer: Hynix/Hyundai part-no: HMA82GS6CJR8N-VK serial: <filter>
  Device-2: Bottom-Slot 1(top) type: no module installed
CPU:
  Info: model: Intel Core i5-8365U socket: BGA1528 (U3E1) note: check bits: 64 type: MT MCP
    arch: Comet/Whiskey Lake note: check gen: core 8 level: v3 note: check built: 2018
    process: Intel 14nm family: 6 model-id: 0x8E (142) stepping: 0xC (12) microcode: 0xFC
  Topology: cpus: 1x cores: 4 tpc: 2 threads: 8 smt: enabled cache: L1: 256 KiB
    desc: d-4x32 KiB; i-4x32 KiB L2: 1024 KiB desc: 4x256 KiB L3: 6 MiB desc: 1x6 MiB
  Speed (MHz): avg: 862 high: 4099 min/max: 400/4100 base/boost: 1485/4100 scaling:
    driver: intel_pstate governor: performance volts: 0.6 V ext-clock: 100 MHz cores: 1: 400 2: 400
    3: 400 4: 400 5: 400 6: 4099 7: 400 8: 400 bogomips: 30399
  Flags: avx avx2 ht lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  Vulnerabilities:
  Type: gather_data_sampling mitigation: Microcode
  Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf status: Not affected
  Type: mds status: Not affected
  Type: meltdown status: Not affected
  Type: mmio_stale_data mitigation: Clear CPU buffers; SMT vulnerable
  Type: reg_file_data_sampling status: Not affected
  Type: retbleed mitigation: Enhanced IBRS
  Type: spec_rstack_overflow status: Not affected
  Type: spec_store_bypass mitigation: Speculative Store Bypass disabled via prctl
  Type: spectre_v1 mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Enhanced / Automatic IBRS; IBPB: conditional; RSB filling;
    PBRSB-eIBRS: SW sequence; BHI: SW loop, KVM: SW loop
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort mitigation: TSX disabled
Graphics:
  Device-1: Intel WhiskeyLake-U GT2 [UHD Graphics 620] vendor: Hewlett-Packard driver: i915
    v: kernel arch: Gen-9.5 process: Intel 14nm built: 2016-20 ports: active: HDMI-A-1 off: eDP-1
    empty: DP-1,DP-2,HDMI-A-2 bus-ID: 00:02.0 chip-ID: 8086:3ea0 class-ID: 0300
  Device-2: Quanta HP HD Camera driver: uvcvideo type: USB rev: 2.0 speed: 480 Mb/s lanes: 1
    mode: 2.0 bus-ID: 1-9:5 chip-ID: 0408:5373 class-ID: 0e02 serial: <filter>
  Display: server: X.org v: 1.21.1.11 with: Xwayland v: 24.1.1 compositor: kwin_x11 driver: X:
    loaded: modesetting unloaded: fbdev,vesa alternate: intel dri: iris gpu: i915 tty: 270x64
  Monitor-1: HDMI-A-1 model: Philips FTV serial: <filter> built: 2019 res: 1920x1080 dpi: 34
    gamma: 1.2 size: 1440x810mm (56.69x31.89") diag: 1652mm (65") ratio: 16:9 modes: max: 1920x1080
    min: 640x480
  Monitor-2: eDP-1 model: Najing CEC Panda 0x0040 built: 2018 res: 1920x1080 dpi: 142 gamma: 1.2
    size: 344x194mm (13.54x7.64") diag: 395mm (15.5") ratio: 16:9 modes: 1920x1080
  API: OpenGL Message: GL data unavailable in console for root.
Audio:
  Device-1: Intel Cannon Point-LP High Definition Audio vendor: Hewlett-Packard
    driver: snd_hda_intel v: kernel alternate: snd_soc_skl,snd_sof_pci_intel_cnl bus-ID: 00:1f.3
    chip-ID: 8086:9dc8 class-ID: 0403
  API: ALSA v: k6.4.0-150600.23.25-default status: kernel-api with: aoss type: oss-emulator
    tools: alsactl,alsamixer,amixer
  Server-1: PipeWire v: 1.0.5 status: n/a (root, process) with: 1: wireplumber status: active
    2: pw-jack type: plugin tools: pw-cat,pw-cli,wpctl
  Server-2: PulseAudio v: 17.0 status: active (root, process) with: pulseaudio-alsa type: plugin
    tools: pacat,pactl
Network:
  Device-1: Intel Cannon Point-LP CNVi [Wireless-AC] driver: iwlwifi v: kernel bus-ID: 00:14.3
    chip-ID: 8086:9df0 class-ID: 0280
  IF: wlan0 state: down mac: <filter>
  Device-2: Intel Ethernet I219-LM vendor: Hewlett-Packard driver: e1000e v: kernel port: N/A
    bus-ID: 00:1f.6 chip-ID: 8086:15bd class-ID: 0200
  IF: eth0 state: up speed: 1000 Mbps duplex: full mac: <filter>
Bluetooth:
  Device-1: Intel Bluetooth 9460/9560 Jefferson Peak (JfP) driver: btusb v: 0.8 type: USB rev: 2.0
    speed: 12 Mb/s lanes: 1 mode: 1.1 bus-ID: 1-10:6 chip-ID: 8087:0aaa class-ID: e001
  Report: rfkill ID: hci0 rfk-id: 1 state: up address: see --recommends
Drives:
  Local Storage: total: 2.29 TiB used: 1.03 TiB (45.1%)
  ID-1: /dev/nvme0n1 maj-min: 259:0 vendor: Toshiba model: KBG40ZNV512G KIOXIA size: 476.94 GiB
    block-size: physical: 512 B logical: 512 B speed: 31.6 Gb/s lanes: 4 tech: SSD serial: <filter>
    fw-rev: HP00AE00 temp: 34.9 C scheme: MBR
  SMART: yes health: PASSED on: 260d 15h cycles: 624 read-units: 37,057,267 [18.9 TB]
    written-units: 43,292,268 [22.1 TB]
  ID-2: /dev/sda maj-min: 8:0 vendor: Seagate model: ST2000LM015-2E8174
    family: Barracuda 2.5 5400 size: 1.82 TiB block-size: physical: 4096 B logical: 512 B sata: 3.1
    speed: 6.0 Gb/s tech: HDD rpm: 5400 serial: <filter> fw-rev: 0001 temp: 42 C scheme: MBR
  SMART: yes state: enabled health: PASSED on: 2y 58d 14h cycles: 59 read: 52.96 TiB
    written: 12.96 TiB Pre-Fail: attribute: Spin_Retry_Count value: 100 worst: 100 threshold: 97
Partition:
  ID-1: / raw-size: 80 GiB size: 78.19 GiB (97.74%) used: 9.57 GiB (12.2%) fs: ext4
    block-size: 4096 B dev: /dev/nvme0n1p5 maj-min: 259:4
Swap:
  Kernel: swappiness: 60 (default) cache-pressure: 100 (default)
  ID-1: swap-1 type: partition size: 16 GiB used: 0 KiB (0.0%) priority: -2 dev: /dev/nvme0n1p6
    maj-min: 259:5
Sensors:
  System Temperatures: cpu: 44.0 C pch: 39.0 C mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 301 Uptime: 2h 0m wakeups: 7 Init: systemd v: 254 default: graphical tool: systemctl
  Compilers: gcc: 7.5.0 alt: 7 Packages: pm: rpm pkgs: N/A note: see --rpm tools: yast,zypper
  pm: flatpak pkgs: 0 Shell: Bash (su) v: 4.4.23 running-in: pty pts/2 inxi: 3.3.27
TVLaptop-PC:~ #

Power saving settings can be found at

  1. BIOS settings
  2. kernel settings
  3. DE settings
  4. tlp package settings
  5. APM/AAM settings in HDD

IMHO you need to set up APM/AAM with “hdparm -B 255 …” at every boot because this setting does not persist.

Test

hdparm -M

Or request HDD every X minutes.

@Imasundaj … might want to read this:

Are you referring to this sentence?

hdparm -S x causes the hard disk to be spun down after a certain period of inactivity. Replace x as follows: 0 disables this mechanism, causing the hard disk to run continuously.

The OP tried “-S 0” and apparently it did not work. That setting worked here some years ago, but have since tossed all HDDs in the trash, replaced all with SSDs. The price difference is negligible.

Please show the output of: sudo hdparm -i /dev/sda

Thank you everyone for the suggestions.

I tried “hdparm -B 255” and also “hdparm -B 254”. Neither worked.
Also tried “hdparm -S 0”. Also didn’t work.

But I think I found a workaround.
In KDE I can run a command when the battery power profile loads.
So when the laptop switches to battery mode, it simply executes this:

echo 60000000 > /sys/block/sda/device/power/autosuspend_delay_ms

If I’m not mistaken, 60 million milliseconds is more than 16 hours. Which is way more than the battery can last before I have to charge it.

Though I would really like to know why the power saving is so aggressive and what is doing it, this is workaround is enough for me. The HDD is not spinning down anymore when the laptop is running on the battery. And this what I wanted to achieve.

Again, thank you everyone for the suggestions and the help.

2 Likes

And what value did this attribute have before your script? The kernel default is -1 and that is what I have on my system.

FYI:

Prevent autosuspend:
Write a negative value to the file to prevent the device from being suspended. For example, writing “-1” to the file has the same effect as writing “on” to the power/control file.

1 Like

It was 15000. That is 15 thousand milliseconds. Which is 15 seconds. And yes, the hdd actually powered off after 15 seconds of idle time.

Again - it is not the default value. Something was setting it.

And what other commands run in this profile?

I don’t know what is setting it. My best guess is TLP. But I tried to configure it, and it didn’t work. So either I did it wrong, or there’s some kernel integrated stuff the I can’t change, unless I build my own custom kernel. Which I’d rather not.

You never even mentioned that you had TLP installed and running.

And you did not describe what you tried.

May be. Without knowing what you did it is difficult to guess.

This is the default value of $AHCI_RUNTIME_PM_TIMEOUT in TLP.

Though installed, TLP was and still is disabled. That is why I didn’t mention.

â—‹ tlp.service - TLP system startup/shutdown
     Loaded: loaded (/usr/lib/systemd/system/tlp.service; disabled; preset: disabled)
     Active: inactive (dead)
       Docs: https://linrunner.de/tlp

I thought if it was disabled it wouldn’t interfere. I guess I was wrong. But I used to fiddle with Linux couple of years ago and back in those day when it said something was disabled, it was disabled. Not anymore it seems.

Given that the actual value was suspiciously equal to the default TLP value, it strongly suggests that something invoked (and still invokes) TLP. Educated guess is that it is invoked by systemd-udevd when power supply information switches between AC and battery. Enable TLP debug, check logs.