xref: /netbsd-src/share/man/man4/sd.4 (revision 81b108b45f75f89f1e3ffad9fb6f074e771c0935)
1.Dd January 18, 1996
2.Dt SD 4
3.Os NetBSD
4.Sh NAME
5.Nm sd
6.Nd SCSI disk driver
7.Sh SYNOPSIS
8.Cd sd* at scsibus? target ? lun ?
9.Cd sd3 at scsibus0 target 3 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.
47.\"In
48.\".Tn FreeBSD
49.\"releases prior to 2.1, the first found was attached as
50.\".Li sd0 ,
51.\"the second
52.\".Li sd1 ,
53.\"and so on.
54.\"Beginning in 2.1 it became possible to lock down the assignment of
55.\"devices on the
56.\".Tn SCSI
57.\"bus to particular units of the
58.\".Nm
59.\"device; refer to
60.\".Xr scsi 4
61.\"for details on kernel configuration.
62.Sh PARTITIONING
63.\"The
64.\".Nm
65.\"driver allows the disk to have two levels of partitioning.
66.\"One layer, called the
67.\".Dq slice layer ,
68.\"is used to separate the
69.\".Tn FreeBSD
70.\"areas of the disk from areas used by other operating systems.
71.\"The second layer is the native
72.\".Bx 4.4
73.\"partitioning scheme,
74.\".Xr disklabel 5 ,
75.\"which is used to subdivide the
76.\".Tn FreeBSD
77.\"slices into areas for individual filesystems and swap spaces.
78.\"For more information, see
79.\".Xr fdisk 8
80.\"and
81.\".Xr disklabel 8 ,
82.\"respectively.)
83On many systems
84.Xr disklabel 8
85is used to partition the drive into filesystems.  On some systems the
86NetBSD portion of the disk resides within a native partition, and another
87program is used to create the NetBSD portion.
88.Pp
89For example, the i386 port uses
90.Xr fdisk 8
91to partition the disk into a BIOS level partition.  This allows sharing
92the disk with other operating systems.
93.Pp
94.\"If an uninitialized disk is opened, the slice table will be
95.\"initialized with a fictitious
96.\".Tn FreeBSD
97.\"slice spanning the entire disk.  Similarly, if an uninitialized
98.\"(or
99.\".No non- Ns Tn FreeBSD )
100.\"slice is opened, its disklabel will be initialized with parameters returned
101.\"by the drive and a single
102.\".Sq Li c
103.\"partition encompassing the entire slice.
104.\".Sh KERNEL CONFIGURATION
105.\"It is only necessary to explicitly configure one
106.\".Nm
107.\"device; data structures are dynamically allocated as disks are found
108.\"on the
109.\".Tn SCSI
110.\"bus.
111.Sh IOCTLS
112The following
113.Xr ioctl 2
114calls apply to
115.Tn SCSI
116disks as well as to other disks.  They are defined in the header file
117.Aq Pa disklabel.h .
118.Pp
119.Bl -tag -width DIOCSDINFO
120.\".It Dv DIOCSBAD
121.\"Usually used to set up a bad-block mapping system on the disk.
122.\".Tn SCSI
123.\"drive incorporate their own bad-block mapping so this command is not
124.\"implemented.
125.It Dv DIOCGDINFO
126Read, from the kernel, the in-core copy of the disklabel for the
127drive. This may be a fictitious disklabel if the drive has never
128been initialized, in which case it will contain information read
129from the
130.Tn SCSI
131inquiry commands.
132.It Dv DIOCSDINFO
133Give the driver a new disklabel to use. The driver
134.Em will not
135write the new
136disklabel to the disk.
137.It Dv DIOCWLABEL
138Enable or disable the driver's software
139write protect of the disklabel on the disk.
140.It Dv DIOCWDINFO
141Give the driver a new disklabel to use. The driver
142.Em will
143write the new disklabel to the disk.
144.It Dv DIOCLOCK
145Lock the media cartridge into the device, or unlock a cartridge previously
146locked.  Used to prevent user and software eject while the media is in
147use.
148.It Dv DIOCEJECT
149Eject the media cartridge from a removable device.
150.El
151.Pp
152In addition, the
153.Xr scsi 4
154general
155.Fn ioctl
156commands may be used with the
157.Nm
158driver, but only against the
159.Sq Li c
160(whole disk) partition.
161.Sh NOTES
162If a removable device is attached to the
163.Nm
164driver, then the act of changing the media will invalidate the
165disklabel and information held within the kernel.  To avoid
166corruption, all accesses to the device will be discarded until there
167are no more open file descriptors referencing the device.  During this
168period, all new open attempts will be rejected.  When no more open
169file descriptors reference the device, the first next open will load a
170new set of parameters (including disklabel) for the drive.
171.Sh FILES
172.Bl -tag -width /dev/rsdXXXXX -compact
173.It Pa /dev/sd Ns Ar u Ns Ar p
174block mode
175.Tn SCSI
176disk unit
177.Ar u ,
178partition
179.Ar p
180.It Pa /dev/rsd Ns Ar u Ns Ar p
181raw mode
182.Tn SCSI
183disk unit
184.Ar u ,
185partition
186.Ar p
187.Sm off
188.El
189.Sh DIAGNOSTICS
190None.
191.Sh SEE ALSO
192.Xr wd 4 ,
193.Xr disklabel 5 ,
194.Xr disklabel 8 ,
195.Xr fdisk 8
196.Sh HISTORY
197The
198.Nm
199driver was originally written for
200.Tn Mach
2012.5, and was ported to
202.Tn FreeBSD
203by Julian Elischer.
204It was later ported to
205.Tn NetBSD .
206