Linux HDD sleep – how to enable and disable with hdparm

The purpose of this guide is to learn about enable or disable Linux HDD sleep. cover the steps necessary to change a hard drive’s sleep/standby mode timer on Linux. You can either enable standby mode on a storage device, disable standy completely, or adjust the current time it takes for a hard drive to enter standby.

Depending on your system’s usage and environment, the time your hard drive is in an idle state may vary. Every time a hard drive has nothing to do, it waits a certain period of time, and then it enters sleep mode. To enter the sleep/standby mode, a hard drive has to park its head and stop its plates from spinning (of course, this doesn’t apply to solid state drives). By reducing a timer before the hard drive goes to sleep mode, we can save some power.

Adjusting a hard drive’s standby timer can be done from the GUI or command line. Both methods are covered below, so feel free to use whichever method is easier for you.

In this tutorial you will learn:

  • How to install hdparm on major Linux distros
  • How to use hdparm to adjust standby time
  • How to adjust HDD standby time via GUI
How to enable and disable HDD sleep on Linux
How to enable and disable HDD sleep on Linux
Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software hdparm
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Install hdparm on major Linux distros




In order to change the standby time of storage device via command line, you’ll need to install the hdparm software package. This software is available in official repositories on nearly all Linux distributions.

On some systems, hdparm may already be installed by default. But if not, you can use the appropriate command below to install the program with your system’s package manager.

To install hdparm on Ubuntu, Debian, and Linux Mint:

$ sudo apt install hdparm

To install hdparm on CentOS, Fedora, AlmaLinux, and Red Hat:

$ sudo dnf install hdparm

To install hdparm on Arch Linux and Manjaro:

$ sudo pacman -S hdparm

After it’s installed, check out the examples below to see how to adjust HDD standby time.

Adjust HDD standby time with hdparm

Check the hdparm examples below to see how you can adjust the standby mode of the HDDs on your system.

The only thing you need to know before getting started is the path to the drive’s device file that you wish to configure standby settings for. In the examples below, we will be using a hard drive at path /dev/sda. You can see a list of all your connected storage devices and their corresponding device paths with the following command:

# fdisk -l
  1. To turn standby mode off, the following hdparm command can be used.
    $ sudo hdparm -s 0 /dev/sda
    



  2. To turn standby mode on, we can use hte -s 1 option. We must also supply the --yes-i-know-what-i-am-doing flag. As funny as that sounds, it truly is necessary to supply it in the hdparm command syntax, otherwise the command won’t work. This is done for extra verification that your BIOS and HDD firmware indeed support standy mode. These days, that should nearly always be the case.
    $ sudo hdparm --yes-i-know-what-i-am-doing -s 1 /dev/sda
    
  3. To adjust the amount of idle time it takes before a hard drive enters standby mode, we will use the -S option. The way we specify the number of minutes is a little peculiar. The possible values are between 1-255. Multiply the value by 5 and you get the number of seconds your hard drive enters standby mode.
    $ sudo hdparm -S 200 /dev/sda
    
    /dev/sda:
     setting standby to 200 (16 minutes + 40 seconds)
    

Adjust HDD standby time via GUI

Modern Linux distributions will also allow us to adjust the HDD standby time from inside the desktop environment. The exact instructions for this process will vary by distro and desktop environment.

In the steps below, we are adjusting hard drive standby in Ubuntu on GNOME.

  1. Start by opening the Disks utility.

    Opening the Disks utility
    Opening the Disks utility
  2. Inside this menu, select the disk that you wish to configure, and then open up the drive settings menu.

    Opening the drive settings menu
    Opening the drive settings menu
  3. From this menu, you can select the toggle button to turn standby on or off. If you choose to toggle it on, you can then adjust the slider below to configure how long it should take before the drive enters standby.


    Adjusting the HDD standby timer via GUI on Ubuntu
    Adjusting the HDD standby timer via GUI on Ubuntu

Closing Thoughts

In this Linux HDD sleep guide, we learned how to enable and disable standby mode on a hard drive in Linux. We also saw how to adjust the amount of time it takes before a hard drive enters standby. This can be done from the command line with the hdparm command, or by GUI in system settings.



Comments and Discussions
Linux Forum