1SG_FORMAT(8)                       SG3_UTILS                      SG_FORMAT(8)
2
3
4

NAME

6       sg_format - format, resize a SCSI disk or format a tape
7

SYNOPSIS

9       sg_format    [--cmplst={0|1}]    [--count=COUNT]   [--dcrt]   [--early]
10       [--ffmy=FFMT] [--fmtpinfo=FPI] [--format] [--help] [--ip_def]  [--long]
11       [--mode=MP]  [--pfu=PFU]  [--pie=PIE]  [--pinfo] [--poll=PT] [--resize]
12       [--rto_req] [--security] [--six] [--size=SIZE] [--tape=FM]  [--verbose]
13       [--verify] [--version] [--wait] DEVICE
14

DESCRIPTION

16       Not  all  SCSI direct access devices need to be formatted and some have
17       vendor specific formatting procedures. SCSI disks with  rotating  media
18       are  probably  the  largest  group  that do support a 'standard' format
19       operation. They are typically factory formatted to a block size of  512
20       bytes  with  the  largest number of blocks that the manufacturer recom‐
21       mends. The manufacturer's recommendation typically leaves aside a  cer‐
22       tain  number  of  tracks,  spread across the media, for reassignment of
23       blocks to logical block addresses during the life of the disk.
24
25       This utility can format modern SCSI disks and potentially change  their
26       block  size (if permitted) and the block count (i.e. number of accessi‐
27       ble blocks on the media also known as "resizing"). Resizing a  disk  to
28       less  than  the  manufacturer's  recommended  block  count is sometimes
29       called "short stroking" (see NOTES section). Resizing the  block  count
30       while  not  changing the block size may not require a format operation.
31       The SBC-2 standard (see www.t10.org) has obsoleted the "format  device"
32       mode  page.  Many  of the low level details found in that mode page are
33       now left up to the discretion of the manufacturer.
34
35       When this utility is used without options (i.e.  it  is  only  given  a
36       DEVICE  argument) it prints out the existing block size and block count
37       derived from two sources. These two sources are a block  descriptor  in
38       the  response to a MODE SENSE command and the response to a READ CAPAC‐
39       ITY command.  The reason for this double check is to detect  a  "format
40       corrupt"  state (see the NOTES section). This usage will not modify the
41       disk.
42
43       When this utility is used with the "--format" (or "-F") option it  will
44       attempt  to  format the given DEVICE. There is a 15 second pause during
45       which time the user is  invited  thrice  (5  seconds  apart)  to  abort
46       sg_format.  This  occurs  just prior the SCSI FORMAT UNIT command being
47       issued. See the NOTES section for more information.
48
49       Protection information is optional and is made up of one or  more  pro‐
50       tection intervals, each made up of 8 bytes associated with each logical
51       block. Four protection types are defined with protection type  0  being
52       no  protection  intervals. See the PROTECTION INFORMATION section below
53       for more information.
54
55       When the --tape=FM option is given then the SCSI FORMAT MEDIUM  command
56       is  sent  to the DEVICE. FORMAT MEDIUM is defined in SSC and prepares a
57       volume for use which may include partitioning the medium. See the  sec‐
58       tion below on TAPE for more information.
59

OPTIONS

