Using "hdparm" to keep HDD awake. (Western Digital)

Issues and / or general discussion relating to Puppy


Moderator: Forum moderators

Post Reply
User avatar
greengeek
Posts: 1582
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 683 times
Been thanked: 243 times

Using "hdparm" to keep HDD awake. (Western Digital)

Post by greengeek »

I recently replaced the HDD in my Toshiba laptop because I could hear increasingly strange noises from the old one.
My new replacement was a Western Digital SATA drive - not an SSD but rather one of the mechanical ones. (Cost only $12 for 500GB so I figured I would give it a try)

After fitting the new HDD I found that some actions appeared very slow. For example using Rox to open any of the files on HDD resulted in a noticeable delay before the window contents displayed properly. It appeared that the WD drive was going to sleep after only about 8 seconds.

I had a look at hdparm and specifically the -S (Spindown time) parameter (that's capital "S") and tried various options - initially without success.

However - it turns out that the -S parameter is only meaningful when "advanced power management" (APM) is activated. (At least this is the case with some types of drives).

So it was also necessary to modify the APM value by setting the -B option to a value of 254.

This gave me a useful command as follows:
hdparm -B 254 -S 240 /dev/sda
(-B value sets advanced power management to a value that enables the spindown timeout parameter to function)
(-S value sets spindown timeout to 20 minutes. To understand this setting, or to calculate longer timeout you must read the notes below)

I have now made this command into a script that I manually click after booting. (Because the drive resets to it's default values after powering down the laptop)

****************************************************************

NOTES:

With regard to the -S (spindown time) parameter hdparm calculates the spindown values as follows:
https://askubuntu.com/a/39764
A value of zero means "timeouts are disabled": ie the device will not automatically enter standby mode.
Values from 1 to 240 specify multiples of 5 seconds, yielding timeouts from 5 seconds to 20 minutes.
Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes.
A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes plus 15 seconds. Note that some older drives may have very different interpretations of these values.
.

With regard to the -B (APM) parameter - the advanced power management settings are not just " linear digital" values - certain numbers have special meanings:
https://unix.stackexchange.com/question ... 582#174582
hdparm cannot do any calculations with regard to the -B value (APM) and it depends on drive manufacturer
Here is more detail about APM:
https://superuser.com/questions/555400/ ... 622#558622
.

Other helpful commands
You can see a list of all your connected storage devices and their corresponding device paths with the following command:
#fdisk -l
(that's a lowercase "ell")

Interrogate STATUS of a particular drive:
#hdparm -C /dev/sda
(eg active/idle/standby)

Interrogate PARAMETERS of a particular drive:
#hdparm -I /dev/sda
(That's an uppercase "eye")
Also check hdparm -i /dev/sda)
(That's a lowercase "eye")
.

DriveState.png
DriveState.png (9.01 KiB) Viewed 113 times
User avatar
Jasper
Posts: 1884
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 909 times
Been thanked: 391 times

Re: Using "hdparm" to keep HDD awake. (Western Digital)

Post by Jasper »

@greengeek

Your post is informative and I do have some questions to ask.

Which exact model of HDD ? They all differ.

Did you consider using Smartctl ?

Last edited by bigpup on Fri Apr 25, 2025 2:29 pm, edited 1 time in total.
Reason: deleted dead image
User avatar
greengeek
Posts: 1582
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 683 times
Been thanked: 243 times

Re: Using "hdparm" to keep HDD awake. (Western Digital)

Post by greengeek »

Jasper wrote: Thu Apr 17, 2025 8:06 am

Which exact model of HDD ? They all differ.

Hi Jasper, my model is:
Western Digital WD Black
WD5000LPLX-08
Seems to be a date code of 2018. Supposedly never used so I am interested to see how long it lasts - especially since I plan on having it spinning as much as possible rather than in standby mode.

WD_.png
WD_.png (329.77 KiB) Viewed 102 times

.

Jasper wrote: Thu Apr 17, 2025 8:06 am

Did you consider using Smartctl?

My Fossa64 9.5 does not currently have smartctl available. (Maybe in PPM? not sure)

In terms of drive info the following commands I use the following two commands to find quite a bit of info:
1) Using uppercase "eye" parameter:

Code: Select all

#hdparm -I /dev/sda
/dev/sda:

ATA device, with non-removable media
	Model Number:        WD5000LPLX-08ZNTT0                  
	Serial Number:           WD-WX51AA8KDCDH
	Firmware Revision:  
Standards:
	Supported: 9 8 7 6 
	Likely used: 9
Configuration:
	Logical		max	current
	cylinders	16383	16383
	heads		16	16
	sectors/track	63	63
	--
	CHS current addressable sectors:   16514064
	LBA    user addressable sectors:  268435455
	LBA48  user addressable sectors:  976773168
	device size with M = 1024*1024:      476940 MBytes
	device size with M = 1000*1000:      500107 MBytes (500 GB)
Capabilities:
	LBA, IORDY(can be disabled)
	Queue depth: 32
	Standby timer values: spec'd by standard, no device specific minimum
	R/W multiple sector transfer: Max = 16	Current = 16
	AdvancedPM level: unknown setting (0x00fe)
	DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6 
		Cycle time: min=120ns recommended=120ns
	PIO: pio0 pio1 pio2 pio3 pio4 
		Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
	Enabled	Supported:
	   *	READ BUFFER cmd
	   *	WRITE BUFFER cmd
Security:
	Master password revision code = 65534
		supported
	not	enabled
	not	locked
	not	frozen
	not	expired: security count
		supported: enhanced erase
	70min for SECURITY ERASE UNIT. 70min for ENHANCED SECURITY ERASE UNIT. 
Checksum: correct

.
2) Using lowercase "eye" parameter:

Code: Select all

#hdparm -i /dev/sda
/dev/sda:

 Model=WDC WD5000LPLX-08ZNTT0                  , FwRev=05.01A05, SerialNo=     WD-WX51AA8KDCDH
 Config={ HardSect NotMFM HdSw>15uSec SpinMotCtl Fixed DTR>5Mbs FmtGapReq }
 RawCHS=16383/16/63, TrkSize=0, SectSize=0, ECCbytes=0
 BuffType=(0) unknown, BuffSize=32767kB, MaxMultSect=16, MultSect=?16?
 CurCHS=16383/16/63, CurSects=16514064, LBA=yes, LBAsects=268435455
 IORDY=on/off, tPIO={min:120,w/IORDY:120}, tDMA={min:120,rec:120}
 PIO modes:  pio0 pio3 pio4 
 DMA modes:  mdma0 mdma1 mdma2 
 UDMA modes: udma0 udma1 udma2 
 AdvancedPM=yes: unknown setting WriteCache=enabled
 Drive conforms to: reserved:  ATA/ATAPI-1 ATA/ATAPI-2 ATA/ATAPI-3 ATA/ATAPI-4 ATA/ATAPI-5 ATA/ATAPI-6 ATA/ATAPI-7 ATA/ATAPI-8 ATA/ATAPI-9

 * current active mode

User avatar
greengeek
Posts: 1582
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 683 times
Been thanked: 243 times

Re: Using "hdparm" to keep HDD awake. (Western Digital)

Post by greengeek »

Checked PPM for smartctl and found gsmartctl which is a gui version.

I did not load all the dependencies (30 odd files @ 50MB) but did get it basically running:
.

gsmartcontrol.png
gsmartcontrol.png (112.55 KiB) Viewed 100 times
User avatar
bigpup
Moderator
Posts: 7591
Joined: Tue Jul 14, 2020 11:19 pm
Location: Earth, South Eastern U.S.
Has thanked: 1038 times
Been thanked: 1691 times

Re: Using "hdparm" to keep HDD awake. (Western Digital)

Post by bigpup »

Have you tried putting your script in the startup directory, to get it to run on startup?

The things you do not tell us, are usually the clue to fixing the problem.
When I was a kid, I wanted to be older.
This is not what I expected :o

User avatar
greengeek
Posts: 1582
Joined: Thu Jul 16, 2020 11:06 pm
Has thanked: 683 times
Been thanked: 243 times

Re: Using "hdparm" to keep HDD awake. (Western Digital)

Post by greengeek »

bigpup wrote: Thu Apr 17, 2025 11:36 pm

Have you tried putting your script in the startup directory, to get it to run on startup?

Not yet - so far I am just using it manually.
My pup is just in it's generic form without any save file so I would have to remaster to get the script into Startup.

But now that I think a bit more about it - it would definitely make sense to have the script run automatically because this disk is the one that contains my Swap partition.

Post Reply

Return to “Users Help”