1

I have a very old and very loud HDD relegated purely to archiving "leftover" data that isn't hugely important should the drive finally die.

Rather than unplugging it and plugging it in when needed, I'd like to simply have it power off if/when it is unmounted. Unforatuntely, it does not have AMP support, but I have found that either of these do the trick and the drive comes back on when remounted:

hdparm -S 1 /dev/sda1

or

udisksctl power-off -b /dev/sda1

The drawback is I would have to put this in every time I unmount the disk as well as whenever I boot up the system. I am also unable to disable the drive in the BIOS.

Is there a way that I can have one of these trigger whenever the drive has completed unmounting? Or is there some disk options I just haven't discovered that allow this?

saltesc
  • 11
  • 2

1 Answers1

0

In Linux, it is possible to control HDD power on and off by using spindown and spinup. These commands, by managing its power state, allow you to keep the disk with the platters stopped, without having to physically disconnect it.

The hdparm command is suggested for this purpose.

Stopping the disk manually

sudo hdparm -y /dev/sdX

The -y parameter puts the disk platters into immediate suspension (spindown).

sudo hdparm -Y /dev/sdX

The -Y parameter stops the disk completely, and some HDD models may not wake up again until a reboot.

Powering on the disk

There is no specific command to power on the disk; however, mounting the disk or accessing it, such as listing files, should automatically reactivate it if used with the -y parameter.

If the -Y parameter is used and the drive is unresponsive, a reboot is required.

Mounting and Power Control Example

Unmount and Halt Drive

sudo umount /media/user/my_drive
sudo hdparm -y /dev/sdX1

Mount and Power On, to Reuse

sudo mount /dev/sdX1 /media/user/my_drive

Mounting it will cause the system to automatically "wake it up."

Do not use this on drives with active file systems or mounted in write mode. Some drives and controllers do not properly implement full shutdown (-Y). SSD drives (they have no moving parts and do not benefit from spindown

kyodake
  • 17,808