SG_SEEK(8)
π¦ SG_SEEK(8) β sg_seek from sg3_utils has entered the chat π¦
πΈ NAME πΈ
sg_seek β send SCSI SEEK, PRE-FETCH(10) or PRE-FETCH(16) command π
β¨ SYNOPSIS β¨
sg_seek [--10] [--count=NC] [--grpnum=GN] [--help] [--immed] [--lba=LBA]
[--num-blocks=NUM] [--pre-fetch] [--readonly] [--skip=SB] [--time]
[--verbose] [--version] [--wrap-offset=WO] DEVICE
π DESCRIPTION π
Okay bestie, so sg_seek sends a SCSI SEEK(10), PRE-FETCH(10) or PRE-FETCH(16) command to DEVICE. The SEEK command has been obsolete since SBC-2 (2005), but it still is supported on some hard disks and even some SSDs (solid state disks). The PRE-FETCH command can be viewed as SEEK's modern replacement. Instead of talking about moving the disk heads to the track containing the sort after LBA, it talks about bringing the sort after LBA (and a given number of blocks) into the disk's cache. Also the PRE-FETCH commands have an IMMED field. β¨
The PRE-FETCH commands can report "real" errors but usually they will report one of two "good" statuses. To do this they return the rarely used CONDITION MET status. If the number of blocks does actually fit in the cache (when IMMED=0) or there is enough room in the cache when the command arrives (when IMMED=1) then a CONDITION MET status is returned. If the requested number of blocks did not fit (IMMED=0) or would not fit (IMMED=1) then status GOOD is returned. So if a disk has a large cache and PRE-FETCH is used sparingly then the command is more likely to return CONDITION MET than GOOD. This presents some SCSI sub-systems with problems as due to its rareness they mishandle CONDITION MET and treat it as an error (see NOTES section below). π
π OPTIONS π
Arguments to long options are mandatory for short options as well. No sneaky skipping, bestie π
-T,--10β use a 10 byte cdb command, eitherSEEK(10)orPRE-FETCH(10)command. In the absence of the--pre-fetchoption, theSEEK(10)command is used. If the--pre-fetchoption is given without this option then aPRE-FETCH(16)command is used. π-c,--count=NCβNCis the number of commands (one ofSEEK(10),PRE-FETCH(10)orPRE-FETCH(16)) that will be executed. The default value is1. If an error occurs it is noted and the program continues untilNCis exhausted. IfNCis0then options are checked and theDEVICEis opened but no commands are sent. π«Ά-g,--grpnum=GNβGNis the group number, a value between0and63(in hex:0x3f). The default value is0. This option is ignored if the selected command isSEEK(10). β¨-h,--helpβ output the usage message then exit. Bye bestie π-i,--immedβ this option only applies toPRE-FETCH(10)andPRE-FETCH(16), setting theIMMEDbit. Without this option, theDEVICEreturns after it has completed transferring all, or part of, the requested blocks into the cache. If this option is given theDEVICEreturns after it has done sanity checks on the cdb (e.g. making sure theLBAis greater than the number of available blocks) and before it does the transfer into the cache. Note that even when this option is given, the return status from thePRE-FETCHcommands is still eitherCONDITION METstatus (if the cache seems to have enough free space for the transfer) or aGOODstatus (if the cache does not seem to have enough free space). π-l,--lba=LBAβLBAis the starting logical block address that is placed in the command descriptor block (cdb) of the selected command. Note that theLBAfield inSEEK(10)andPRE-FETCH(10)is a 32 bit quantity, while withPRE-FETCH(16)it is a 64 bit quantity. The default value is0. π-n,--num-blocks=NUMβNUMis the number of blocks, starting at and includingLBA, to place in theDEVICE's cache. TheSEEK(10)command does not use theNUMvalue. ForPRE-FETCH(10)NUMis a 16 bit quantity, while forPRE-FETCH(16)it is a 32 bit quantity. The default value is1. IfNUMis0then theDEVICEwill attempt to transfer all blocks from the givenLBAto the end of the medium. π¦-p,--pre-fetchβ this option selects eitherPRE-FETCH(10)orPRE-FETCH(16)commands. With the--10also given, thePRE-FETCH(10)command is selected; without that optionPRE-FETCH(16)is selected. The default (in the absence of this and other 'selecting' options) theSEEK(10)command is selected. β-r,--readonlyβ this option sets a 'read-only' flag when the underlying operating system opens the givenDEVICE. This may not work since operating systems can not easily determine whether a pass-through is a logical read or write operation so they take a risk averse stance and require read-write typeDEVICEopens irrespective of what is performed by the pass-through. π-s,--skip=SBβSBis the number of logical block addresses to skip, between repeated commands whenNCis greater than1. The default value ofSBis1.SBmay be set to0so that allNCPRE-FETCHcommands use the sameLBA. π-t,--timeβ if given the elapsed time to executeNCcommands is recorded. This is printed out before this utility exits. IfNCis greater than1then the "per command" time is also printed. β±οΈ-v,--verboseβ increase the level of verbosity, (i.e. debug output). π§-V,--versionβ print the version string and then exit. π-w,--wrap-offset=WOβWOis the number of blocks, relative toLBA, that when exceeded, set the next command's logical block address back toLBA. Whether this "reset-to-LBA" action occurs depends on the valuesNCandSB. π₯
π§ NOTES π§
Prior to Linux kernel 4.17 the CONDITION MET status was logged as an error. Recent versions of FreeBSD handle the CONDITION MET status properly. π
If either the --count=NC or --verbose option is given then a summary line like the following is output:
Command count=5, number of condition_mets=3, number of goods=2
before the utility exits. π
π EXIT STATUS π
The exit status of sg_seek is 0 (GOOD) or 25 (CONDITION_MET) when this utility is successful. If multiple commands are executed (e.g. when NC is greater than 1) then the result of the last executed SEEK or PRE-FETCH command sets the exit status. Otherwise see the sg3_utils(8) man page. β¨
π«Ά AUTHORS π«Ά
Written by Douglas Gilbert. π
π REPORTING BUGS π
Report bugs to <dgilbert at interlog dot com>. π
π COPYRIGHT π
Copyright Β© 2018 Douglas Gilbert
This software is distributed under a BSD-2-Clause license. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. π
π SEE ALSO π
sg_vpd(sg3_utils); sdparm(sdparm) π¦
signed, sealed, from the SG3_UTILS source β version sg3_utils-1.43, dated September 2018. mwah πβ¨
π¦ 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