SG_START(8)
Manual page header: SG_START(8) โ SG3_UTILS โ SG_START(8); yes the name repeats, and weโre folding it in right here. slay. ๐
๐ธ NAME ๐ธ
sg_start โ send SCSI START STOP UNIT command: start, stop, load or eject medium. Thatโs the whole vibe: this utility tells a device to start, stop, load, or eject media. ๐
โจ SYNOPSIS โจ
sg_start [0] [1] [--eject] [--help] [--fl=FL] [--immed] [--load]
[--loej] [--mod=PC_MOD] [--noflush] [--pc=PC] [--readonly] [--start]
[--stop] [--verbose] [--version] DEVICE
sg_start [--eject] [--fl=FL] [-i] [--imm=0|1] [--load] [--loej]
[--mod=PC_MOD] [--noflush] [--pc=PC] [-r] [--start] [--stop] [-v] [-V]
[0|1] DEVICE
๐ฆ DESCRIPTION ๐ฆ
Okay so hereโs the tea, bestie: sg_start sends a SCSI START STOP UNIT command to the DEVICE with the options you picked. The big faves are --stop to spin down a disk and --start to spin up a disk. Using --start on a disk that is already spinning is harmless โ no drama. โจ Thereโs also finer-grain control with the โpower conditionโ: active, idle or standby. Thatโs set with the --pc=PC option. In some contexts the โstopโ state can be considered an additional power condition. iykyk.
Devices that contain removable media, like cd/dvds, can use the --loej option to load the medium when itโs used with --start (i.e. load medium then spin up). Alternatively --loej can eject the medium when used with --stop (i.e. spin down then eject medium). More simply, loading or ejecting a removable medium can be requested with the --load or --eject option. Itโs giving โmedia go in, media go out.โ ๐ฆ
If no option or argument is given then a --start is assumed โ as the utilityโs name suggests. Main character energy: it just starts. ๐
This utility supports two command line syntaxes. The preferred one is shown first in the synopsis and explained in this section. A later section on the old command line syntax outlines the second group of options. Periodt.
Linux note: best not to use a standard block device name (e.g./dev/sdc) with the--stopoption. Use ansgorbsgdevice node instead (seelsscsi(8)). The block layer will sometimes notice the disk spinning down and decide: โthatโs not rightโ and spin it up again! ๐
๐ OPTIONS ๐
Arguments to long options are mandatory for short options as well. ๐
0โ same action as--stop.1โ same action as--start.-e,--ejectโ stop the medium and eject it from the drive. Only appropriate for a device with removable medium. Might be ignored (prevented), see below. Note, this is an operation that can be done on a tape drive or CD/DVD/BD player, not on a hard disk or SSD! ๐-h,--helpโ print out the usage message then exit.-f,--fl=FLโ sets the format layer number for the disc to โjumpโ to (defined in MMC-5). Values ofFLcan be0to3. When this option is chosen, theFL,LoEjandStartbits are set in the cdb as required by MMC-5; thus the user does not need to set the--startand/or--loadoptions. Not me setting extra bits when--flalready handles it.-i,--immedโ sets theIMMbit on the START STOP UNIT command so this utility will return immediately and not wait for the media to complete the requested action. The default is to wait until the media to complete the requested action before returning.-l,--loadโ load the medium in the drive and start it. Only appropriate for a removable medium.-L,--loejโ sets theLOEJbit on the START STOP UNIT command. This loads the media when the unit is started or eject it when the unit is stopped (i.e. works in conjunction withSTARTbit in cdb). This option is ignored ifpc > 0. Default is off (i.e. donโt attempt to load or eject media). If neither--startnor--stopis given and this option is given then a load and start action is assumed.-m,--mod=PC_MODโ wherePC_MODis the โpower condition modifierโ value.0to15(inclusive) are valid and0is the default. This โpower condition modifierโ field in the cdb was added aftersbc3r13.-n,--noflushโ do not perform a flush to media (e.g. likeSYNCHRONIZE CACHEdoes) before a variant of this utility that limits access to the media. Using the--stopoption is an example of something that limits access to the media. This โnoflushโ field in the cdb was added aftersbc3r13.-O,--oldโ switch to older style options. Please use as first option.-p,--pc=PCโ wherePCis the โpower conditionsโ value.0to15(inclusive) are valid. Default value is0. When--pc=0then--eject,--load,--loej,--startand--stopare active. Some common values are1for the โactiveโ power condition (SBC);2for the idle power condition;3for the standby power condition;5for sleep power condition (MMC);7forLU_CONTROL(SBC),0xa(decimal10) forFORCE_IDLE_0(SBC) and0xb(decimal11) forFORCE_STANDBY_0(SBC). See recent SBC-3, MMC-5 and SAS drafts atwww.t10.orgfor more information. So many power conditions, so little time.-r,--readonlyโ open theDEVICEin read-only mode. Maybe required in Linux to stop a nuisance spin-up if theDEVICEis an ATA disk. The nuisance spin-up may occur at the end of this command negating the effect of the--stopoption.-s,--startโ start (spin-up) theDEVICE. This sets theSTARTbit in the cdb. Using this option on an already started device is harmless. In the absence of other options, this option defaults (i.e. set theSTARTcdb bit).-S,--stopโ stop (spin-down) theDEVICE. This clears theSTARTbit in the cdb. This operation is typically done on a hard disk or SSD. In the case of a SSD it will be placed in low power mode and may need a start operation later before normal IO can resume.-v,--verboseโ increase the level of verbosity. Can be used multiple times.-V,--versionโ print out version string then exit.
๐ NOTES ๐
To avoid confusion, only one of 0, 1, --eject, --load, --start and --stop should be given. Pick one lane, bestie. ๐
There is an associated โpower conditionโ mode page (0x1a) in which timer values can be set for transitioning to either idle or standby state after a period of inactivity. The sdparm utility can be used to view the power condition mode page and if required change it. If a DEVICE is in either idle or standby power condition state then a REQUEST SENSE command (see the sg_requests utility) should yield a sense key of โno senseโ and an additional sense code of โLow power condition onโ on recent SCSI devices.
Ejection of removable media (e.g. sg_start --eject /dev/hdd where the DEVICE is an ATAPI cd/dvd drive) may be prevented by a prior SCSI PREVENT ALLOW MEDIUM REMOVAL command (see sg_prevent). In this case this utility should fail with an error generated by the device: illegal request / medium removal prevented. This can be overridden using sg_prevent or, for example, sdparm --command=unlock /dev/hdd.
The SCSI TEST UNIT READY command can be used to find out whether a DEVICE is ready to transfer data. If rotating media is stopped or still coming up to speed, then the TEST UNIT READY command will yield a โnot readyโ sense key and a more informative additional sense code. See the sg_turs utility.
In the 2.4 series of Linux kernels the DEVICE must be a SCSI generic (sg) device. In the 2.6 series block devices (e.g. SCSI disks and DVD drives) can also be specified. For example sg_start 0 /dev/sda will work in the 2.6 series kernels.
In the Linux 2.6 series, especially with ATA disks, using this utility to stop (spin down) a disk may not be sufficient and other mechanisms will start the disk again some time later. The user might additionally mark the disk as โofflineโ with echo offline > /sys/block/sda/device/state where sda is the block name of the disk. To restart the disk โofflineโ can be replaced with โrunningโ. Note that once the โstateโ is set to offline, no SCSI commands can be sent to the device until it is set back to running. Also stopping a disk via a pass-through interface (e.g. /dev/sg1 or /dev/bsg/1:0:0:0) may reduce unwanted side effects (such as restarting it again when this utility completes). fr fr, the disk has a mind of its own sometimes.
๐ EXIT STATUS ๐
The exit status of sg_start is 0 when it is successful. Otherwise see the sg3_utils(8) man page.
๐ฐ๏ธ OLDER COMMAND LINE OPTIONS ๐ฐ๏ธ
okay bestie, history lesson time โจ these are the options that were literally the only ones available before sg3_utils version 1.23. Since then, this utility defaults to the newer command line options, but you can override that by using --old (or -O) as the first option. And yes, there's another way to force the old-school behavior โ peep the ENVIRONMENT VARIABLES section below ๐
Heads up, bestie: the action of--loejis slightly different in the older interface. When neither--startnor--stop(nor proxies for them) are given,--loejperforms an eject operation. In that same situation, the newer interface will perform a load operation. It's giving "same flag, different era" ๐ญ
Also, earlier versions of sg_start had a -s option to perform a SYNCHRONIZE CACHE command before the START STOP UNIT command was issued. According to recent SBC-2 drafts, this is done implicitly if required. Hence the -s option has been dropped. RIP to a real one ๐ซถ
All options, other than -v and -V, can be given with a single -. For example:
sg_start -stop /dev/sda
and
sg_start --stop /dev/sda
are equivalent. The single - form is for backward compatibility. slay for legacy support ๐
0โ stop (spin-down) DEVICE.1โ start (spin-up) DEVICE.--ejectโ stop the medium and eject it from the drive.--fl=FLโ sets the format layer number for the disc to "jump" to (defined in MMC-5).-iโ sets theIMMbit on theSTART STOP UNITcommand so this utility will return immediately and not wait for the media to spin down. Same effect as--imm=1. The default action (without this option or a--imm=1option) is to wait until the media spins down before returning.--imm=0|1โ when the immediate bit is1, then this utility returns immediately after the DEVICE has received the command. When this option is0(the default), then the utility returns once the command has completed its action (i.e. it waits until the device is started or stopped).--loadโ load the medium in the drive and start it.--loejโ sets theLOEJbit in theSTART STOP UNITcdb. When a "start" operation is indicated, then a load and start is performed. When a "stop" operation is indicated, then a stop and eject is performed. When neither a "start" or "stop" operation is indicated, does a stop and eject. [Note that the last action differs from the new interface, in which the option of this name defaults to load and start.]-N,--newโ switch to the newer style options.--mod=PC_MODโ where PC_MOD is the 'power condition modifier' value.0to15(inclusive) are valid and0is the default. This field was added aftersbc3r13.--noflushโ do not perform a flush to media (e.g. likeSYNCHRONIZE CACHEdoes) before a variant of this utility that limits access to the media. Using the--stopoption is an example of something that limits access to the media. This field was added aftersbc3r13.--pc=PCโ where PC is the 'power condition' value (in hex).0tof(inclusive) are valid. Default value is0.-rโ see the--readonlyoption above. May be useful for ATA disks.--startโ start (spin-up) DEVICE.--stopโ stop (spin-down) DEVICE. Same meaning as the"0"argument.-vโ verbose: outputs SCSI command in hex to console before executing it.-vvand-vvvare also accepted, yielding greater verbosity.-Vโ print out version string then exit.
๐ฑ ENVIRONMENT VARIABLES ๐ฑ
Since sg3_utils version 1.23, the environment variable SG3_UTILS_OLD_OPTS can be given. When it is present, this utility will expect the older command line options. So the presence of this environment variable is equivalent to using --old (or -O) as the first command line option. lowkey iconic behavior tbh ๐
โจ
๐ AUTHOR ๐
Written by K. Garloff and D. Gilbert. absolute legends, no cap ๐ซถ
๐ REPORTING BUGS ๐
Report bugs to <dgilbert at interlog dot com>. bestie, be nice and include the details ๐
๐ COPYRIGHT ๐
Copyright ยฉ 2002-2021 Kurt Garloff, Douglas Gilbert.
This software is distributed under the GPL version 2. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
๐ SEE ALSO ๐
sg_prevent(sg3_utils)sg_requests(sg3_utils)sg_turs(sg3_utils)sdparm(sdparm)lsscsi(lsscsi)
and that's the whole vibe, bestie ๐ this page is from sg3_utils-1.47, dated April 2021 โ go forth and spin things up/down responsibly ๐
โจ๐
๐ฆ where this page comes from
- arch rolling: sg3_utils 1.49-1 ยท GPL-2.0-or-later AND BSD-2-Clause
- nixpkgs unstable: sg3_utils 1.49
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms