da.4 revision 13744
1.Dd January 18, 1996
2.Dt SD 4
3.Os FreeBSD
4.Sh NAME
5.Nm sd
6.Nd SCSI disk driver
7.Sh SYNOPSIS
8.Cd disk sd
9.Cd disk sd1 at scbus0 target 4 lun 0
10.Sh DESCRIPTION
11The
12.Nm sd
13driver provides support for a 
14.Tn SCSI
15disk. It allows the disk
16to be divided up into a set of pseudo devices called
17.Em partitions .
18In general the interfaces are similar to those described by 
19.Xr wd 4 .
20.Pp
21Where the 
22.Xr wd 4
23device has a fairly low level interface to the system, 
24.Tn SCSI
25devices have a much higher level interface and talk to the system via
26a 
27.Tn SCSI
28host adapter
29(e.g.,
30.Xr ahc 4 ) .
31A
32.Tn SCSI
33adapter must also be separately configured into the system
34before a
35.Tn SCSI
36disk can be configured.
37.Pp
38When the
39.Tn SCSI
40adapter is probed during boot, the 
41.Tn SCSI
42bus is scanned for devices. Any devices found which answer as 
43.Sq Em Direct
44type devices will be attached to the 
45.Nm
46driver.
47In 
48.Tn FreeBSD
49releases prior to 2.1, the first found was attached as
50.Li sd0 ,
51the second
52.Li sd1 ,
53and so on.
54Beginning in 2.1 it became possible to lock down the assignment of
55devices on the
56.Tn SCSI
57bus to particular units of the
58.Nm
59device; refer to
60.Xr scsi 4
61for details on kernel configuration.
62.Sh PARTITIONING
63The 
64.Nm
65driver allows the disk to have two levels of partitioning.
66One layer, called the
67.Dq slice layer ,
68is used to separate the
69.Tn FreeBSD
70areas of the disk from areas used by other operating systems.
71The second layer is the native
72.Bx 4.4
73partitioning scheme,
74.Xr disklabel 5 ,
75which is used to subdivide the
76.Tn FreeBSD
77slices into areas for individual filesystems and swap spaces.
78For more information, see
79.Xr fdisk 8
80and
81.Xr disklabel 8 ,
82respectively.)
83.Pp
84If an uninitialized disk is opened, the slice table will be
85initialized with a fictitious
86.Tn FreeBSD
87slice spanning the entire disk.  Similarly, if an uninitialized
88(or
89.No non- Ns Tn FreeBSD )
90slice is opened, its disklabel will be initialized with parameters returned
91by the drive and a single
92.Sq Li c
93partition encompassing the entire slice.
94.Sh KERNEL CONFIGURATION
95It is only necessary to explicitly configure one
96.Nm
97device; data structures are dynamically allocated as disks are found
98on the
99.Tn SCSI
100bus.
101.Sh IOCTLS
102The following 
103.Xr ioctl 2
104calls apply to 
105.Tn SCSI
106disks as well as to other disks.  They are defined in the header file
107.Aq Pa disklabel.h .
108.Pp
109.Bl -tag -width DIOCSDINFO
110.It Dv DIOCSBAD
111Usually used to set up a bad-block mapping system on the disk. 
112.Tn SCSI
113drive incorporate their own bad-block mapping so this command is not
114implemented.
115.It Dv DIOCGDINFO
116Read, from the kernel, the in-core copy of the disklabel for the
117drive. This may be a fictitious disklabel if the drive has never
118been initialized, in which case it will contain information read
119from the
120.Tn SCSI
121inquiry commands.
122.It Dv DIOCSDINFO
123Give the driver a new disklabel to use. The driver
124.Em will not
125write the new
126disklabel to the disk.
127.It Dv DIOCWLABEL
128Enable or disable the driver's software
129write protect of the disklabel on the disk.
130.It Dv DIOCWDINFO
131Give the driver a new disklabel to use. The driver
132.Em will
133write the new disklabel to the disk.
134.El
135.Pp
136In addition, the 
137.Xr scsi 4
138general
139.Fn ioctl
140commands may be used with the 
141.Nm
142driver, but only against the 
143.Sq Li c
144(whole disk) partition.
145.Sh NOTES
146If a removable device is attached to the 
147.Nm
148driver, then the act of changing the media will invalidate the
149disklabel and information held within the kernel.  To avoid
150corruption, all accesses to the device will be discarded until there
151are no more open file descriptors referencing the device.  During this
152period, all new open attempts will be rejected.  When no more open
153file descriptors reference the device, the first next open will load a
154new set of parameters (including disklabel) for the drive.
155.Sh FILES
156.Bl -tag -width /dev/rsdXXXXX -compact
157.It Pa /dev/rsd Ns Ar u
158raw mode
159.Tn SCSI
160disk unit
161.Ar u ,
162accessed as an unpartitioned device
163.Sm off
164.It Pa /dev/sd Ar u Pa s Ar n
165.Sm on
166block mode
167.Tn SCSI
168disk unit
169.Ar u ,
170slice
171.Ar n ,
172accessed as an unpartitioned device
173.Sm off
174.It Pa /dev/rsd Ar u Pa s Ar n
175.Sm on
176raw mode
177.Tn SCSI
178disk unit
179.Ar u ,
180slice
181.ar n ,
182accessed as an unpartitioned device
183.It Pa /dev/sd Ns Ar u Ns Ar p
184block mode
185.Tn SCSI
186disk unit
187.Ar u ,
188first
189.Tn FreeBSD
190slice, partition
191.Ar p
192.It Pa /dev/rsd Ns Ar u Ns Ar p
193raw mode
194.Tn SCSI
195disk unit
196.Ar u ,
197first
198.Tn FreeBSD
199slice, partition
200.Ar p
201.Sm off
202.It Xo
203.Pa /dev/sd
204.Ar u
205.Pa s
206.Ar n
207.Ar p
208.Xc
209.Sm on
210block mode
211.Tn SCSI
212disk unit
213.Ar u ,
214.No Ar n Ns th
215slice, partition
216.Ar p
217.Sm off
218.It Xo
219.Pa /dev/rsd
220.Ar u
221.Pa s
222.Ar n
223.Ar p
224.Xc
225raw mode
226.Tn SCSI
227disk unit
228.Ar u ,
229.No Ar n Ns th
230slice, partition
231.Ar p
232.El
233.Sh DIAGNOSTICS
234None.
235.Sh SEE ALSO
236.Xr disklabel 8 ,
237.Xr fdisk 8 ,
238.Xr wd 4 ,
239.Xr disklabel 5
240.Sh HISTORY
241The
242.Nm
243driver was originally written for
244.Tn Mach
2452.5, and was ported to
246.Tn FreeBSD
247by Julian Elischer.  Support for slices was written by Bruce Evans.
248