1.\" $OpenBSD: sd.4,v 1.19 2014/01/21 03:15:46 schwarze 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: January 21 2014 $ 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.In 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 DIOCWDINFO 162Give the driver a new disklabel to use. 163The driver 164.Em will 165write the new disklabel to the disk. 166.It Dv DIOCLOCK 167Lock the media cartridge into the device, or unlock a cartridge previously 168locked. 169Used to prevent user and software eject while the media is in use. 170.It Dv DIOCEJECT 171Eject the media cartridge from a removable device. 172.It Dv DIOCINQ 173Read the devices product information. 174.El 175.Pp 176In addition, the 177.Xr scsi 4 178general 179.Fn ioctl 180commands may be used with the 181.Nm 182driver, but only against the 183.Sq Li c 184(whole disk) partition. 185.Sh NOTES 186If a removable device is attached to the 187.Nm 188driver, then the act of changing the media will invalidate the 189disklabel and information held within the kernel. 190To avoid corruption, all access to the device will be discarded until there 191are no more open file descriptors referencing the device. 192During this period, all new open attempts will be rejected. 193When no more open file descriptors reference the device, the first next 194open will load a new set of parameters (including disklabel) for the drive. 195.Sh FILES 196.Bl -tag -width /dev/rsdXXXXX -compact 197.It Pa /dev/sd Ns Ar u Ns Ar p 198block mode 199.Tn SCSI 200disk unit 201.Ar u , 202partition 203.Ar p 204.It Pa /dev/rsd Ns Ar u Ns Ar p 205raw mode 206.Tn SCSI 207disk unit 208.Ar u , 209partition 210.Ar p 211.El 212.Sh DIAGNOSTICS 213None. 214.Sh SEE ALSO 215.Xr intro 4 , 216.Xr scsi 4 , 217.Xr wd 4 , 218.Xr disklabel 5 , 219.Xr disklabel 8 , 220.Xr fdisk 8 221.Sh HISTORY 222The 223.Nm 224driver was originally written for 225.Tn Mach 2262.5, and was ported to 227.Fx 228by Julian Elischer. 229It was later ported to 230.Ox . 231