1.\" $NetBSD: sd.4,v 1.3 1996/10/20 23:15:23 explorer Exp $ 2.\" 3.\" Copyright (c) 1996 4.\" Julian Elischer <julian@freebsd.org>. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26.\" SUCH DAMAGE. 27.\" 28.Dd January 18, 1996 29.Dt SD 4 30.Os NetBSD 31.Sh NAME 32.Nm sd 33.Nd SCSI disk driver 34.Sh SYNOPSIS 35.Cd sd* at scsibus? target ? lun ? 36.Cd sd3 at scsibus0 target 3 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. 74.\"In 75.\".Tn FreeBSD 76.\"releases prior to 2.1, the first found was attached as 77.\".Li sd0 , 78.\"the second 79.\".Li sd1 , 80.\"and so on. 81.\"Beginning in 2.1 it became possible to lock down the assignment of 82.\"devices on the 83.\".Tn SCSI 84.\"bus to particular units of the 85.\".Nm 86.\"device; refer to 87.\".Xr scsi 4 88.\"for details on kernel configuration. 89.Sh PARTITIONING 90.\"The 91.\".Nm 92.\"driver allows the disk to have two levels of partitioning. 93.\"One layer, called the 94.\".Dq slice layer , 95.\"is used to separate the 96.\".Tn FreeBSD 97.\"areas of the disk from areas used by other operating systems. 98.\"The second layer is the native 99.\".Bx 4.4 100.\"partitioning scheme, 101.\".Xr disklabel 5 , 102.\"which is used to subdivide the 103.\".Tn FreeBSD 104.\"slices into areas for individual filesystems and swap spaces. 105.\"For more information, see 106.\".Xr fdisk 8 107.\"and 108.\".Xr disklabel 8 , 109.\"respectively.) 110On many systems 111.Xr disklabel 8 112is used to partition the drive into filesystems. On some systems the 113NetBSD portion of the disk resides within a native partition, and another 114program is used to create the NetBSD portion. 115.Pp 116For example, the i386 port uses 117.Xr fdisk 8 118to partition the disk into a BIOS level partition. This allows sharing 119the disk with other operating systems. 120.Pp 121.\"If an uninitialized disk is opened, the slice table will be 122.\"initialized with a fictitious 123.\".Tn FreeBSD 124.\"slice spanning the entire disk. Similarly, if an uninitialized 125.\"(or 126.\".No non- Ns Tn FreeBSD ) 127.\"slice is opened, its disklabel will be initialized with parameters returned 128.\"by the drive and a single 129.\".Sq Li c 130.\"partition encompassing the entire slice. 131.\".Sh KERNEL CONFIGURATION 132.\"It is only necessary to explicitly configure one 133.\".Nm 134.\"device; data structures are dynamically allocated as disks are found 135.\"on the 136.\".Tn SCSI 137.\"bus. 138.Sh IOCTLS 139The following 140.Xr ioctl 2 141calls apply to 142.Tn SCSI 143disks as well as to other disks. They are defined in the header file 144.Aq Pa disklabel.h . 145.Pp 146.Bl -tag -width DIOCSDINFO 147.\".It Dv DIOCSBAD 148.\"Usually used to set up a bad-block mapping system on the disk. 149.\".Tn SCSI 150.\"drive incorporate their own bad-block mapping so this command is not 151.\"implemented. 152.It Dv DIOCGDINFO 153Read, from the kernel, the in-core copy of the disklabel for the 154drive. This may be a fictitious disklabel if the drive has never 155been initialized, in which case it will contain information read 156from the 157.Tn SCSI 158inquiry commands. 159.It Dv DIOCSDINFO 160Give the driver a new disklabel to use. The driver 161.Em will not 162write the new 163disklabel to the disk. 164.It Dv DIOCWLABEL 165Enable or disable the driver's software 166write protect of the disklabel on the disk. 167.It Dv DIOCWDINFO 168Give the driver a new disklabel to use. The driver 169.Em will 170write the new disklabel to the disk. 171.It Dv DIOCLOCK 172Lock the media cartridge into the device, or unlock a cartridge previously 173locked. Used to prevent user and software eject while the media is in 174use. 175.It Dv DIOCEJECT 176Eject the media cartridge from a removable device. 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. To avoid 193corruption, all accesses to the device will be discarded until there 194are no more open file descriptors referencing the device. During this 195period, all new open attempts will be rejected. When no more open 196file descriptors reference the device, the first next open will load a 197new 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.Sm off 215.El 216.Sh DIAGNOSTICS 217None. 218.Sh SEE ALSO 219.Xr wd 4 , 220.Xr disklabel 5 , 221.Xr disklabel 8 , 222.Xr fdisk 8 223.Sh HISTORY 224The 225.Nm 226driver was originally written for 227.Tn Mach 2282.5, and was ported to 229.Tn FreeBSD 230by Julian Elischer. 231It was later ported to 232.Tn NetBSD . 233