hdparm is a command-line utility for Linux and Unix-like operating systems that can be used to get and set various parameters of SATA and IDE hard drives. It can be used to perform a variety of tasks, such as:
- Retrieving hard drive information: hdparm -i /dev/sda will display information about the hard drive such as model number, firmware version, and supported features.
- Testing hard drive performance: hdparm -t /dev/sda will perform a read speed test on the hard drive, which can be used to determine the drive’s performance.
- Enabling/disabling features: hdparm -S 0 /dev/sda can be used to disable the hard drive’s standby mode, which can be useful for preventing the drive from going into a low power state.
- Changing hard drive settings: hdparm -d1 /dev/sda will set the hard drive to use DMA (Direct Memory Access) for data transfers, which can improve performance.
It’s important to note that hdparm can be used to make changes to the hard drive that can potentially cause data loss or other problems. It’s recommended to use hdparm with caution and to make a backup before making any changes. It’s also important to note that many modern hard drives implement advanced power management features that may interfere with hdparm commands such as setting the Advanced Power Management (APM) level or disabling the drive’s standby mode.
If you encounter the below error while running the command hdparm:
hdparm: command not found
you may try installing the below package as per your choice of distribution:
|Debian||apt-get install hdparm|
|Ubuntu||apt-get install hdparm|
|Alpine||apk add hdparm|
|Arch Linux||pacman -S hdparm|
|Kali Linux||apt-get install hdparm|
|CentOS||yum install hdparm|
|Fedora||dnf install hdparm|
|Raspbian||apt-get install hdparm|
hdparm Command Examples
1. Request the identification info of a given device:
# sudo hdparm -I /dev/device
2. Get the Advanced Power Management level:
# sudo hdparm -B /dev/device
3. Set the Advanced Power Management value (values 1-127 permit spin-down, and values 128-254 do not):
# sudo hdparm -B 1 /dev/device
4. Display the device’s current power mode status:
# sudo hdparm -C /dev/device
5. Force a drive to immediately enter standby mode (usually causes a drive to spin down):
# sudo hdparm -y /dev/device
6. Put the drive into idle (low-power) mode, also setting its standby timeout:
# sudo hdparm -S standby_timeout device
7. Test the read speed of a specific device:
# sudo hdparm -tT device