Safely Spin Down SCSI Disks with scsi_stop
Before you pull a drive from service, get it actually stopped, not just unmounted, with scsi_stop. Allow about ten minutes for a single, already identified disk. Stopping a disk interrupts access to it, so make the change during a maintenance window and keep a recovery command ready.
The route
Jump straight to the step you need, or tick off Done means at the end.
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, so the package version is worth recording if you ever compare notes with 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, it addresses the device itself, not what is sitting on top of it.
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 carries a mounted filesystem, active database data, a swap area or a service's working directory, stop that workload and unmount the filesystem through your operating procedure first. scsi_stop does nothing to 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 hit the wrong disk, and a successful command does not prove 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 at all. 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 trusting one final status to cover them all.
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 start only after each stop has actually 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 is still the first thing to check.
5. Stop several disks only after checking every path
Multiple device arguments get 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 full 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 never build the list from an unreviewed glob such as /dev/sd*.
6. Bring a stopped disk back up
scsi_stop has no opposite mode built in. The underlying sg_start utility can send the matching start request instead. 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 treat those as separate recovery steps to complete 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 just 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 turn a missing device or an unsupported command into a valid one.
Keep the original disk accessible until you have confirmed the operational result. If you used an immediate stop, give 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 at it.
Done means
- Version and binary confirmed. You recorded the installed
sg3-utilsversion and confirmedscsi_stopis the intended binary. - Every device matched and cleared. Each path was matched to the correct disk and confirmed safe to interrupt.
- Mode chosen deliberately. You picked immediate mode or
--waiton purpose, not by default. - Exit status checked per device. Not just the last item in a multi-device command.
- Recovery path known. Starting the unit again means
sg_start --start, and mounting and service recovery are separate steps.