61       Arguments to long options are mandatory for short options as well.  The
62       options are arranged in alphabetical order based  on  the  long  option
63       name.
64
65       -C, --cmplst={0|1}
66              sets  the CMPLST ("complete list") bit in the FORMAT UNIT cdb to
67              0 or 1.  The default is 1  in  which  case  the  existing  GLIST
68              (grown  list)  is  ignored.  If the value is 0 then the existing
69              GLIST is taken into account. See the  LISTS  section  below.  In
70              most cases this bit should be left set; some MO disk drives need
71              this bit cleared.
72
73       -c, --count=COUNT
74              where COUNT is the number of blocks to be formatted or media  to
75              be  resized  to.  Can  be used with either --format or --resize.
76              With --format this option need not be given in which case it  is
77              assumed  to  be  zero. With --format the interpretation of COUNT
78              is:
79                (COUNT > 0) : only format the first COUNT blocks and READ
80                              CAPACITY will report COUNT blocks after format
81                (COUNT = 0) and block size  unchanged  :  use  existing  block
82              count
83                (COUNT = 0) and block size changed : recommended maximum block
84                                                     count for new block size
85                (COUNT = -1) : use recommended maximum block count
86                (COUNT < -1) : illegal
87              With  --resize  this  option  must  be  given and COUNT has this
88              interpretation:
89                (COUNT > 0) : after resize READ CAPACITY will report COUNT
90                              blocks
91                (COUNT = 0) : after resize READ CAPACITY will report 0 blocks
92                (COUNT = -1) : after resize READ CAPACITY will report its
93                               maximum number of blocks
94                (COUNT < -1) : illegal
95              In both cases if the given COUNT exceeds the maximum  number  of
96              blocks (for the block size) then the disk reports an error.  See
97              NOTES section below.
98
99       -D, --dcrt
100              this option sets the DCRT  bit  in  the  FORMAT  UNIT  command's
101              parameter list header. It will "disable certification". Certifi‐
102              cation  verifies  that  blocks  are  usable  during  the  format
103              process.  Using  this  option may speed the format.  The default
104              action of this utility (i.e. when this option is not  given)  is
105              to  clear the DCRT bit thereby requesting "media certification".
106              When the DCRT bit is set, the FOV bit must  also  be  set  hence
107              sg_format does that.
108
109       -e, --early
110              during a format operation, The default action of this utility is
111              to poll the disk every 60 seconds to determine the  progress  of
112              the  format  operation until it is finished. When this option is
113              given this utility will exit "early", that is  as  soon  as  the
114              format  operation  has  commenced. Then the user can monitor the
115              progress of the ongoing format operation  with  other  utilities
116              (e.g.  sg_turs(8) or sg_requests(8)). This option and --wait are
117              mutually exclusive.
118
119       -t, --ffmt=FFMT
120              FFMT is placed in a field of the same name in  the  FORMAT  UNIT
121              cdb.  The field was introduced in SBC-4 revision 10. The default
122              value is 0 which implies the former action to typically write to
123              all blocks on the DEVICE and that can take a long time.
124              FFMT  has  values  1 and 2 for fast format with 3 being reserved
125              currently. The difference between 1 and 2 concerns  read  opera‐
126              tions  on  LBAs  to which no data has been written to, since the
127              fast format. When FFMT is 1 the  read  operation  should  return
128              "unspecified  logical  block  data"  and complete without error.
129              When FFMT is 2 the read operation should yield  check  condition
130              status  with  a sense key set to hardware error, medium error or
131              command aborted. See SBC-4 revsion  10  section  4.35  for  more
132              details.
133
134       -f, --fmtpinfo=FPI
135              sets  the  FMTPINFO  field  in  the  FORMAT  UNIT cdb to a value
136              between 0 and 3.  The default value is  0.  The  FMTPINFO  field
137              from  SBC-3 revision 16 is a 2 bit field (bits 7 and 6 of byte 1
138              in the cdb). Prior to that it was a single bit field (bit  7  of
139              byte  1  in  the  cdb)  and there was an accompanying bit called
140              RTO_REQ (bit 6 of byte 1 in the  cdb).  The  deprecated  options
141              "--pinfo" and "--rto-req" represent the older usage. This option
142              should be used in their place. See  the  PROTECTION  INFORMATION
143              section below for more information.
144
145       -F, --format
146              issue  a  SCSI  FORMAT  UNIT command.  This will destroy all the
147              data held on the media.  This option is required to  change  the
148              block  size  of a disk. The user is given a 15 second count down
149              to ponder the wisdom of doing this, during which time  control-C
150              (amongst  other  Unix commands) can be used to kill this process
151              before it does any damage.
152              When used three times (or more) the preliminary MODE  SENSE  and
153              SELECT  commands  are bypassed, leaving only the initial INQUIRY
154              and FORMAT UNIT commands. This is for emergency use  (e.g.  when
155              the  MODE  SENSE/SELECT  commands  are  not  working) and cannot
156              change the logical block size.
157              See NOTES section for implementation details and  EXAMPLES  sec‐
158              tion for typical use.
159
160       -h, --help
161              print out the usage information then exit.
162
163       -I, --ip_def
164              sets  the  default Initialization Pattern. Some disks (SSDs) use
165              this to flag that a format should fully  provision  (i.e.  asso‐
166              ciate a physical block with every logical block). The same disks
167              (SSDs) might thin provision if this option is not given. If this
168              option is given then the --security option cannot be given.
169
170       -l, --long
171              the  default  action of this utility is to assume 32 bit logical
172              block addresses. With 512 byte block size this permits more than
173              2 terabytes (almost 2 ** 41 bytes) on a single disk. This option
174              selects commands and parameters that allow for  64  bit  logical
175              block  addresses.   Specifically  this option sets the "longlba"
176              flag in the MODE SENSE (10) command and uses READ CAPACITY  (16)
177              rather  than READ CAPACITY (10). If this option is not given and
178              READ CAPACITY (10) or MODE SELECT detects a disk the needs  more
179              than  32  bits  to  represent  its logical blocks then it is set
180              internally. This option does not set the  LONGLIST  bit  in  the
181              FORMAT UNIT command. The LONGLIST bit is set as required depend‐
182              ing other parameters (e.g.  when  '--pie=PIE'  is  greater  than
183              zero).
184
185       -M, --mode=MP
186              MP  is  a mode page number (0 to 62 inclusive) that will be used
187              for reading and perhaps changing the device logical block  size.
188              The  default  is  1  which is the Read-Write Error Recovery mode
189              page.
190
191       -P, --pfu=PFU
192              sets the "Protection Field Usage" field in the  parameter  block
193              associated  with a FORMAT UNIT command to PFU. The default value
194              is 0, the only other defined value currently is 1. See the  PRO‐
195              TECTION INFORMATION section below for more information.
196
197       -q, --pie=PIE
198              sets  the  "Protection Interval Exponent" field in the parameter
199              block associated with a FORMAT UNIT command to PIE. The  default
200              value  is  0.   PIE can only be non-zero with protection types 2
201              and 3.  The value of 0 is typical for 512 byte blocks; with 4096
202              byte  blocks  a value of 3 may be appropriate (i.e. 8 protection
203              intervals interleaved with 4096 bytes of user  data).  A  device
204              may  not  support any non-zero values. This field first appeared
205              in SBC-3 revision 18.
206
207       -p, --pinfo
208              this  option  is  deprecated,  use  the  --fmtpinfo=FPI   option
209              instead.   If  used,  then it sets bit 7 of byte 1 in the FORMAT
210              UNIT cdb and that is equivalent to setting --fmtpinfo=2. [So  if
211              --pinfo is used (plus --fmtpinfo=FPI and --pfu=PFU are not given
212              or their arguments are 0) then protection type 1 is selected.]
213
214       -x, --poll=PT
215              where PT is the type of poll used. If PT is 0 then a  TEST  UNIT
216              READY  command  is  used,  otherwise  a REQUEST SENSE command is
217              used. The default is currently 0 but this will change  to  1  in
218              the near future. See the NOTES sections below.
219
220       -r, --resize
221              rather  than  format  the  disk,  it  can be resized. This means
222              changing the number of blocks on the device reported by the READ
223              CAPACITY   command.    This  option  should  be  used  with  the
224              --count=COUNT option.  The contents of all logical blocks on the
225              media remain unchanged when this option is used. This means that
226              any resize operation can be reversed. This option cannot be used
227              together with either --format or a --size=SIZE whose argument is
228              different to the existing block size.
229
230       -R, --rto_req
231              The option is deprecated, use the --fmtpinfo=FPI option instead.
232              If used, then it sets bit 6 of byte 1 in the FORMAT UNIT cdb.
233
234       -S, --security
235              sets  the  "Security Initialization" (SI) bit in the FORMAT UNIT
236              command's initialization pattern descriptor within the parameter
237              list.  According  to  SBC-3  the  default initialization pattern
238              "shall be written using a security erasure write technique". See
239              the  NOTES  section on the SCSI SANITIZE command. If this option
240              is given then the --ip_def option cannot be given.
241
242       -6, --six
243              Use 6 byte variants of MODE SENSE and MODE SELECT.  The  default
244              action  is to use the 10 byte variants. Some MO drives need this
245              option set when doing a format.
246
247       -s, --size=SIZE
248              where SIZE is the block size  (i.e.  number  of  bytes  in  each
249              block) to format the device to. The default value is whatever is
250              currently reported by the block descriptor in a MODE SENSE  com‐
251              mand.  If  the block size given by this option is different from
252              the current value then a MODE SELECT command is used  to  change
253              it  prior  to  the  FORMAT UNIT command being started (as recom‐
254              mended in the draft standard). Many SCSI  disks  have  512  byte
255              sectors  by  default  and allow up to 16 bytes extra in a sector
256              (i.e. 528 byte sectors).  If the given size in unacceptable with
257              the  disk, most likely an "Invalid field in parameter list" mes‐
258              sage will appear in sense data (requires  the  use  of  '-v'  to
259              decode sense data).
260
261       -T, --tape=FM
262              will  send a FORMAT MEDIUM command to the DEVICE with the FORMAT
263              field set to FM. This option is used to prepare a tape (i.e. the
264              "medium") in a tape drive for use. Values for FM include 0 to do
265              the "default" format; 1 to partition a volume  and  2  to  do  a
266              default format then partition.
267
268       -v, --verbose
269              increase  the  level  of  verbosity, (i.e. debug output). "-vvv"
270              gives a lot more debug output.
271
272       -y, --verify
273              set the VERIFY bit in the FORMAT MEDIUM cdb. The default is that
274              the  VERIFY  bit  is  clear. This option is only appropriate for
275              tapes.
276
277       -V, --version
278              print the version string and then exit.
279
280       -w, --wait
281              the default format action is to set the "IMMED" bit in the  FOR‐
282              MAT  UNIT  command's  (short)  parameter  header. If this option
283              (i.e. --wait) is given then the  "IMMED"  bit  is  not  set.  If
284              --wait  is  given the FORMAT UNIT command waits until the format
285              operation completes before returning its response. This  can  be
286              many  hours  on large disks. This utility sets a 15 hour timeout
287              on such a FORMAT UNIT command! Some recent SSDs go to the  other
288              extreme  of  completing  a format operation in 1.5 seconds hence
289              waiting is not an issue.
290

