How to turn off internal HDD (and prevent it to turn back on during resumes and/or shutdowns cycles)

Hi

Is there a way to completely “turn off” internal HDD?

I’m aware of hdparm, but I mean like do not wake up the drive at all (unless I say so) after it’s been put to sleep/idle/power-off… at the moment I think it wakes up each time the computer suspend/resume, turn off (turn on too obviously)…

I assume it is probably the kernel checking if anything changed, is there a way against that? (or one would have to use a custom kernel?)

Cheers

How is it mounted, via fstab?

very good question :sweat_smile:

it’s a fresh install from latest iso, i don’t think i edited fstab, i plugged the drive afterwards and that’s it i think.

I’ll go and check fstab on the computer :upside_down_face:

@linuxislife
Try hd-idle from AUR as well

So, yeah fstab has no mention of the HDD drives.
Just the main ssd is in there.

cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=3E8F-28DC                            /efi           vfat    fmask=0137,dmask=0027 0 2
/dev/mapper/luks-ca4c4be1-37fe-468a-9061-520dee85a95a /              btrfs   subvol=/@,noatime,compress=zstd 0 0
/dev/mapper/luks-ca4c4be1-37fe-468a-9061-520dee85a95a /home          btrfs   subvol=/@home,noatime,compress=zstd 0 0
/dev/mapper/luks-ca4c4be1-37fe-468a-9061-520dee85a95a /var/cache     btrfs   subvol=/@cache,noatime,compress=zstd 0 0
/dev/mapper/luks-ca4c4be1-37fe-468a-9061-520dee85a95a /var/log       btrfs   subvol=/@log,noatime,compress=zstd 0 0
tmpfs                                     /tmp           tmpfs   defaults,noatime,noexec,mode=1777 0 0

There might be other, better ways of doing this but on the OS level, I would create a systemd service which runs early at the boot process to power off the drive using hdparm
(something like hdparm -W /dev/sdX && hdparm -Y /dev/sdX).

I am not sure if it is safe/advisable to find out what the driver is for the hard drive in question and blacklist it :thinking:

udevadm info -a -n /dev/sdX | grep -oP 'DRIVERS?=="\K[^"]+'

I did actually, with same “results”.

will it prevent it to be accessed (turn back on and spin) during the sleep/resume cycle you think ?

I guess i’ll try :sweat_smile:

$ udevadm info -a -n /dev/sda | grep -oP 'DRIVERS?=="\K[^"]+'
sd
ahci

$ udevadm info -a -n /dev/sdb | grep -oP 'DRIVERS?=="\K[^"]+'
sd
ahci

Hmmm… I am admittedly on the “experimental thinking” plane so I am not sure :grimacing:

Please do some research! Have a Live USB at hand if you would need to revert changes you make.

Which one is the drive you want to power off?
They both seem to be using same modules, so blacklisting is perhaps not a good idea.

drives are empty atm anyway, system is on the ssd.
but sure, cheers :blush: i’ll make sure if i blacklist something the ssd will be left alone

Both HDD actually :upside_down_face:

$ udevadm info -a -n /dev/nvme0n1 | grep -oP 'DRIVERS?=="\K[^"]+'
nvme
pcieport

so, yeah, maybe blacklisting would work, not sure if it will be convenient to unblock them later to turn them on without a reboot…?

You can use the modprobe command line to load the module at run time. No reboot should bee needed.

See: https://wiki.archlinux.org/title/Kernel_module#Manual_module_handling

wouldn’t “at runtime” means during a boot ?

I wanted to say that when system is already booted up and running. You could load and unload the kernel modules manually.

I’ll give all that a try and report back !

Cheers !

Good luck!

:crossed_fingers:t5:

Did you get anywhere with this?

Hey,

I’m very sorry that I didn’t report yet…
Life (and work) caught up with me…

So, long story short, I didn’t try anything at all yet, I’ve read a lot about hdparm, hd-idle and idle3-tools, as well as many other ressources.
One of the disks I wanna manage doesn’t remember parameters after sleep or reboot, the other one does, none I’ve tried to “completely” turn off though.
One of the parameter I struggle with on one disk is the “park time” of the head, it is way way too fast, causing huge huge load/unload cycles in a short period of time.

Anyway, I will look into all that at one point, can’t promise when unfortunately, but I will of course report exhaustively here and share my findings and ressources.

Cheers

(@pebcak fancy your new avatar btw!)

Thanks for taking your time and updating on this subject!
Hopefully you’ll find a satisfactory solution for this issue.

And thanks for liking my new avatar!
:speech_balloon:
@pebcak