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?

1 Like

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:

2 Likes

@linuxislife
Try hd-idle from AUR as well

1 Like

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[^"]+'

1 Like

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.

1 Like

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.

1 Like

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…?

1 Like

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

1 Like

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.

1 Like

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

Cheers !

1 Like

Good luck!

:crossed_fingers:t5:

2 Likes

Did you get anywhere with this?

1 Like