LISTS

292       The SBC-3 draft (revision 36) defines PLIST, CLIST, DLIST and GLIST  in
293       section  4.13  on "Medium defects". Briefly, the PLIST is the "primary"
294       list of manufacturer detected defects, the CLIST ("certification" list)
295       contains  those  detected  during  the format operation, the DLIST is a
296       list of defects that can be given to the format operation. The GLIST is
297       the  grown  list  which starts in the format process as CLIST+DLIST and
298       can "grow" later due to automatic reallocation (see the ARRE  and  AWRE
299       bits  in  the  Read-Write Error Recovery mode page (see sdparm(8))) and
300       use of the SCSI REASSIGN BLOCKS command (see sg_reassign(8)).
301
302       The CMPLST bit  (controlled  by  the  --cmplst=0|1  option)  determines
303       whether  the  existing  GLIST, when the format operation is invoked, is
304       taken into account. The sg_format utility sets  the  FOV  bit  to  zero
305       which causes DPRY=0, so the PLIST is taken into account, and DCRT=0, so
306       the CLIST is generated and used during the format process.
307
308       The sg_format utility does not permit a user to provide a  defect  list
309       (i.e. DLIST).
310

PROTECTION INFORMATION

312       Protection Information (PI) is additional information held with logical
313       blocks so that an application and/or host bus  adapter  can  check  the
314       correctness  of  those logical blocks. PI is placed in one or more pro‐
315       tection intervals beside each logical block. A protection interval con‐
316       tains 8 bytes made up of a 2 byte "logical block guard" (CRC), a 2 byte
317       "logical block application guard", and a 4 byte "logical  block  refer‐
318       ence  tag". Devices with 512 byte logical block size typically have one
319       protection interval appended, making its logical block data  520  bytes
320       long. Devices with 4096 byte logical block size often have 8 protection
321       intervals spread across its logical block data for a total size of 4160
322       bytes.  Note that for all other purposes the logical block size is con‐
323       sidered to be 512 and 4096 bytes respectively.
324
325       SBC-3 drafts have added several "protection types" to the PI introduced
326       in  the SBC-2 standard. SBC-3 defines 4 protection types (types 0 to 3)
327       with protection type 0 meaning no PI is maintained. While a device  may
328       support  one  or more protection types, it can only be formatted with 1
329       of the 4. To change a device's protection type, it must  be  re-format‐
330       ted.  For  more  information  see the Protection Information in section
331       4.22 of draft SBC-3 revision 36.
332
333       A device that supports PI information (i.e. supports one or  more  pro‐
334       tection  types  1,  2  and  3)  sets  the "PROTECT" bit in its standard
335       INQUIRY response. It also sets the SPT field in  the  EXTENDED  INQUIRY
336       VPD page response to indicate which protection types it supports. Given
337       PROTECT=1 then SPT=0 implies the device supports PI type 1 only,  SPT=1
338       implies  the  device  supports  PI  types  1  and  2, and various other
339       non-obvious mappings up to SPT=7 which implies protection  types  1,  2
340       and 3 are supported. The current protection type of a disk can be found
341       in the "P_TYPE" and "PROT_EN" fields in the response of a READ CAPACITY
342       (16) command (e.g. with the 'sg_readcap --long' utility).
343
344       Given  that  a device supports a particular protection type, a user can
345       then choose to format that disk with that protection  type  by  setting
346       the  "FMTPINFO"  and "Protection Field Usage" fields in the FORMAT UNIT
347       command.  Those  fields  correspond  to  the  --fmtpinfo=FPI  and   the
348       --pfu=PFU  options  in this utility. The list below shows the four pro‐
349       tection types followed by the options of this utility needed to  select
350       them:
351         0 : --fmtpinfo=0 --pfu=0
352         1 : --fmtpinfo=2 --pfu=0
353         2 : --fmtpinfo=3 --pfu=0
354         3 : --fmtpinfo=3 --pfu=1
355       The default value of FPI (in --fmtpinfo=FPI) is 0 and the default value
356       of PFU (in --pfu=PFU) is 0. So if neither --fmtpinfo=FPI nor  --pfu=PFU
357       are  given  then  protection type 0 (i.e. no protection information) is
358       chosen.
359

