---
name: "sg"
section: "4"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/sg/4"
---

# sg(4)

Linux ioctl-compatible SCSI passthru device

## NAME

**sg** – Linux ioctl-compatible SCSI passthru device

## SYNOPSIS

**device** **sg** **device** **scbus**

## DESCRIPTION

The **sg** driver provides a Linux compatible scsi passthru device. This driver attaches to all [cam(4)](/cam/4.md) peripheral devices. It is similar to the [pass(4)](/pass/4.md) device, but uses the Linux interfaces, rather than the FreeBSD CAM interfaces.

## IOCTL

The following subset of the Linux sg ioctl interfaces are implemented:

- *SG\_SET\_TIMEOUT*

  *u\_int*, *to* Set the timeout in milliseconds.

- *SG\_GET\_TIMEOUT*

  Get the timeout in milliseconds

- *SG\_GET\_RESERVED\_SIZE*

  *u\_int* Returns the size of the I/O one can do this device.

- *SG\_GET\_SCSI\_ID*

  *struct*, *sg\_scsi\_id* Returns the bus number, channel, scsi bus ID number, lun and other information about the SCSI device.

- *SG\_GET\_SG\_TABLESIZE*

  *u\_int* Returns the table size, though hard wired to 0.

- *SG\_GET\_VERSION\_NUM*

  *u\_int* Return the version number that is implemented.

- *SG\_IO*

  *struct*, *sg\_io\_hdr*

All other ioctl interfaces return *ENODEV*.

## FILES

- */dev/sg\**

  Passthru devices.

## SEE ALSO

[cam(4)](/cam/4.md), [pass(4)](/pass/4.md)

## HISTORY

The **sg** driver first appeared in FreeBSD 7.0.
