Linux hdparm Command Tutorial

40

In Linux-type systems, the “hdparm” command tool is used to provide the interface for kernel-supported devices. It is to display the drive disk statistics and set hardware parameters and testing performance.

This utility allows the user to perform DMA settings, set hardware parameters like cache settings, acoustic and power management.

The operations of the “hdparm” command-line utility work properly with the latest kernel devices. But some of the options still support old disk drives.

Syntax:

The syntax of the “hdparm” command is mentioned below:

hdparm [options…] [device]

Install hdparm Command:

The “hdparm” command is a built-in utility in Linux-type systems. Rarely, this command-line utility may not be available on your Linux machine.

So, to get it on the system, type the mentioned command in the terminal:

$ sudo apt install hdparm

Hdparm Command Flags:

The “hdparm” command supports various flags. All available options are mentioned here:

“-A” flag:

The “-A” flag is used to Enable/Disable the IDE drive’s read-lookahead feature. When we perform this action, it is on Enabled mode by default. The “-A” flag value lies between 0 and 1, which means:

[cc lang=“bash” width=“100%” height=“100%” escaped=“true” theme=“blackboard” nowrap=“0”]
0 = Disable
1 = Enable

Run it without passing any value (0 or 1); the terminal will display the by-default result:

$ sudo hdparm -A /dev/sda

“-a” flag:

The “-a” flag is used to Enable/Disable file-system read-ahead that helps to enhance performance to read large files. Multiple IDE drives consist of separate built-in read-ahead functions.

“-B” flag:

The “-B” flag is used to set the advanced features of Power Management. Its value lies between 0 255. The highest value (255) means good performance, whereas aggressive performance uses the lowest one (0). You can also set any number in between.

$ sudo hdparm -B 254 /dev/sda

“-b” flag:

The “-b” flag is used to Get/Set the bus state of a device that consists of 3 value:

0 = off
1 = on
2 = tristate

“-D” flag:

The “-D” flag is used to Enable/Disable the on-drive feature of defect management. This option is not useful for many latest devices since ATA-4.

“-d” flag:

The “-d” flag is used to Enable/Disable “using_dma” flag for the device:

$ sudo hdparm -d1 /dev/sda

“-E” flag:

The “-E” flag is used to set the speed of cdrom/dvd. It is not necessary to perform this option regularly, as the disk will do it automatically.

“-F” flag:

The “-F” flag is used for flushing the drive write cache.

“-f” flag:

The “-f” flag is used to sync and flush the buffer cache on exit.

“-g” flag:

The “-g” flag is used to present the drive geometry that includes its size that will display in sectors and the offsets that starts from the beginning of the drive.

“-h” flag:

To display the help message about the “hdparm” command and its flags, use the “-h” flag.

“-I” flag:

To display complete information in an expanded format about drive, use the “-I” flag. It is used to retrieve data directly from the drive.

$ sudo hdparm -I /dev/sda

“-K” flag:

The “-K” flag is used to get or set the keep_features_over_reset flag of the device:

“-M” flag:

The “-M” flag is used to Get/Set the Automated Acoustic Management (AAM) setting for the device, and its value lies between 0-254. This flag has 3 supportive values, 0, 128, and 254. 0 is considered off state, 128 is the quiet and slowest one, whereas 254 is considered the loudest and fast one.

$ sudo hdparm –M 228 /dev/sda

“-m” flag:

The “-m” flag is used to Get/Set the count of multiple I/O sectors.

“-n” flag:

The “-n” flag is used to Enable/Disable ignore-write-errors flag that is 0/1.

“-N” flag:

The “-N” flag is used to Get/Set the sector’s highest visible number, which could be more dangerous.

“-n” flag:

The “-n” flag is used to Enable/Disable ignore-write-errors flag that is 0/1.

“-P” flag:

The “-P” flag is used to set the highest sector count for the drive prefetch mechanism.

“-p” flag:

The “-p” flag is used for the IDE chipset interface to set the specified PIO mode (0,1,2,3…)

“-q” flag:

The “-q” flag is used to handle the next settings of the flag quietly. It helps when you want to reduce clutter while startup scripts are running on the system. It doesn’t work with “-i, -v, -t, -T” flags.

“-Q” flag:

The “-Q” flag is used to Get/Set the tagged queue depth that could be 1 or more than that. But, to off the tagged queue state, the value would be 0.

“-r” flag:

Execute the “-r” option to Get/Set read-only flag for the drive:

$ sudo hdparm –r /dev/sda

“-S” flag:

Use the “-S” flag to set the drive’s standby timeout.

“-s” flag:

It is used to set the power-up value in the standby flag that is 0/1.

“-T” flag:

The “-T” flag is used to execute the cache reads timing for comparison and standard purposes:

$ sudo hdparm -T /dev/sda

“-t” flag:

Execute the “-t” flag to check the timings of buffer disk reads of a device:

$ sudo hdparm –t /dev/sda

“-u” flag:

The “-u” flag is used to Get/Set the drive’s interrupt-unmask flag 0/1.

“-v” flag:

The “-v” flag is used to print all settings when there is no argument to pass:

$ sudo hdparm –v /dev/sda

“-V” flag:

To get the version of the “hdparm” command tool, execute the “-V” flag in the terminal:

“-w” flag:

Use the “-w” flag when you want to perform a device reset operation.

“-W” flag:

The “-W” option is used to Enable/Disable the write-cache flag that is 0/1 for the drive:

$ sudo hdparm –W /dev/sda

“-X” flag:

Run the “-X” command to set up the latest driver’s transfer mode.

“-y” flag:

Execute the “-y” flag when you want to force the drive to enter in the standby mode:

$ sudo hdparm -y /dev/sda

“-Y” flag:

Execute the “-Y” flag when you want to force the drive to enter the sleep mode:

$ sudo hdparm -Y /dev/sda

“-z” flag:

The “-z” flag is used to allow the kernel to re-read the partitioned table of the particular device.

“-Z” flag:

When the “-Z” flag is used with the “hdparm” command, it will disable the automatic power-saving mode of the device.

Conclusion:

This guide has gone through the detailed information about the Linux command-line utility “hdparm”. We have also discussed all the supported flags of this tool.

The “hdparm” command is used to display and perform the disk drive operations, including power management, DMA settings, and hardware parameters.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More