How To Spin Down Hard Disks at Shutdown on LSI HBAs on Linux

Post copy from TheUbuntuGuy

Anyone who has a file server or just a lot of disks in a workstation knows that the best and most reliable way to connect them is with a proper server grade HBA or RAID card, usually with a chipset made by LSI, such as the famous SAS2008.

One thing you may have noticed is that when running Linux, the disks are not spun down when the system is shut down. Instead, the power is cut with the disks still spinning, causing an emergency retract cycle. This is extremely hard on the drive mechanics and will ultimately kill the drive after only several hundred cycles, as opposed to the hundreds of thousands of regular cycles the drives can handle.

You can solve this problem fairly easily. Each disk on the system has an entry at /sys/class/scsi_disk. In there you will find a property called manage_start_stop. Setting this to a value of 1 will enable spindown at shutdown. You will also notice that regular ATA disks already have this set to 1, but drives on your HBA are set to 0 by default.

root@tesla:~$ cat /sys/class/scsi_disk/1\:0\:0\:0/manage_start_stop
0
root@tesla:~$ echo 1 > /sys/class/scsi_disk/1\:0\:0\:0/manage_start_stop
root@tesla:~$ cat /sys/class/scsi_disk/1\:0\:0\:0/manage_start_stop
1

You can easily set this property on all drives by adding this little script to /etc/rc.local:

for i in /sys/class/scsi_disk/*/manage_start_stop; do echo 1 > $i; done

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.