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