I have a usb sata2 drive connected to usb that is mounted as /home. When I turn off the computer/laptop the disk makes some high pitch sound as if the disks were still spinning and heads were not parked when the power goes off.

This sound is not produced when I unmount the partitions and send a sleep signal to the disk manually:

hdparm -Y /dev/sdb

But to do that I need to unmount /home as a partition of the disk is mounted as /home by the fstab:

UUID=[long number] /home                   ext4    defaults        1 2

So unmounting it isn't possible as the disk is always busy. Currently I can go to runlevel 1 and then unmount it and then send the sleep signal:

systemctl isolate runlevel1.target
umount /home
umount /dev/sdb*
hdparm -Y /dev/sdb
(unplug the drive without the drive giving any sounds)
systemctl poweroff

Because this is a bit much to do every time I want to turn off the computer/laptop I tried adding a script to rc0:

Have the following file in /etc/init.d

-rwxr-xr-x   1 root root   547 Mar  3 07:57 sleep.usb


#! /bin/bash
# network       Bring up/down networking
# chkconfig: - 10 1
# description: Unmount /home/harm/ssd, /home and send sleep signal

# See how we were called.
case "$1" in

    somevar="$(mount|grep /home)";
    if [ "$somevar" != "" ]; then
      umount /home
    umount /dev/sdb*
    hdparm -Y /dev/sdb
        echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
        exit 2

exit 0

Installed it with:

chkconfig --add sleep.usb

and it is showing up in the right directory:

lrwxrwxrwx   1 root root   19 Mar  3 08:00 K01sleep.usb -> ../init.d/sleep.usb

However; when I power down my computer/laptop the harddisk still makes the sound and holding it in my hand I can feel the disks spinning up until the very moment the power goes off.

1 Answer 1



So, you have systemd as your init. In that case, I'd first suggest to avoid using the compatibility layer at least in your own code and instead use systemd's native tools. Here, your best bet would be to use systemd's ability to run arbitrary files in /usr/lib/systemd/system-shutdown as part of its shutdown logic.

To quote systemd-shutdown(8):

Immediately before executing the actual system halt/poweroff/reboot/kexec systemd-shutdown will run all executables in /usr/lib/systemd/system-shutdown/ and pass one arguments to them: either "halt", "poweroff", "reboot" or "kexec", depending on the chosen action.

So, you can place a script doing just hdparm -Y into that directory, and it will be executed right before system is halted. Note that it is very late shutdown: everything is either unmounted or remounted read-only, processes are killed, network is down, etc, etc. Due to that, you won't need any of the ancillary logic currently present in your script.


As you've stated, just telling the disk to go to sleep doesn't help. That's because it is woken up again after your script finishes. It possibly happens because systemd-shutdown performs final preparations for shutdown, or whatever.

So, we need to remove the device from the system after sending it to sleep. I suppose your drive is a USB mass storage device; everything below will work only for such drives.

DRIVE=sdb # replace with whatever is needed
echo 1 > $(realpath /sys/block/$DRIVE/device)/../../../../remove

To understand what's going on one needs to have some knowledge of (Linux-specific) sysfs hierachy.

  • /sys/block/sdX is a directory representing a (virtual) block device
  • device is a symlink pointing to the directory representing the physical SCSI device (in Linux, USB mass storage devices are shown as SCSI disks)
  • first .. goes to the parent directory representing a SCSI target
  • second .. goes to the parent directory representing a SCSI host
  • third .. goes to the parent directory representing an USB "interface"
  • fourth .. goes to the parent directory representing an USB "device" -- that's what we need.

Finally, we write 1 to the remove file in that directory. This tells the USB driver to disable and remove the device from the system.

Hopefully, this will do the trick.

  • Thank you for your answer, although it didn't work (hd still making sound even after trying to put sleep 1 after the hdparm)
    – HMR
    Commented Mar 5, 2015 at 13:51
  • 1
    @HMR: Well, you've mentioned that you manually unplug your drive to make it work. The closest thing you can do from software is to disable/remove the corresponding USB device (I suppose your drive is USB). I will update my answer to demonstrate it.
    – intelfx
    Commented Mar 5, 2015 at 14:10
  • Thank you again for your update, I will try that and see if it works.
    – HMR
    Commented Mar 6, 2015 at 1:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .