1

My laptop has two drives: An SSD for the operating system (Kubuntu 20.10) and an HDD for media storage. Under windows my HDD only spins up when it's necessary but under linux it's spinning constantly and never spins down even if I am not using that at all. It's quite annoying because it drains my battery faster. I am 100% sure that it's my HDD and not the CPU fan because when I open a folder on it I never hear the spin up noise which is well known from windows.

I've tried many programs such as iotop, htop, iostat, dstat to find out what programs transfering data on my disk but I couldn't use them to show the disk(/sdb) activity separately from my SSD(/sda) and the name of the processes which may be using that. When I ran iotop it didn't show any data transfer on my disk at all.

I also tried the sudo hdparm -S 12 /dev/sdb command which would spin down my HDD after 1 minute of not using that but it still doesn't work.

Finally I'v found a desktop widget which shows the disk activity and it shows writing spikes quite frequently but I still don't know what causes this.


Edit:

Setting an APM value lower than 128 has solved the main problem but there are two another ones about it:

After every single reboot my APM_level is set back to default 254. I tried to use the sudo hdparm -K /dev/sdb command but it didn't help. I also tried to rewrite the hdparm.config file in /etc directory but it didn't help either.

These commands doesn't work properly: I tried many APM values and hdparm -S spindown-settings and all did the same: My HDD spins down within a half minute no matter if I set a -S12 or -S36 or anything else even when my APM_level is at 127. If I set a lower APM_level sometimes the HDD spins down during video playback and the video gets pixelated for a couple of seconds as the drive can't spin-up fast enough to provide data for the video player.

So the only setting that effects the HDD spin_down time is the hdparm -B but not that much. I could never achive more than half minute.

1 Answers1

2

This might help you:

find /{mount point} -mount -newer /proc -print

Note: Be sure to change {mount point} to the proper location where the disk partitions are mounted. For example: /home/robert

This command will list all of the files modified since boot on the physical device of the /{mount point} file system. If you can identify which files are being accessed then you may be able to determine which process(es) is/are responsible for the issue.


Talk to the Drive

If the output of the find command is empty or lists files that have not been updated in hours/days/weeks/etc., then the lack of idle sleep could be the result of the device's power management settings not allowing an automatic spin down.

You can query the device's Advanced Power Management value like this:

sudo hdparm -B /dev/sdb

You could see something like this:

/dev/sdb:
 APM_level  = 128

From the hdparm documentation for the -B option:

Get/set Advanced Power Management feature, if the drive supports it. A low value means aggressive power management and a high value means better performance. Possible settings range from values 1 through 127 (which permit spin-down), and values 128 through 254 (which do not permit spin-down). The highest degree of power management is attained with a setting of 1, and the highest I/O performance with a setting of 254. A value of 255 tells hdparm to disable Advanced Power Management altogether on the drive (not all drives support disabling it, but most do).

For the drive queried above, it returned a value of 128, which means that "spin down is not permitted". However, you can change this by setting a value after -B:

sudo hdparm -B 64 /dev/sdb

This will (hopefully) result in the following output:

/dev/sdb:
 setting Advanced Power Management level to 0x40 (64)
 APM_level  = 64

At this point, the drive will be permitted to spin down. Feel free to change the Advanced Power Management value to anything between 1 (very aggressive power management) and 127 (less aggressive, but still allowing spin-down). At this point, the system should start to honour the -S 12 spin-down setting.

Hope this gives you what you're looking for.