blob: 411f0984ff0eae45f1460e1577940d72be76aa5f [file] [log] [blame]
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +00001Introduction
2============
3The FreeBSD port of sg3_utils contains those utilities that are _not_
Douglas Gilbertdbdf66d2008-12-27 20:21:09 +00004specific to Linux. In some cases the FreeBSD camcontrol command supplies
5similar functionality; for example 'sg_map' is similar to
6'camcontrol devlist'.
7
8The dd variants from the sg3_utils package (e.g. sg_dd) rely on too many
Douglas Gilbert1cca59e2011-12-17 02:11:10 +00009Linux idiosyncrasies to be easily ported. A new package called 'ddpt'
Douglas Gilbertfdb38cb2009-02-05 17:42:34 +000010contains a utility with similar functionality to sg_dd and ddpt is available
Douglas Gilbertdbdf66d2008-12-27 20:21:09 +000011for FreeBSD.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000012
13Supported Utilities
14===================
15Here is a list of utilities that have been ported:
Douglas Gilbert35242f72017-09-25 21:57:43 +000016 sg_bg_ctl
Douglas Gilbertc0a72682013-01-18 00:51:54 +000017 sg_compare_and_write
Douglas Gilbert3c60a8b2010-12-06 02:27:23 +000018 sg_decode_sense
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000019 sg_format
20 sg_get_config
Douglas Gilberteaa9d922019-09-09 19:02:59 +000021 sg_get_elem_status
Douglas Gilbert53add622009-09-20 13:12:50 +000022 sg_get_lba_status
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000023 sg_ident
24 sg_inq [dropped ATA IDENTIFY DEVICE capability]
25 sg_logs
26 sg_luns
27 sg_modes
Douglas Gilbert75026472007-06-27 03:51:21 +000028 sg_opcodes
Douglas Gilbertdbdf66d2008-12-27 20:21:09 +000029 sg_persist
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000030 sg_prevent
Douglas Gilbert2e37f3d2007-06-27 03:53:07 +000031 sg_raw
Douglas Gilbert71e6e2d2007-06-27 03:24:23 +000032 sg_rdac
Douglas Gilbert242e1a82009-06-15 21:46:24 +000033 sg_read_block_limits
Douglas Gilbert75026472007-06-27 03:51:21 +000034 sg_read_buffer
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000035 sg_read_long
36 sg_readcap
37 sg_reassign
Douglas Gilbert542179b2010-09-13 16:41:13 +000038 sg_referrals
Douglas Gilbert62c85c82020-06-05 16:19:48 +000039 sg_rep_pip
Douglas Gilbertcad48992017-11-15 06:21:21 +000040 sg_rep_zones
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000041 sg_requests
42 sg_rmsn
43 sg_rtpg
Douglas Gilbert084021a2007-09-29 13:51:35 +000044 sg_safte
Douglas Gilbert857d1cc2011-06-22 15:13:59 +000045 sg_sanitize
Douglas Gilbert543a9ec2007-06-27 03:26:00 +000046 sg_sat_identify
Douglas Gilbert203814d2007-12-01 05:04:11 +000047 sg_sat_phy_event
Douglas Gilbert084021a2007-09-29 13:51:35 +000048 sg_sat_set_features
Douglas Gilbert3a7e1662018-01-28 06:50:39 +000049 sg_seek
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000050 sg_senddiag
51 sg_ses
52 sg_start
Douglas Gilbertf8340512007-09-01 03:01:06 +000053 sg_stpg
Douglas Gilbert3a7e1662018-01-28 06:50:39 +000054 sg_stream_ctl
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000055 sg_sync
56 sg_turs
57 sg_verify
Douglas Gilbert84323452009-06-11 20:41:54 +000058 sg_unmap
Douglas Gilbert71e6e2d2007-06-27 03:24:23 +000059 sg_vpd
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000060 sg_wr_mode
Douglas Gilbert75026472007-06-27 03:51:21 +000061 sg_write_buffer
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000062 sg_write_long
Douglas Gilbertf5674ee2009-03-11 17:53:31 +000063 sg_write_same
Douglas Gilbert35242f72017-09-25 21:57:43 +000064 sg_write_verify
Douglas Gilbertcad48992017-11-15 06:21:21 +000065 sg_write_x
66 sg_zone
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000067
68Most utility names are indicative of the main SCSI command
69that they execute. Some utilities are slightly higher level, for
70example sg_ses fetches SCSI Enclosure Services (SES) status pages and
71can send control pages. Each utility has a man page (placed in
72section 8). An overview of sg3_utils can be found at:
Douglas Gilbert28400772021-04-15 02:13:40 +000073https://sg.danny.cz/sg/sg3_utils.html .
Douglas Gilbert71e6e2d2007-06-27 03:24:23 +000074A copy of the "sg3_utils.html" file is in the "doc" subdirectory.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +000075
76
Douglas Gilbert3457b262010-04-24 20:56:46 +000077The executables and library can be built from the source code in
78the tarball and installed with the familiar
79"./configure ; make ; make install" sequence. If this fails try
80running the "./autogen.sh" script prior to that sequence. There
81are generic instruction on configure and friend in the INSTALL file.
82
Douglas Gilbert1cca59e2011-12-17 02:11:10 +000083Some man pages have examples which use Linux device names which
Douglas Gilbert3457b262010-04-24 20:56:46 +000084hopefully will not confuse the FreeBSD users.
85
86Device naming
87=============
88In FreeBSD disks have block names like '/dev/da0' with a corresponding
Douglas Gilbert9ccb5562021-03-28 00:58:36 +000089pass-through device name like '/dev/pass0'. Use this command:
90"camcontrol devlist" to see that SCSI devices available. To list NVMe
91devices: "nvmecontrol devlist" can be used. Any many, but not all
92contexts, the device name can be used without the '/dev/' prefix.
93FreeBSD is relatively unique in this respect and support for this
94abbreviated form has been broken in this package and fixed in
Douglas Gilbert0791cf62021-05-02 01:09:24 +000095sg3_utils release 1.46 .
96
97Device naming for NVMe is a bit more complex. Controllers have names
98like /dev/nvme0 and namespaces /dev/nvme0ns1 . Partitions are not
99supported on /dev/nvme0ns1 type nodes. Instead there are /dev/nvd0
100and /dev/nvd0p<m> where <m> is th partition number starting at 1.
101The nvd driver (written by Intel) is not CAM compatible and has its
102own utility nvmecontrol which has similar capabilities as camcontrol
103has for CAM devices. In FreeBSD release 12 the nda driver was
104introduced with names like /dev/nda0 and /dev/nda0n<m>. The difference
105is that nda is CAM compatible. From the point of view of this package,
106the nda driver is preferred as CAM supports NVMe command timeouts and
107the error processing is more mature.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000108
Douglas Gilbertbccea1a2012-01-19 14:09:40 +0000109FreeBSD installation
110====================
111The traditional './configure ; make ; make install' sequence from the
112top level of the unpacked tarball will work on FreeBSD. But the man pages
113will be placed under the /usr/local/share/man directory which unfortunately
114is not on the standard manpath. One solution is to add this path by
115creating a file with a name like local_share.conf in the
116/usr/local/etc/man.d/ directory and placing this line in it:
117 MANPATH /usr/local/share/man
118
119FreeBSD 9.0 has a "ports" entry for sg3_utils under the
120/usr/ports/sysutils directory. It points to version 1.28 of sg3_utils
121which is now a bit dated. It could be used as a template to point
122to more recent versions.
123
Douglas Gilberte799fe22011-02-26 02:23:57 +0000124kFreeBSD
125========
126sg3_utils can be built into a Debian package for kFreeBSD using the
127./build_debian.sh script in the top level directory. This has been tested
128with Debian 6.0 release.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000129
130Details
131=======
Douglas Gilbert3457b262010-04-24 20:56:46 +0000132Most of the ported utilities listed above use SCSI command functions
133declared in sg_cmds_*.h headers . Those SCSI command functions are
134implemented in the corresponding ".c" files. The ".c" files pass SCSI
135commands to the host operating system via an interface declared in sg_pt.h .
136There are currently five implementations of that interface depending on
137the host operating system:
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000138 - sg_pt_linux.c
139 - sg_pt_freebsd.c
140 - sg_pt_osf1.c [Tru64]
Douglas Gilbert543a9ec2007-06-27 03:26:00 +0000141 - sg_pt_win32.c
Douglas Gilbert3457b262010-04-24 20:56:46 +0000142 - sg_pt_solaris.c
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000143
Douglas Gilbert3457b262010-04-24 20:56:46 +0000144The sg_pt_freebsd.c file uses the FreeBSD CAM SCSI pass through mechanism.
145Hence only FreeBSD device nodes that support CAM can be used. These can be
146viewed with the "camcontrol devlist" command. To access ATAPI devices (e.g.
147ATAPI DVD drives) the kernel may need to be configured with the "atapicam"
148device.
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000149
Douglas Gilberte799fe22011-02-26 02:23:57 +0000150Attempts to send SCSI commands with data-in or data-out buffers around 64 KB
151and larger failed on a FreeBSD 7.0 with an "argument list too long" error
152message. There is an associated kernel message (viewable with dmesg) that an
153attempt has been made to map <n> bytes which is greater than
154DFLTPHYS(65536). Still a problem in FreeBSD 8.1 . Due to CAM overhead the
155largest power of 2 that can fit through with one command is 32768 bytes (32
156KB).
157
Douglas Gilbertbccea1a2012-01-19 14:09:40 +0000158FreeBSD 9.0 is the most recent version of FreeBSD tested with these
Douglas Gilbert3457b262010-04-24 20:56:46 +0000159utilities.
Douglas Gilbertdbdf66d2008-12-27 20:21:09 +0000160
Douglas Gilbert2e37f3d2007-06-27 03:53:07 +0000161
Douglas Gilbert68f4f8d2007-06-27 03:20:52 +0000162
Douglas Gilbertdd92db02012-02-10 23:09:25 +0000163Douglas Gilbert
Douglas Gilbert0791cf62021-05-02 01:09:24 +00001641st May 2021