~ubuntu-branches/ubuntu/dapper/sg3-utils/dapper-backports

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
.TH SG_READCAP "8" "June 2006" "sg3_utils-1.21" SG3_UTILS
.SH NAME
sg_readcap \- calls a READ CAPACITY command on a SCSI device
.SH SYNOPSIS
.B sg_readcap 
[\fI-16\fR] [\fI-h\fR] [\fI-lba=<block>\fR] [\fI-pmi\fR] [\fI-v\fR]
[\fI-V\fR]
<\fIdevice\fR>
.SH DESCRIPTION
.\" Add any additional description here
.PP
The normal usage is to find the number of blocks (and block size)
of the given device and output them.
.PP
The SCSI READ CAPACITY command (both 10 and 16 byte cdbs) actually yield
the block address of the last block and the block size. The number of
blocks is thus one plus the block address of the last block (as blocks
are counted origin zero (i.e. starting at block zero)). This is the source
of many "off by one" errors which are often seen as medium or out of range
errors when the reported last block is read.
.PP
Device capacity is the product of the number of blocks and block size.
This utility outputs this figure in bytes, MiB (1048576 bytes per MiB)
and GB (1000000000 bytes per GB).
.TP
-16
Use the 16 byte cdb variant of the READ CAPACITY command. The default
action is to use the 10 byte cdb variant which limits the maximum
block address to (2**32 - 2). When a 10 byte cdb READ CAPACITY command
is used on a device whose size is too large then a last block address
of 0xffffffff is returned (if the device complies with SBC-2).
.TP
-b
utility outputs two hex numbers (prefixed with '0x' and space separated)
to stdout. The first number is the maximum number of blocks on the
device (which is one plus the lba of the last accessible block). The
second number is the size of each block. If the operation fails
then "0x0 0x0" is written to stdout.
.TP
-h
output the usage message then exit.
.TP
-lba=<block>
used in conjunction with "-pmi" option. This variant of READ CAPACITY will
yield the last block address after "<block>" prior to a delay. For a
disk, given a "<block>" address it yields the highest numbered block on
the same cylinder (i.e. before the heads need to move). "<block>" is 
in hex (from 0 to ffffffff) and defaults to zero.
.TP
-pmi
partial medium indicator: for finding the next block address prior to
some delay (e.g. head movement). In the absence of this switch, the
total number of blocks and the block size of the device are output.
.TP
-v
verbose: print out cdb of issued commands prior to execution. '-vv'
and '-vvv' are also accepted yielding greater verbosity.
.TP
-V
outputs version string then exits.
.PP
In the 2.4 series of Linux kernels the given device must be
a SCSI generic (sg) device. In the 2.6 series block devices (e.g. disks
and SCSI DVDs) can also be specified. For example "sg_readcap /dev/sda"
and "sg_readcap /dev/hdd" (if /dev/hdd is a ATAPI CD/DVD device) will
work in the 2.6 series kernels.
.SH EXIT STATUS
The exit status of sg_readcap is 0 when it is successful. Otherwise see
the sg3_utils(8) man page.
.SH AUTHORS
Written by Douglas Gilbert
.SH COPYRIGHT
Copyright \(co 1999-2006 Douglas Gilbert
.br
This software is distributed under the GPL version 2. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.