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