xref: /netbsd-src/share/man/man4/sd.4 (revision 481fca6e59249d8ffcf24fef7cfbe7b131bfb080)
1.\"	$NetBSD: sd.4,v 1.9 1999/12/23 21:24:03 leo Exp $
2.\"
3.\" Copyright (c) 1996
4.\"     Julian Elischer <julian@freebsd.org>.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\"
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26.\" SUCH DAMAGE.
27.\"
28.Dd January 18, 1996
29.Dt SD 4
30.Os
31.Sh NAME
32.Nm sd
33.Nd SCSI and ATAPI disk driver
34.Sh SYNOPSIS
35.Cd sd* at scsibus? target ? lun ?
36.Cd sd3 at scsibus0 target 3 lun 0
37.Cd "sd* at atapibus? drive ? flags 0x0000"
38.Sh DESCRIPTION
39The
40.Nm
41driver provides support for
42.Tn SCSI
43bus and Advanced Technology Attachment Packet Interface
44.Pq Tn ATAPI
45disks.
46It allows the disk to be divided up into a set of pseudo devices called
47.Em partitions .
48In general the interfaces are similar to those described by
49.Xr wd 4 .
50.Pp
51Where the
52.Xr wd 4
53device has a fairly low level interface to the system,
54.Tn SCSI
55devices have a much higher level interface and talk to the system via a
56.Tn SCSI
57host adapter
58(e.g.,
59.Xr ahc 4 ) .
60A
61.Tn SCSI
62adapter must also be separately configured into the system
63before a
64.Tn SCSI
65disk can be configured.
66.Pp
67When the
68.Tn SCSI
69adapter is probed during boot, the
70.Tn SCSI
71bus is scanned for devices.
72Any devices found which answer as
73.Sq Em Direct
74type devices will be attached to the
75.Nm
76driver.
77.Pp
78For the use of flags with ATAPI devices, see
79.Xr wd 4 .
80.\"In
81.\".Tn FreeBSD
82.\"releases prior to 2.1, the first found was attached as
83.\".Li sd0 ,
84.\"the second
85.\".Li sd1 ,
86.\"and so on.
87.\"Beginning in 2.1 it became possible to lock down the assignment of
88.\"devices on the
89.\".Tn SCSI
90.\"bus to particular units of the
91.\".Nm
92.\"device; refer to
93.\".Xr scsi 4
94.\"for details on kernel configuration.
95.Sh PARTITIONING
96.\"The
97.\".Nm
98.\"driver allows the disk to have two levels of partitioning.
99.\"One layer, called the
100.\".Dq slice layer ,
101.\"is used to separate the
102.\".Tn FreeBSD
103.\"areas of the disk from areas used by other operating systems.
104.\"The second layer is the native
105.\".Bx 4.4
106.\"partitioning scheme,
107.\".Xr disklabel 5 ,
108.\"which is used to subdivide the
109.\".Tn FreeBSD
110.\"slices into areas for individual filesystems and swap spaces.
111.\"For more information, see
112.\".Xr fdisk 8
113.\"and
114.\".Xr disklabel 8 ,
115.\"respectively.)
116On many systems
117.Xr disklabel 8
118is used to partition the drive into filesystems.
119On some systems the
120.Nx
121portion of the disk resides within a native partition, and another
122program is used to create the
123.Nx
124portion.
125.Pp
126For example, the i386 port uses
127.Xr fdisk 8
128to partition the disk into a
129.Tn BIOS
130level partition.
131This allows sharing the disk with other operating systems.
132.Pp
133.\"If an uninitialized disk is opened, the slice table will be
134.\"initialized with a fictitious
135.\".Tn FreeBSD
136.\"slice spanning the entire disk.  Similarly, if an uninitialized
137.\"(or
138.\".No non- Ns Tn FreeBSD )
139.\"slice is opened, its disklabel will be initialized with parameters returned
140.\"by the drive and a single
141.\".Sq Li c
142.\"partition encompassing the entire slice.
143.\".Sh KERNEL CONFIGURATION
144.\"It is only necessary to explicitly configure one
145.\".Nm
146.\"device; data structures are dynamically allocated as disks are found
147.\"on the
148.\".Tn SCSI
149.\"bus.
150.Sh IOCTLS
151The following
152.Xr ioctl 2
153calls apply to
154.Tn SCSI
155disks as well as to other disks.
156They are defined in the header file
157.Aq Pa disklabel.h .
158.Pp
159.Bl -tag -width DIOCSDINFO
160.\".It Dv DIOCSBAD
161.\"Usually used to set up a bad-block mapping system on the disk.
162.\".Tn SCSI
163.\"drive incorporate their own bad-block mapping so this command is not
164.\"implemented.
165.It Dv DIOCGDINFO
166Read, from the kernel, the in-core copy of the disklabel for the drive.
167This may be a fictitious disklabel if the drive has never
168been initialized, in which case it will contain information read
169from the
170.Tn SCSI
171inquiry commands.
172.It Dv DIOCSDINFO
173Give the driver a new disklabel to use.
174The driver
175.Em will not
176write the new
177disklabel to the disk.
178.It Dv DIOCKLABEL
179Keep or drop the in-core disklabel on the last close.
180.It Dv DIOCWLABEL
181Enable or disable the driver's software
182write protect of the disklabel on the disk.
183.It Dv DIOCWDINFO
184Give the driver a new disklabel to use.
185The driver
186.Em will
187write the new disklabel to the disk.
188.It Dv DIOCLOCK
189Lock the media cartridge into the device, or unlock a cartridge previously
190locked.
191Used to prevent user and software eject while the media is in use.
192.It Dv DIOCEJECT
193Eject the media cartridge from a removable device.
194.El
195.Pp
196In addition, the
197.Xr scsi 4
198general
199.Fn ioctl
200commands may be used with the
201.Nm
202driver, but only against the
203.Sq Li c
204(whole disk) partition.
205.Sh NOTES
206If a removable device is attached to the
207.Nm
208driver, then the act of changing the media will invalidate the
209disklabel and information held within the kernel.
210To avoid corruption, all accesses to the device will be discarded
211until there are no more open file descriptors referencing the
212device.
213During this period, all new open attempts will be rejected.
214When no more open file descriptors reference the device, the first
215next open will load a new set of parameters (including disklabel)
216for the drive.
217.Sh FILES
218.Bl -tag -width /dev/rsdXXXXX -compact
219.It Pa /dev/sd Ns Ar u Ns Ar p
220block mode
221.Tn SCSI
222disk unit
223.Ar u ,
224partition
225.Ar p
226.It Pa /dev/rsd Ns Ar u Ns Ar p
227raw mode
228.Tn SCSI
229disk unit
230.Ar u ,
231partition
232.Ar p
233.Sm off
234.El
235.Sh DIAGNOSTICS
236None.
237.Sh SEE ALSO
238.Xr ioctl 2 ,
239.Xr intro 4 ,
240.Xr scsi 4 ,
241.Xr wd 4 ,
242.Xr disklabel 5 ,
243.Xr disklabel 8 ,
244.Xr fdisk 8
245.Sh HISTORY
246The
247.Nm
248driver was originally written for
249.Tn Mach
2502.5, and was ported to
251.Fx
252by Julian Elischer.
253It was later ported to
254.Nx .
255