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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
.Dd January 18, 1996
.Dt SD 4
.Os FreeBSD
.Sh NAME
.Nm sd
.Nd SCSI disk driver
.Sh SYNOPSIS
.Cd disk sd
.Cd disk sd1 at scbus0 target 4 lun 0
.Sh DESCRIPTION
The
.Nm sd
driver provides support for a
.Tn SCSI
disk. It allows the disk
to be divided up into a set of pseudo devices called
.Em partitions .
In general the interfaces are similar to those described by
.Xr wd 4 .
.Pp
Where the
.Xr wd 4
device has a fairly low level interface to the system,
.Tn SCSI
devices have a much higher level interface and talk to the system via
a
.Tn SCSI
host adapter
(e.g.,
.Xr ahc 4 ) .
A
.Tn SCSI
adapter must also be separately configured into the system
before a
.Tn SCSI
disk can be configured.
.Pp
When the
.Tn SCSI
adapter is probed during boot, the
.Tn SCSI
bus is scanned for devices. Any devices found which answer as
.Sq Em Direct
type devices will be attached to the
.Nm
driver.
In
.Tn FreeBSD
releases prior to 2.1, the first found was attached as
.Li sd0 ,
the second
.Li sd1 ,
and so on.
Beginning in
.Fx 2.1
it became possible to lock down the assignment of
devices on the
.Tn SCSI
bus to particular units of the
.Nm
device; refer to
.Xr scsi 4
for details on kernel configuration.
.Sh PARTITIONING
The
.Nm
driver allows the disk to have two levels of partitioning.
One layer, called the
.Dq slice layer ,
is used to separate the
.Tn FreeBSD
areas of the disk from areas used by other operating systems.
The second layer is the native
.Bx 4.4
partitioning scheme,
.Xr disklabel 5 ,
which is used to subdivide the
.Tn FreeBSD
slices into areas for individual filesystems and swap spaces.
For more information, see
.Xr fdisk 8
and
.Xr disklabel 8 ,
respectively.)
.Pp
If an uninitialized disk is opened, the slice table will be
initialized with a fictitious
.Tn FreeBSD
slice spanning the entire disk. Similarly, if an uninitialized
(or
.No non- Ns Tn FreeBSD )
slice is opened, its disklabel will be initialized with parameters returned
by the drive and a single
.Sq Li c
partition encompassing the entire slice.
.Sh KERNEL CONFIGURATION
It is only necessary to explicitly configure one
.Nm
device; data structures are dynamically allocated as disks are found
on the
.Tn SCSI
bus.
.Sh IOCTLS
The following
.Xr ioctl 2
calls apply to
.Tn SCSI
disks as well as to other disks. They are defined in the header file
.Aq Pa disklabel.h .
.Pp
.Bl -tag -width DIOCSDINFO
.It Dv DIOCSBAD
Usually used to set up a bad-block mapping system on the disk.
.Tn SCSI
drive incorporate their own bad-block mapping so this command is not
implemented.
.It Dv DIOCGDINFO
Read, from the kernel, the in-core copy of the disklabel for the
drive. This may be a fictitious disklabel if the drive has never
been initialized, in which case it will contain information read
from the
.Tn SCSI
inquiry commands.
.It Dv DIOCSDINFO
Give the driver a new disklabel to use. The driver
.Em will not
write the new
disklabel to the disk.
.It Dv DIOCWLABEL
Enable or disable the driver's software
write protect of the disklabel on the disk.
.It Dv DIOCWDINFO
Give the driver a new disklabel to use. The driver
.Em will
write the new disklabel to the disk.
.El
.Pp
In addition, the
.Xr scsi 4
general
.Fn ioctl
commands may be used with the
.Nm
driver, but only against the
.Sq Li c
(whole disk) partition.
.Sh NOTES
If a removable device is attached to the
.Nm
driver, then the act of changing the media will invalidate the
disklabel and information held within the kernel. To avoid
corruption, all accesses to the device will be discarded until there
are no more open file descriptors referencing the device. During this
period, all new open attempts will be rejected. When no more open
file descriptors reference the device, the first next open will load a
new set of parameters (including disklabel) for the drive.
.Sh FILES
.Bl -tag -width /dev/rsdXXXXX -compact
.It Pa /dev/rsd Ns Ar u
raw mode
.Tn SCSI
disk unit
.Ar u ,
accessed as an unpartitioned device
.Sm off
.It Pa /dev/sd Ar u Pa s Ar n
.Sm on
block mode
.Tn SCSI
disk unit
.Ar u ,
slice
.Ar n ,
accessed as an unpartitioned device
.Sm off
.It Pa /dev/rsd Ar u Pa s Ar n
.Sm on
raw mode
.Tn SCSI
disk unit
.Ar u ,
slice
.ar n ,
accessed as an unpartitioned device
.It Pa /dev/sd Ns Ar u Ns Ar p
block mode
.Tn SCSI
disk unit
.Ar u ,
first
.Tn FreeBSD
slice, partition
.Ar p
.It Pa /dev/rsd Ns Ar u Ns Ar p
raw mode
.Tn SCSI
disk unit
.Ar u ,
first
.Tn FreeBSD
slice, partition
.Ar p
.Sm off
.It Xo
.Pa /dev/sd
.Ar u
.Pa s
.Ar n
.Ar p
.Xc
.Sm on
block mode
.Tn SCSI
disk unit
.Ar u ,
.No Ar n Ns th
slice, partition
.Ar p
.Sm off
.It Xo
.Pa /dev/rsd
.Ar u
.Pa s
.Ar n
.Ar p
.Xc
raw mode
.Tn SCSI
disk unit
.Ar u ,
.No Ar n Ns th
slice, partition
.Ar p
.El
.Sh DIAGNOSTICS
None.
.Sh SEE ALSO
.Xr disklabel 8 ,
.Xr fdisk 8 ,
.Xr wd 4 ,
.Xr disklabel 5
.Sh HISTORY
The
.Nm
driver was originally written for
.Tn Mach
2.5, and was ported to
.Tn FreeBSD
by Julian Elischer. Support for slices was written by Bruce Evans.
|