aboutsummaryrefslogtreecommitdiff
path: root/sg_ident.8
blob: f29c3739f1acdd94df6346d1f4624f46d4edccde (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
.TH SG_IDENT "8" "August 2005" "sg3_utils-1.16" SG3_UTILS
.SH NAME
sg_ident \- report or set device identifier
.SH SYNOPSIS
.B sg_ident
[\fI--ascii\fR] [\fI--clear\fR] [\fI--help\fR] [\fI--raw\fR]
[\fI--set\fR] [\fI--verbose\fR] [\fI--version\fR] \fI<scsi_device>\fR
.SH DESCRIPTION
.\" Add any additional description here
.PP
Send a REPORT DEVICE IDENTIFIER or SET DEVICE IDENTIFIER SCSI command
to the given device. SCSI devices that support these two commands
allow users to write (set) an identifier and report it back at some
later time. The identifier is persistent (i.e. stored on some
non-volatile medium within the SCSI device that will survive a power
outage).
.PP
Typically the space allocated for the identifier is limited:
SPC-4 (revision 0) states the maximum length is 512 bytes and
all devices (that support these commands) shall support lengths
up to 64 bytes. The author has seen older disks that only support
16 bytes.
.PP
The default action when no options are given is to invoke the
Report Device Identifier command. Error reports are sent to
stderr. If no errors occur then the length of the device identifier
is output (to stdout). This is followed by an ASCII-HEX rendering of
each byte of the identifier (up to 16 bytes per line) which an ASCII
representation to the right with dots replacing non printable characters.
each 
.TP
--ascii | -A
invokes the Report Device Identifier command and if anything is
found interprets it as ASCII (or UTF-8 depending on the environment)
and prints the identifier to stdout.
.TP
--clear | -C
invokes the Set Device Identifier command with an identifier length
of zero. This has the effect of clearing the existing device
identifier.
.TP
--help | -h
output the usage message then exit.
.TP
--raw | -r
invokes the Report Device Identifier command and if anything is found
sends the identifier (which may be binary) to stdout. Nothing else
is sent to stdout however error reports are sent to stderr.
.TP
--set | -S
first read stdin until an EOF is detected then invokes the Set Device
Identifier command to set what has been fetched from stdin as the
device identifier. The amount of data read must be between 1 and
512 bytes length (inclusive).
.TP
--verbose | -v
increase the level of verbosity, (i.e. debug output).
.TP
--version | -V
print the version string and then exit.
.PP
This utility facilitates users writing their own identifiers to
their SCSI devices. There are several other types of identifiers
that the user cannot change. These include the SCSI INQUIRY command
with its standard vendor and product identification strings and
the product revision level; plus the large amount of information
provided by the "Device Identification" VPD page (see sg_inq).
There is also the READ MEDIA SERIAL NUMBER command (see sg_rmsn).
The MMC-4 command set for CDs and DVDs has a "media serial number"
feature (0x109) [and a "logical unit serial number" feature]. These
can be viewed with sg_get_config.
.PP
When this utility succeeds its process exits with a status of 0;
if problems are encountered the process status is 1 .
.SH EXAMPLES
First, to see if there is an existing device identifier whose format
is unknown, use no options:
.PP
  # sg_ident /dev/sdb
.br
  Reported device identifier length = 10
.br
  Device identifier:
.br
   00     31 32 33 34 35 36 37 38  39 30          1234567890
.PP
If it is ASCII then it can printed as such:
.PP
  # sg_ident --ascii /dev/sdb
.br
  Reported device identifier length = 10
.br
  Device identifier:
.br
  1234567890
.PP
The device identifier can be copied to a file, cleared and then 
re-asserted with this sequence:
.PP
  # sg_ident --raw /dev/sdb > t
.br
  # sg_ident --clear /dev/sdb
.br
  # cat t | sg_ident --set /dev/sdb
.SH AUTHORS
Written by Douglas Gilbert.
.SH "REPORTING BUGS"
Report bugs to <dgilbert at interlog dot com>.
.SH COPYRIGHT
Copyright \(co 2005 Douglas Gilbert
.br
This software is distributed under a FreeBSD license. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.SH "SEE ALSO"
.B sg_inq(sg3_utils), sg_rmsn(sg3_utils), sg_get_config(sg3_utils)