How to turn off one of SATA HDDs installed in the computer to save power?

5,092

What you're looking for is the hdparm utility.

It allows you to control your hard drives' power settings, apart from benchmarking and other stuff.

With hdparm -y /dev/sdX you put the disk into standby mode. This way, whenever you access the disk, it should automatically wake up and work back again.

There's an even deeper resting mode, which can be set with -Y instead of -y, but you may need to restart your computer in order to make the HDD work again, depending on the device.

Since manually having to put it to sleep is a bit of a hassle, you can set a timer to do it after a specific amount of time with the -S option.

From ArchWiki:

A device which is rarely needed can be put to sleep directly at the end of the boot process. This does not work with the above udev rule because it happens too early. In order to issue the command when the boot is completed, just create a systemd service.

/etc/systemd/system/hdparm.service

[Unit]
Description=hdparm sleep

[Service]
Type=oneshot
ExecStart=/usr/bin/hdparm -q -S 120 -y /dev/sdb

[Install]
WantedBy=multi-user.target

Then enable it.

Share:
5,092

Related videos on Youtube

Ivan
Author by

Ivan

Updated on September 18, 2022

Comments

  • Ivan
    Ivan over 1 year

    I have bought an SSD to replace my HDD to make my Xubuntu 16.10 laptop faster but there is hardly too much of space on it so I've decided to keep the old big HDD as a second drive replacing the DVD+RW drive with it.

    I am going to store big, rarely needed files like distros, backups, movies etc on the HDD, so I am not going to need access to it 100% of time.

    Is there a way to power it off to save the battery when I am not using it?

    • Xen2050
      Xen2050 almost 6 years
      If this were a desktop, you could (relatively) easily add a physical power switch to cut off all power to the drive, would just need a 2 or 3 "wire" switch (a DPST or TPST switch, or 2/3 single switches physically connected together, like in a house breaker box's connected 220V breakers) to disconnect all the power wires at the same time. If your computer supports hot swapping drives you wouldn't need a reboot to turn on & access the storage drive either
  • Vincent Fourmond
    Vincent Fourmond over 5 years
    For the record, this allowed me to boot into a system that didn't start because of a critical disk failure on a disk which is not the system disk.