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