Home / Alt manpages / scsi_stop(8)

  • scsi_stop(8)
  • Admin command
  • linux

Safely Spin Down SCSI Disks with scsi_stop

You will stop one or more SCSI disks with scsi_stop, check that you have named the intended devices, and confirm whether the command completed successfully. Allow about ten minutes for a single, already identified disk. Stopping a disk interrupts access to it, so perform the change during a maintenance window and keep a recovery command ready.

1. Check the installed tool and package

This guide follows the installed sg3-utils package on this machine, version 1.46-3ubuntu4. The local manual page still carries the older sg3_utils-1.36 header and is dated May 2013. The package version is therefore worth recording when you troubleshoot a different host.

$ command -v scsi_stop
/usr/bin/scsi_stop
$ dpkg-query -W -f='${Package} ${Version}\n' sg3-utils
sg3-utils 1.46-3ubuntu4
$ scsi_stop --help
Usage: scsi_stop [-h] [-v] [-w] <device>+
  where:
    -h, --help           print usage message
    -v, --verbose        more verbose output
    -w, --wait           wait for each stop to complete

Send SCSI START STOP UNIT command to stop each <device>

The command accepts one or more device arguments. Its job is a thin wrapper around sg_start, which sends the SCSI START STOP UNIT command for each device. Do not confuse this with a filesystem unmount or a power-off operation: the command addresses the device itself.

2. Identify the exact device before stopping it

Replace /dev/sdX in the examples with a real SCSI disk path from your host. Do not guess from a letter that can change after a reboot. Use your normal inventory process to match the path to the disk's model, serial number, mount points and current workload.

$ lsblk -o NAME,TYPE,SIZE,MODEL,SERIAL,MOUNTPOINTS
$ readlink -f /dev/sdX
/dev/sdX

Both commands are read-only. If the disk contains a mounted filesystem, active database data, a swap area or a service's working directory, stop that workload and unmount the filesystem according to your operating procedure first. scsi_stop does not prepare applications for the loss of their storage.

Checkpoint

Write down the exact device path you intend to stop and the service or mount that owns it. If you cannot explain why that device is idle, stop here. A typo can affect the wrong disk and a successful command does not prove that the selected disk was the right one.

3. Stop one disk in immediate mode

Run the command with elevated privileges if the device permissions require them. The default mode is immediate: the request asks the device to stop and the utility does not wait for the spin-down to finish.

$ sudo scsi_stop /dev/sdX
$ status=$?
$ printf 'scsi_stop exit status: %s\n' "$status"
scsi_stop exit status: 0

There may be no normal output. Exit status 0 means the script reported success. A non-zero status means the script returned an error from the last sg_start invocation it ran. If you supplied multiple devices, that detail matters: inspect each target independently rather than treating one final status as a per-device report.

The device is now unavailable for normal I/O while it is stopped. Do not run filesystem checks, copy data from it or start a service that expects it to respond until you have deliberately brought it back up.

4. Wait for completion when the boundary matters

Use --wait when the next operation must begin only after each stop has completed. The option changes the wrapper's behaviour; it does not select a different device power state.

$ sudo scsi_stop --wait /dev/sdX
$ printf 'scsi_stop exit status: %s\n' "$?"
scsi_stop exit status: 0

The manual describes the default as immediate mode and --wait as waiting for each stop to complete. The actual time depends on the disk and its SCSI implementation. Keep the terminal open and treat a timeout or non-zero status as a failed operational step, not as proof that the disk stopped.

Use --verbose if you need more diagnostic output:

$ sudo scsi_stop --wait --verbose /dev/sdX
$ printf 'scsi_stop exit status: %s\n' "$?"
scsi_stop exit status: 0

Diagnostic wording and the amount of output can vary by package version and device. The exit status remains the first check.

5. Stop several disks only after checking every path

Multiple device arguments are processed by the script one at a time. Keep the list explicit and review it before pressing Enter. Use --wait when later work depends on every stop having completed.

$ sudo scsi_stop --wait /dev/sdX /dev/sdY
$ printf 'scsi_stop exit status: %s\n' "$?"
scsi_stop exit status: 0

The exit status is that of the last sg_start utility called, as documented by the local manual. That means a successful final status is not a complete audit trail for an earlier failure. For a scripted maintenance job, run one device per command and log the path together with its status:

$ for device in /dev/sdX /dev/sdY; do
>     printf 'stopping %s\n' "$device"
>     sudo scsi_stop --wait "$device"
>     printf '%s status: %s\n' "$device" "$?"
> done
stopping /dev/sdX
/dev/sdX status: 0
stopping /dev/sdY
/dev/sdY status: 0

These paths are placeholders. Replace them only after your inventory check, and do not use an unreviewed glob such as /dev/sd*.

6. Bring a stopped disk back up

scsi_stop has no opposite mode. The underlying sg_start utility can send the matching start request. Use its explicit --start option with the same verified device path:

$ sudo sg_start --start /dev/sdX
$ printf 'sg_start exit status: %s\n' "$?"
sg_start exit status: 0

On this host, sg_start --version reports version 0.67 20200930. The installed help describes --start as starting the unit and --stop as stopping it. A successful start request does not mount a filesystem or restart an application, so complete those separate recovery steps only after checking the disk.

If the start request fails, do not repeatedly retry against an unknown state. Check the device's power, cabling, controller logs and the relevant service procedure. Preserve the original error text for the storage administrator.

7. Diagnose failures without widening the change

A missing argument, an unreadable device or a device that does not support the requested SCSI command can all produce a non-zero result. Start with read-only checks:

$ test -e /dev/sdX && echo 'device path exists'
device path exists
$ ls -l /dev/sdX
$ scsi_stop --help

Do not add unrelated sg_start options to make an error disappear. The wrapper's documented controls are help, verbosity and waiting. In particular, --wait is not a permission fix, and running as root cannot make a missing device or unsupported command become valid.

Keep the original disk accessible until you have confirmed the operational result. If you used an immediate stop, allow the device time to settle before checking it through another tool. If a service still has the disk open, stop the service through its normal procedure rather than forcing repeated SCSI commands.

Done means

  • You recorded the installed sg3-utils version and confirmed scsi_stop is the intended binary.
  • You matched every device path to the correct disk and confirmed it was safe to interrupt.
  • You chose immediate mode or --wait deliberately.
  • You checked the exit status for each target, not only the last item in a multi-device command.
  • You know that starting the unit again uses sg_start --start, and that mounting and service recovery are separate actions.