1.\" $OpenBSD: sd.4,v 1.12 2003/11/09 16:06:07 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.Bl -tag -width DIOCSDINFO 152.\".It Dv DIOCSBAD 153.\"Usually used to set up a bad-block mapping system on the disk. 154.\".Tn SCSI 155.\"drive incorporate their own bad-block mapping so this command is not 156.\"implemented. 157.It Dv DIOCGDINFO 158Read, from the kernel, the in-core copy of the disklabel for the 159drive. 160This may be a fictitious disklabel if the drive has never 161been initialized, in which case it will contain information read 162from the 163.Tn SCSI 164inquiry commands. 165.It Dv DIOCSDINFO 166Give the driver a new disklabel to use. 167The driver 168.Em will not 169write the new 170disklabel to the disk. 171.It Dv DIOCWLABEL 172Enable or disable the driver's software 173write protect of the disklabel on the disk. 174.It Dv DIOCWDINFO 175Give the driver a new disklabel to use. 176The driver 177.Em will 178write the new disklabel to the disk. 179.It Dv DIOCLOCK 180Lock the media cartridge into the device, or unlock a cartridge previously 181locked. 182Used to prevent user and software eject while the media is in use. 183.It Dv DIOCEJECT 184Eject the media cartridge from a removable device. 185.El 186.Pp 187In addition, the 188.Xr scsi 4 189general 190.Fn ioctl 191commands may be used with the 192.Nm 193driver, but only against the 194.Sq Li c 195(whole disk) partition. 196.Sh NOTES 197If a removable device is attached to the 198.Nm 199driver, then the act of changing the media will invalidate the 200disklabel and information held within the kernel. 201To avoid corruption, all access to the device will be discarded until there 202are no more open file descriptors referencing the device. 203During this period, all new open attempts will be rejected. 204When no more open file descriptors reference the device, the first next 205open will load a new set of parameters (including disklabel) for the drive. 206.Sh FILES 207.Bl -tag -width /dev/rsdXXXXX -compact 208.It Pa /dev/sd Ns Ar u Ns Ar p 209block mode 210.Tn SCSI 211disk unit 212.Ar u , 213partition 214.Ar p 215.It Pa /dev/rsd Ns Ar u Ns Ar p 216raw mode 217.Tn SCSI 218disk unit 219.Ar u , 220partition 221.Ar p 222.El 223.Sh DIAGNOSTICS 224None. 225.Sh SEE ALSO 226.Xr intro 4 , 227.Xr scsi 4 , 228.Xr wd 4 , 229.Xr disklabel 5 , 230.Xr disklabel 8 , 231.Xr fdisk 8 232.Sh HISTORY 233The 234.Nm 235driver was originally written for 236.Tn Mach 2372.5, and was ported to 238.Fx 239by Julian Elischer. 240It was later ported to 241.Ox . 242