NOTES

361       The SBC-2 standard states that the REQUEST SENSE command should be used
362       for  obtaining progress indication when the format command is underway.
363       However, tests on a selection of disks shows that TEST UNIT READY  com‐
364       mands  yield  progress indications (but not REQUEST SENSE commands). So
365       the current version of this utility defaults to using TEST  UNIT  READY
366       commands  to  poll the disk to find out the progress of the format. The
367       --poll=PT option has been added to control this.
368
369       When the --format option is given without the --wait  option  then  the
370       SCSI  FORMAT UNIT command is issued with the IMMED bit set which causes
371       the SCSI command to return after it has started the  format  operation.
372       The  --early option will cause sg_format to exit at that point.  Other‐
373       wise the DEVICE is polled every 60 seconds  with  TEST  UNIT  READY  or
374       REQUEST SENSE commands until it reports an "all clear" (i.e. the format
375       operation has completed). Normally these polling commands  will  result
376       in a progress indicator (expressed as a percentage) being output to the
377       screen.  If the user gets  bored  watching  the  progress  report  then
378       sg_format  process  can  be  terminated  (e.g.  with control-C) without
379       affecting the format operation which continues.  However  a  target  or
380       device  reset  (or  a  power  cycle)  will probably cause the device to
381       become "format corrupt".
382
383       When the --format and --wait options are both given then  this  utility
384       may  take  a long time to return. In this case care should be taken not
385       to send any other SCSI commands to the disk as it may not respond leav‐
386       ing  those  commands  queued behind the active format command. This may
387       cause a timeout in the OS driver (in a lot shorter period than 15 hours
388       applicable to some format operations). This may result in the OS reset‐
389       ting the disk leaving the format operation incomplete. This  may  leave
390       the disk in a "format corrupt" state requiring another format to remedy
391       the situation.
392
393       When the block size (i.e. the number of bytes in each block) is changed
394       on  a  disk two SCSI commands must be sent: a MODE SELECT to change the
395       block size followed by a FORMAT command. If  the  MODE  SELECT  command
396       succeeds  and the FORMAT fails then the disk may be in a state that the
397       draft standard calls "format corrupt". A block descriptor in  a  subse‐
398       quent  MODE SENSE will report the requested new block size while a READ
399       CAPACITY command will report the existing (i.e. different) block  size.
400       Alternatively  the READ CAPACITY command may fail, reporting the device
401       is not ready, potentially requiring a format. The solution to this sit‐
402       uation  is  to do a format again (and this time the new block size does
403       not have to be given) or change the block size  back  to  the  original
404       size.
405
406       The  SBC-2  standard states that the block count can be set back to the
407       manufacturer's maximum recommended value in a format or  resize  opera‐
408       tion.   This can be done by placing an address of 0xffffffff (or the 64
409       bit equivalent) in the appropriate block descriptor  field  to  a  MODE
410       SELECT command. In signed (two's complement) arithmetic that value cor‐
411       responds to  the  manufacturer's  maximum  recommended  value.  To  see
412       exactly  which  SCSI  commands are being executed and parameters passed
413       add the "-vvv" option to the sg_format command line.
414
415       Short stroking is a technique to trade off  capacity  for  performance.
416       Rotating  disk performance is usually highest on the outer tracks (i.e.
417       lower logical block addresses) so by resizing or reformatting a disk to
418       a smaller capacity, average performance will usually be increased.
419
420       Other  utilities  may  be useful in finding information associated with
421       formatting. These include sg_inq(8) to fetch standard INQUIRY  informa‐
422       tion  (e.g. the PROTECT bit) and to fetch the EXTENDED INQUIRY VPD page
423       (e.g. RTO and GRD_CHK bits). The  sdparm(8)  utility  can  be  used  to
424       access and potentially change the now obsolete format mode page.
425
426       scsiformat  is another utility available for formatting SCSI disks with
427       Linux. It dates from 1997 (most recent update) and may  be  useful  for
428       disks whose firmware is of that vintage.
429
430       The  COUNT  numeric  argument may include a multiplicative suffix or be
431       given in hexadecimal.  See  the  "NUMERIC  ARGUMENTS"  section  in  the
432       sg3_utils(8) man page.
433
434       The  SCSI  SANITIZE  command was introduced in SBC-3 revision 27. It is
435       closely related to the ATA sanitize disk feature set and can be used to
436       remove  all  existing  data  from a disk. Sanitize is more likely to be
437       implemented on modern disks (including SSDs) than FORMAT  UNIT's  secu‐
438       rity  initialization  feature  (see  the --security option) and in some
439       cases much faster.
440
441       SSDs that support thin provisioning will typically  unmap  all  logical
442       blocks  during  a format. The reason is to improve the SSD's endurance.
443       Also thin provisioned formats typically complete faster than fully pro‐
444       visioned  ones  on  the  same disk (see the --ip_def option). In either
445       case format operations on SSDs tend to be a lot faster than they are on
446       hard disks with spinning media.
447

TAPE

449       Tape  system  use  a  variant of the FORMAT UNIT command used on disks.
450       Tape systems use the FORMAT MEDIUM command which is simpler  with  only
451       three  fields  in  the  cdb typically used. Apart from sharing the same
452       opcode the cdbs of FORMAT UNIT and FORMAT MEDIUM are  quite  different.
453       FORMAT  MEDIUM's  fields  are  VERIFY,  IMMED and FORMAT (with TRANSFER
454       LENGTH always set to 0).  The VERIFY bit field is set with the --verify
455       option.  The  IMMED bit is manipulated by the --wait option in the same
456       way it is for disks; one difference is that if the --poll=PT option  is
457       not given then it defaults to PT of 1 which means the poll is done with
458       REQUEST SENSE commands.
459
460       The argument given to the --tape=FM option is used to  set  the  FORMAT
461       field.  FM  can  take values from "-1" to "15" where "-1" (the default)
462       means don't do a tape format; value "8" to "15" are for vendor specific
463       formats.  The  --early option may also be used to set the IMMED bit and
464       then exit this utility (rather than poll periodically until it is  fin‐
465       ished). In this case the tape drive will still be busy doing the format
466       for some time but, according to T10, should still respond  in  full  to
467       the INQUIRY and REPORT LUNS commands. Other commands (including REQUEST
468       SENSE) should yield a "not ready" sense key with  an  additional  sense
469       code  of  "Logical  unit  not  ready, format in progress". Additionally
470       REQUEST SENSE should contain a progress indication in its sense data.
471
472       When FM is 1 or 2 then the settings in the Medium partition  mode  page
473       control  the  partitioning.  That  mode page can be viewed and modified
474       with the sdparm utility.
475
476       Prior to invoking this utility the tape may need to  be  positioned  to
477       the  beginning of partition 0. In Linux that can typically be done with
478       the mt utility (e.g. 'mt -f /dev/st0 rewind').
479

