SD(4)

NAME
sd - SCSI disk driver

SYNOPSIS
disk sd
disk sd1 at scbus0 target 4 lun 0

DESCRIPTION
The sd driver provides support for a SCSI disk. It allows the disk to be divided up into a set of pseudo devices called partitions. In general the interfaces are similar to those described by wd(4).

Where the wd(4) device has a fairly low level interface to the system, SCSI devices have a much higher level interface and talk to the system via a SCSI host adapter (e.g., ahc(4)). A SCSI adapter must also be separately configured into the system before a SCSI disk can be configured.

When the SCSI adapter is probed during boot, the SCSI bus is scanned for devices. Any devices found which answer as ‘Direct’ type devices will be attached to the sd driver. In FreeBSD releases prior to 2.1, the first found was attached as sd0, the second sd1, and so on. Beginning in 2.1 it became possible to lock down the assignment of devices on the SCSI bus to particular units of the sd device; refer to scsi(4) for details on kernel configuration.

PARTITIONING
The sd driver allows the disk to have two levels of partitioning. One layer, called the “slice layer”, is used to separate the FreeBSD areas of the disk from areas used by other operating systems. The second layer is the native 4.4BSD partitioning scheme, disklabel(5), which is used to subdivide the FreeBSD slices into areas for individual filesystems and swap spaces. For more information, see fdisk(8) and disklabel(8), respectively.)

If an uninitialized disk is opened, the slice table will be initialized with a fictitious FreeBSD slice spanning the entire disk. Similarly, if an uninitialized (or non-FreeBSD) slice is opened, its disklabel will be initialized with parameters returned by the drive and a single ‘c’ partition encompassing the entire slice.

KERNEL CONFIGURATION
It is only necessary to explicitly configure one sd device; data structures are dynamically allocated as disks are found on the SCSI bus.

IOCTLS
The following ioctl(2) calls apply to SCSI disks as well as to other disks. They are defined in the header file <disklabel.h>.

DIOCSBAD
    Usually used to set up a bad-block mapping system on the disk. SCSI drive incorporate their own bad-block mapping so this command is not implemented.

DIOCGDINFO
    Read, from the kernel, the in-core copy of the disklabel for the drive. This may be a fictitious disklabel if the drive has never been initialized, in which case it will contain information read from the SCSI inquiry commands.

DIOCSDINFO
    Give the driver a new disklabel to use. The driver will not write the new disklabel to the disk.

DIOCWLABEL
    Enable or disable the driver's software write protect of the disklabel on the disk.

DIOCWDINFO
    Give the driver a new disklabel to use. The driver will write the new disklabel to the disk.

In addition, the scsi(4) general ioctl() commands may be used with the sd driver, but only against the ‘c’ (whole disk) partition.

NOTES
If a removable device is attached to the sd driver, then the act of changing the media will invalidate the disklabel and information held within the kernel. To avoid corruption, all accesses to the device will be discarded until there are no more open file descriptors referencing the device. During this period, all new open attempts will be rejected. When no more open file descriptors reference the device, the first next open will load a new set of parameters (including disklabel) for the drive.

FILES
/dev/rsdu
    raw mode SCSI disk unit u, accessed as an unpartitioned device
/dev/sdusn
    block mode SCSI disk unit u, slice n, accessed as an unpartitioned device
/dev/rsdusn
    raw mode SCSI disk unit u, slice accessed as an unpartitioned device
/dev/sdup
    block mode SCSI disk unit u, first FreeBSD slice, partition p
/dev/rsdup
    raw mode SCSI disk unit u, first FreeBSD slice, partition p
    /dev/sd u s n p block mode SCSI disk unit u, nth slice, partition p
    /dev/rsd u s n p raw mode SCSI disk unit u, nth slice, partition p

DIAGNOSTICS
None.

SEE ALSO
disklabel(8), fdisk(8), wd(4), disklabel(5)

HISTORY
The sd driver was originally written for Mach 2.5, and was ported to FreeBSD by Julian Elischer. Support for slices was written by Bruce Evans.