1
- .TH SG_FORMAT "8" "January 2012" "sg3_utils\- 1.33" SG3_UTILS
1
+ .TH SG_FORMAT "8" "February 2012" "sg3_utils\- 1.33" SG3_UTILS
2
2
.SH NAME
3
3
sg_format \- format or resize a SCSI disk (perhaps change its block size)
4
4
.SH SYNOPSIS
@@ -164,8 +164,11 @@ associated with a FORMAT UNIT command to \fIPIE\fR. The default value is 0.
164
164
This field first appeared in SBC\- 3 revision 18.
165
165
.TP
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.]
169
172
.TP
170
173
\fB \- x \fR , \fB \-\- poll \fR =\fI PT \fR
171
174
where \fI PT \fR is the type of poll used. If \fI PT \fR is 0 then a TEST UNIT
@@ -251,7 +254,7 @@ information" section (section 4.21 in draft SBC\-3 rev 29). 8 bytes of
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
255
258
is maintained.
256
259
.PP
257
260
A device that supports protection information (i.e. supports one or more
@@ -266,11 +269,22 @@ Given that a device supports a particular protection type, a user can then
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 \fI FPI \fR and \fI PFU \fR are
270
- both 0 (their default values) then protection type 0 is chosen. If \fI FPI \fR
271
- is 2 and \fI PFU \fR is 0 then protection type 1 is chosen. If \fI FPI \fR is 3
272
- and \fI PFU \fR is 0 then protection type 2 is chosen. If \fI FPI \fR is 3 and
273
- \fI PFU \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
274
+ them:
275
+ .br
276
+ \fB 0 \fR : \-\- fmtpinfo=0 \-\- pfu=0
277
+ .br
278
+ \fB 1 \fR : \-\- fmtpinfo=2 \-\- pfu=0
279
+ .br
280
+ \fB 2 \fR : \-\- fmtpinfo=3 \-\- pfu=0
281
+ .br
282
+ \fB 3 \fR : \-\- fmtpinfo=3 \-\- pfu=1
283
+ .br
284
+ The default value of \fI FPI \fR (in \fI \-\- fmtpinfo=FPI \fR ) is 0 and the
285
+ default value of \fI PFU \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.
274
288
.SH NOTES
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,42 +372,72 @@ size derived from two sources: a block descriptor in a MODE SELECT command
358
372
response and from the response of a READ CAPACITY commands. No changes
359
373
are made:
360
374
.PP
361
- sg_format /dev/sdm
375
+ # sg_format /dev/sdm
362
376
.PP
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:
366
380
.PP
367
- sg_format \-\- format /dev/sdm
381
+ # sg_format \-\- format /dev/sdm
368
382
.PP
369
383
Now the same format, but waiting (passively) until the format operation is
370
384
complete:
371
385
.PP
372
- sg_format \-\- format \-\- wait /dev/sdm
386
+ # sg_format \-\- format \-\- wait /dev/sdm
373
387
.PP
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:
377
391
.PP
378
- sg_format \-\- format \-\- size=520 /dev/sdm
392
+ # sg_format \-\- format \-\- size=520 /dev/sdm
379
393
.PP
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.
382
396
.PP
383
- sg_format \-\- resize \-\- count=0x10000 /dev/sdm
397
+ # sg_format \-\- resize \-\- count=0x10000 /dev/sdm
384
398
.PP
385
399
Now resize the disk back to its normal (maximum) block count:
386
400
.PP
387
- sg_format \-\- resize \-\- count=\- 1 /dev/sdm
401
+ # sg_format \-\- resize \-\- count=\- 1 /dev/sdm
402
+ .PP
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):
407
+ .PP
408
+ # sg_vpd -p ei -l /dev/sdb
409
+ .br
410
+ extended INQUIRY data VPD page:
411
+ .br
412
+ ACTIVATE_MICROCODE=0
413
+ .br
414
+ SPT=1 [protection types 1 and 2 supported]
415
+ .br
416
+ ....
388
417
.PP
389
418
Format with type 1 protection:
390
419
.PP
391
- sg_format \-\- format \-\- fmtpinfo=2 /dev/sdm
420
+ # sg_format \-\- format \-\- fmtpinfo=2 /dev/sdm
421
+ .PP
422
+ After a successful format with type 1 protection, READ CAPACITY(16)
423
+ should show something like this:
424
+ .PP
425
+ # sg_readcap -l /dev/sdm
426
+ .br
427
+ Read Capacity results:
428
+ .br
429
+ Protection: prot_en=1, p_type=0, p_i_exponent=0 [type 1 protection]
430
+ .br
431
+ Logical block provisioning: lbpme=0, lbprz=0
432
+ .br
433
+ ....
392
434
.PP
393
- Format with type 3 protection:
435
+ To format with type 3 protection:
394
436
.PP
395
- sg_format \-\- format \-\- fmtpinfo=3 \-\- pfu /dev/sdm
437
+ # sg_format \-\- format \-\- fmtpinfo=3 \-\- pfu=1 /dev/sdm
396
438
.PP
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.
397
441
.SH EXIT STATUS
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
0 commit comments