hdparm is a Linux utility which can be used to configure and optimize the performance of hard drives, including the read and write speed, data buffer size, and other parameters.
hdparm is a low-level tool and should be used with caution, as incorrect use can result in data loss or corruption. Before using
hdparm, it is recommended to make a backup of important data and to read the manual page and understand the options and their effects.
On the latest Raspberry Pi4, you need to make some tweaks before using
hdparm otherwise it will not work.
First make sure you hard disk is not connected to Pi, open a terminal and run:
Now connect the hard disk and run
lsusb command again. Now you will see a new USB device on your terminal. Just note down the ID of your USB hard drive.
In this case, the ID of Seagate drive is
0bc2:ab24, now edit
/boot/cmdline.txt file and add this to the beginning of the file:
/boot/cmdline.txt file will look like this:
usb-storage.quirks=0bc2:ab24:u console=serial0,115200 console=tty1 root=PARTUUID=395b5838-02 rootfstype=ext4 fsck.repair=yes rootwait cgroup_enable=cpuset cgroup_enable=memory cgroup_memory=1
Now you must restart your pi before proceeding to the next step:
hdparm utility on your pi:
sudo apt install hdparm -y
Now you can spin down and sleep the hard disk attached to your pi, using these commands:
Spin down commd:
# Replace X with your drive letter # You can set value from 1 to 255 sudo hdparm -B 1 /dev/sdX
# Replace X with your drive letter sudo hdparm -S 24 /dev/sdX
You can make these tweaks permanent by adding these settings to /etc/rc.local file (before
# Replace X with your drive letter sudo hdparm -B 1 /dev/sdX sudo hdparm -S 24 /dev/sdX