EXAMPLES

481       These examples use Linux device names. For  suitable  device  names  in
482       other supported Operating Systems see the sg3_utils(8) man page.
483
484       In the first example below simply find out the existing block count and
485       size derived from two sources: a block descriptor in a MODE SELECT com‐
486       mand  response  and  from  the response of a READ CAPACITY commands. No
487       changes are made:
488
489          # sg_format /dev/sdm
490
491       Now a simple format, leaving the block count and size as they were pre‐
492       viously.   The  FORMAT  UNIT  command is executed in IMMED mode and the
493       device is polled every 60 seconds to print out a progress indication:
494
495          # sg_format --format /dev/sdm
496
497       Now the same format, but waiting (passively) until the format operation
498       is complete:
499
500          # sg_format --format --wait /dev/sdm
501
502       Next  is  a  format in which the block size is changed to 520 bytes and
503       the block count is set to the manufacturer's maximum  value  (for  that
504       block size). Note, not all disks support changing the block size:
505
506          # sg_format --format --size=520 /dev/sdm
507
508       Now a resize operation so that only the first 0x10000 (65536) blocks on
509       a disk are accessible. The remaining blocks remain unaltered.
510
511          # sg_format --resize --count=0x10000 /dev/sdm
512
513       Now resize the disk back to its normal (maximum) block count:
514
515          # sg_format --resize --count=-1 /dev/sdm
516
517       One reason to format a SCSI disk  is  to  add  protection  information.
518       First check which protection types are supported by a disk (by checking
519       the SPT field in the Extended inquiry VPD page together with  the  Pro‐
520       tect bit in the standard inquiry response):
521
522          # sg_vpd -p ei -l /dev/sdb
523          extended INQUIRY data VPD page:
524            ACTIVATE_MICROCODE=0
525            SPT=1 [protection types 1 and 2 supported]
526            ....
527
528       Format with type 1 protection:
529
530          # sg_format --format --fmtpinfo=2 /dev/sdm
531
532       After  a  successful  format  with type 1 protection, READ CAPACITY(16)
533       should show something like this:
534
535          # sg_readcap -l /dev/sdm
536          Read Capacity results:
537             Protection: prot_en=1, p_type=0, p_i_exponent=0 [type  1  protec‐
538       tion]
539             Logical block provisioning: lbpme=0, lbprz=0
540             ....
541
542       To format with type 3 protection:
543
544          # sg_format --format --fmtpinfo=3 --pfu=1 /dev/sdm
545
546       For  the  disk shown above this will probably fail because the Extended
547       inquiry VPD page showed only types 1 and 2 protection are supported.
548

EXIT STATUS

550       The exit status of sg_format is 0 when it is successful. Otherwise  see
551       the  sg3_utils(8) man page. Unless the --wait option is given, the exit
552       status may not reflect the success of otherwise of the  format.   Using
553       sg_turs(8) and sg_readcap(8) after the format operation may be wise.
554

AUTHORS

556       Written by Grant Grundler, James Bottomley and Douglas Gilbert.
557

REPORTING BUGS

559       Report bugs to <dgilbert at interlog dot com>.
560
562       Copyright  ©  2005-2016  Grant  Grundler,  James  Bottomley and Douglas
563       Gilbert
564       This software is distributed under the GPL version 2. There is NO  war‐
565       ranty;  not  even  for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
566       POSE.
567

SEE ALSO

569       sg_turs(8), sg_requests(8), sg_inq(8), sg_modes(8), sg_vpd(8), sg_reas‐
570       sign(8),    sg_readcap(8),   sg3_utils(8),   sg_sanitize(8)   [all   in
571       sg3_utils], mt(mt-st), sdparm(8), scsiformat (old), hdparm(8)
572
573
574
575sg3_utils-1.42                   February 2016                    SG_FORMAT(8)
Impressum