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