164
164
This field first appeared in SBC\-3 revision 18.
166
166
\fB\-p\fR, \fB\-\-pinfo\fR
167
The option is deprecated, use the \fI\-\-fmtpinfo=FPI\fR option instead.
168
If used, then it sets bit 7 of byte 1 in the FORMAT UNIT cdb.
167
this option is deprecated, use the \fI\-\-fmtpinfo=FPI\fR option instead.
168
If used, then it sets bit 7 of byte 1 in the FORMAT UNIT cdb and that
169
is equivalent to setting \fI\-\-fmtpinfo=2\fR. [So if \fI\-\-pinfo\fR is
170
used (plus \fI\-\-fmtpinfo=FPI\fR and \fI\-\-pfu=PFU\fR are not given or
171
their arguments are 0) then protection type 1 is selected.]
170
173
\fB\-x\fR, \fB\-\-poll\fR=\fIPT\fR
171
174
where \fIPT\fR is the type of poll used. If \fIPT\fR is 0 then a TEST UNIT
251
254
protection information are added to each logical block (a 2 byte "logical
252
255
block guard" (CRC), a 2 byte "logical block application guard", and a 4
253
256
byte "logical block reference tag"). SBC\-3 defines 4 protection
254
types (types 0 to 4) with protection type 0 meaning no protection information
257
types (types 0 to 3) with protection type 0 meaning no protection information
257
260
A device that supports protection information (i.e. supports one or more
266
269
then choose to format that disk with that protection type by setting
267
270
the "FMTPINFO" and "Protection Field Usage" fields in the FORMAT UNIT
268
271
command. Those fields correspond to the \fI\-\-fmtpinfo=FPI\fR and the
269
\fI\-\-pfu=PFU\fR options in this utility. If \fIFPI\fR and \fIPFU\fR are
270
both 0 (their default values) then protection type 0 is chosen. If \fIFPI\fR
271
is 2 and \fIPFU\fR is 0 then protection type 1 is chosen. If \fIFPI\fR is 3
272
and \fIPFU\fR is 0 then protection type 2 is chosen. If \fIFPI\fR is 3 and
273
\fIPFU\fR is 1 then protection type 3 is chosen.
272
\fI\-\-pfu=PFU\fR options in this utility. The list below shows the four
273
protection types followed by the options of this utility needed to select
276
\fB0\fR : \-\-fmtpinfo=0 \-\-pfu=0
278
\fB1\fR : \-\-fmtpinfo=2 \-\-pfu=0
280
\fB2\fR : \-\-fmtpinfo=3 \-\-pfu=0
282
\fB3\fR : \-\-fmtpinfo=3 \-\-pfu=1
284
The default value of \fIFPI\fR (in \fI\-\-fmtpinfo=FPI\fR) is 0 and the
285
default value of \fIPFU\fR (in \fI\-\-pfu=PFU\fR) is 0. So if neither
286
\fI\-\-fmtpinfo=FPI\fR nor \fI\-\-pfu=PFU\fR are given then protection
287
type 0 (i.e. no protection information) is chosen.
275
289
The SBC\-2 standard states that the REQUEST SENSE command should be used
276
290
for obtaining progress indication when the format command is underway.
358
372
response and from the response of a READ CAPACITY commands. No changes
363
377
Now a simple format, leaving the block count and size as they were previously.
364
378
The FORMAT UNIT command is executed in IMMED mode and the device is polled
365
379
every 60 seconds to print out a progress indication:
367
sg_format \-\-format /dev/sdm
381
# sg_format \-\-format /dev/sdm
369
383
Now the same format, but waiting (passively) until the format operation is
372
sg_format \-\-format \-\-wait /dev/sdm
386
# sg_format \-\-format \-\-wait /dev/sdm
374
388
Next is a format in which the block size is changed to 520 bytes and the block
375
389
count is set to the manufacturer's maximum value (for that block size). Note,
376
390
not all disks support changing the block size:
378
sg_format \-\-format \-\-size=520 /dev/sdm
392
# sg_format \-\-format \-\-size=520 /dev/sdm
380
394
Now a resize operation so that only the first 0x10000 (65536) blocks on a disk
381
395
are accessible. The remaining blocks remain unaltered.
383
sg_format \-\-resize \-\-count=0x10000 /dev/sdm
397
# sg_format \-\-resize \-\-count=0x10000 /dev/sdm
385
399
Now resize the disk back to its normal (maximum) block count:
387
sg_format \-\-resize \-\-count=\-1 /dev/sdm
401
# sg_format \-\-resize \-\-count=\-1 /dev/sdm
403
One reason to format a SCSI disk is to add protection information. First
404
check which protection types are supported by a disk (by checking the SPT
405
field in the Extended inquiry VPD page together with the Protect bit in the
406
standard inquiry response):
408
# sg_vpd \-p ei \-l /dev/sdb
410
extended INQUIRY data VPD page:
414
SPT=1 [protection types 1 and 2 supported]
389
418
Format with type 1 protection:
391
sg_format \-\-format \-\-fmtpinfo=2 /dev/sdm
393
Format with type 3 protection:
395
sg_format \-\-format \-\-fmtpinfo=3 \-\-pfu /dev/sdm
420
# sg_format \-\-format \-\-fmtpinfo=2 /dev/sdm
422
After a successful format with type 1 protection, READ CAPACITY(16)
423
should show something like this:
425
# sg_readcap \-l /dev/sdm
427
Read Capacity results:
429
Protection: prot_en=1, p_type=0, p_i_exponent=0 [type 1 protection]
431
Logical block provisioning: lbpme=0, lbprz=0
435
To format with type 3 protection:
437
# sg_format \-\-format \-\-fmtpinfo=3 \-\-pfu=1 /dev/sdm
439
For the disk shown above this will probably fail because the Extended inquiry
440
VPD page showed only types 1 and 2 protection are supported.
398
442
The exit status of sg_format is 0 when it is successful. Otherwise see
399
443
the sg3_utils(8) man page. Unless the \fI\-\-wait\fR option is given, the