My drives were clunking

Fixing emergency head parking on shutdown


<--

The premise

I am currently building a new NAS at home. A full writeup about it is coming, but I wanted to share something I discovered that was a huuuge headache to solve.

Basically I use a homemade disk shelf for my drives where they are externally powered and connected through an LSI 9305-16e HBA card. Due to this they start spinning and initialized when they receive power.

Whenever I would shut off the PSU powering these drives (after having powered down the server) I heard a loud “clunk” every time. Turns out this is the drives emergency parking the head. Now why the head isn’t properly parked I have no clue, as no data is currently read from or written to the drives.

Turns out this was not that easy to solve. Glorious Claude suggested a service that shuts the drives down, while Kagi kept giving me results of you should not spin down ZFS drives. Turns out this was a problem with TrueNAS a while back, which got me the following solution:

  systemd.services.scsi-disk-start-stop = {
    description = "Enable SCSI disk manage start/stop";
    wantedBy = [ "multi-user.target" ];
    serviceConfig = {
      Type = "oneshot";
      RemainAfterExit = true;
    };
    script = ''
      for i in /sys/class/scsi_disk/*/manage_system_start_stop; do echo 1 > $i; done
      for i in /sys/class/scsi_disk/*/manage_runtime_start_stop; do echo 1 > $i; done
    '';
  };

Fin

Now the drives are put in standby when the server shuts down, and I no longer hear anything when powering the drives down after the fact. The drives also start if I just reboot the server without powering the drives down.