1.\" $OpenBSD: sd.4,v 1.17 2007/05/31 19:19:51 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 $Mdocdate: May 31 2007 $ 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?" 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 49.Tn SCSI 50devices have a fairly high level interface to the system and talk to it via 51a 52.Tn SCSI 53host adapter 54(e.g., 55.Xr ahc 4 ) . 56A 57.Tn SCSI 58adapter must also be separately configured into the system 59before a 60.Tn SCSI 61disk can be configured. 62.Pp 63When the 64.Tn SCSI 65adapter is probed during boot, the 66.Tn SCSI 67bus is scanned for devices. 68Any devices found which answer as 69.Sq Em Direct 70type devices will be attached to the 71.Nm 72driver. 73.\"In 74.\".Fx 75.\"releases prior to 2.1, the first found was attached as 76.\".Li sd0 , 77.\"the second 78.\".Li sd1 , 79.\"and so on. 80.\"Beginning in 2.1 it became possible to lock down the assignment of 81.\"devices on the 82.\".Tn SCSI 83.\"bus to particular units of the 84.\".Nm 85.\"device; refer to 86.\".Xr scsi 4 87.\"for details on kernel configuration. 88.Sh PARTITIONING 89.\"The 90.\".Nm 91.\"driver allows the disk to have two levels of partitioning. 92.\"One layer, called the 93.\".Dq slice layer , 94.\"is used to separate the 95.\".Fx 96.\"areas of the disk from areas used by other operating systems. 97.\"The second layer is the native 98.\".Bx 4.4 99.\"partitioning scheme, 100.\".Xr disklabel 5 , 101.\"which is used to subdivide the 102.\".Fx 103.\"slices into areas for individual filesystems and swap spaces. 104.\"For more information, see 105.\".Xr fdisk 8 106.\"and 107.\".Xr disklabel 8 , 108.\"respectively.) 109On many systems 110.Xr disklabel 8 111is used to partition the drive into filesystems. 112On some systems the 113.Ox 114portion of the disk resides within a native partition, and another 115program is used to create the 116.Ox 117portion. 118.Pp 119For example, the i386 port uses 120.Xr fdisk 8 121to partition the disk into a BIOS level partition. 122This allows sharing the disk with other operating systems. 123.\"If an uninitialized disk is opened, the slice table will be 124.\"initialized with a fictitious 125.\".Fx 126.\"slice spanning the entire disk. Similarly, if an uninitialized 127.\"(or 128.\".No non- Ns Fx ) 129.\"slice is opened, its disklabel will be initialized with parameters returned 130.\"by the drive and a single 131.\".Sq Li c 132.\"partition encompassing the entire slice. 133.Sh IOCTLS 134The following 135.Xr ioctl 2 136calls apply to 137.Tn SCSI 138disks as well as to other disks. 139They are defined in the header file 140.Aq Pa sys/disklabel.h . 141.Bl -tag -width DIOCSDINFO 142.\".It Dv DIOCSBAD 143.\"Usually used to set up a bad-block mapping system on the disk. 144.\".Tn SCSI 145.\"drive incorporate their own bad-block mapping so this command is not 146.\"implemented. 147.It Dv DIOCGDINFO 148Read, from the kernel, the in-core copy of the disklabel for the 149drive. 150This may be a fictitious disklabel if the drive has never 151been initialized, in which case it will contain information read 152from the 153.Tn SCSI 154inquiry commands. 155.It Dv DIOCSDINFO 156Give the driver a new disklabel to use. 157The driver 158.Em will not 159write the new 160disklabel to the disk. 161.It Dv DIOCWLABEL 162Enable or disable the driver's software 163write protect of the disklabel on the disk. 164.It Dv DIOCWDINFO 165Give the driver a new disklabel to use. 166The driver 167.Em will 168write the new disklabel to the disk. 169.It Dv DIOCLOCK 170Lock the media cartridge into the device, or unlock a cartridge previously 171locked. 172Used to prevent user and software eject while the media is in use. 173.It Dv DIOCEJECT 174Eject the media cartridge from a removable device. 175.It Dv DIOCINQ 176Read the devices product information. 177.El 178.Pp 179In addition, the 180.Xr scsi 4 181general 182.Fn ioctl 183commands may be used with the 184.Nm 185driver, but only against the 186.Sq Li c 187(whole disk) partition. 188.Sh NOTES 189If a removable device is attached to the 190.Nm 191driver, then the act of changing the media will invalidate the 192disklabel and information held within the kernel. 193To avoid corruption, all access to the device will be discarded until there 194are no more open file descriptors referencing the device. 195During this period, all new open attempts will be rejected. 196When no more open file descriptors reference the device, the first next 197open will load a new set of parameters (including disklabel) for the drive. 198.Sh FILES 199.Bl -tag -width /dev/rsdXXXXX -compact 200.It Pa /dev/sd Ns Ar u Ns Ar p 201block mode 202.Tn SCSI 203disk unit 204.Ar u , 205partition 206.Ar p 207.It Pa /dev/rsd Ns Ar u Ns Ar p 208raw mode 209.Tn SCSI 210disk unit 211.Ar u , 212partition 213.Ar p 214.El 215.Sh DIAGNOSTICS 216None. 217.Sh SEE ALSO 218.Xr intro 4 , 219.Xr scsi 4 , 220.Xr wd 4 , 221.Xr disklabel 5 , 222.Xr disklabel 8 , 223.Xr fdisk 8 224.Sh HISTORY 225The 226.Nm 227driver was originally written for 228.Tn Mach 2292.5, and was ported to 230.Fx 231by Julian Elischer. 232It was later ported to 233.Ox . 234