Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 1 | Introduction |
| 2 | ============ |
| 3 | The FreeBSD port of sg3_utils contains those utilities that are _not_ |
Douglas Gilbert | dbdf66d | 2008-12-27 20:21:09 +0000 | [diff] [blame] | 4 | specific to Linux. In some cases the FreeBSD camcontrol command supplies |
| 5 | similar functionality; for example 'sg_map' is similar to |
| 6 | 'camcontrol devlist'. |
| 7 | |
| 8 | The dd variants from the sg3_utils package (e.g. sg_dd) rely on too many |
Douglas Gilbert | 1cca59e | 2011-12-17 02:11:10 +0000 | [diff] [blame] | 9 | Linux idiosyncrasies to be easily ported. A new package called 'ddpt' |
Douglas Gilbert | fdb38cb | 2009-02-05 17:42:34 +0000 | [diff] [blame] | 10 | contains a utility with similar functionality to sg_dd and ddpt is available |
Douglas Gilbert | dbdf66d | 2008-12-27 20:21:09 +0000 | [diff] [blame] | 11 | for FreeBSD. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 12 | |
| 13 | Supported Utilities |
| 14 | =================== |
| 15 | Here is a list of utilities that have been ported: |
Douglas Gilbert | 35242f7 | 2017-09-25 21:57:43 +0000 | [diff] [blame] | 16 | sg_bg_ctl |
Douglas Gilbert | c0a7268 | 2013-01-18 00:51:54 +0000 | [diff] [blame] | 17 | sg_compare_and_write |
Douglas Gilbert | 3c60a8b | 2010-12-06 02:27:23 +0000 | [diff] [blame] | 18 | sg_decode_sense |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 19 | sg_format |
| 20 | sg_get_config |
Douglas Gilbert | eaa9d92 | 2019-09-09 19:02:59 +0000 | [diff] [blame] | 21 | sg_get_elem_status |
Douglas Gilbert | 53add62 | 2009-09-20 13:12:50 +0000 | [diff] [blame] | 22 | sg_get_lba_status |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 23 | sg_ident |
| 24 | sg_inq [dropped ATA IDENTIFY DEVICE capability] |
| 25 | sg_logs |
| 26 | sg_luns |
| 27 | sg_modes |
Douglas Gilbert | 7502647 | 2007-06-27 03:51:21 +0000 | [diff] [blame] | 28 | sg_opcodes |
Douglas Gilbert | dbdf66d | 2008-12-27 20:21:09 +0000 | [diff] [blame] | 29 | sg_persist |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 30 | sg_prevent |
Douglas Gilbert | 2e37f3d | 2007-06-27 03:53:07 +0000 | [diff] [blame] | 31 | sg_raw |
Douglas Gilbert | 71e6e2d | 2007-06-27 03:24:23 +0000 | [diff] [blame] | 32 | sg_rdac |
Douglas Gilbert | 242e1a8 | 2009-06-15 21:46:24 +0000 | [diff] [blame] | 33 | sg_read_block_limits |
Douglas Gilbert | 7502647 | 2007-06-27 03:51:21 +0000 | [diff] [blame] | 34 | sg_read_buffer |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 35 | sg_read_long |
| 36 | sg_readcap |
| 37 | sg_reassign |
Douglas Gilbert | 542179b | 2010-09-13 16:41:13 +0000 | [diff] [blame] | 38 | sg_referrals |
Douglas Gilbert | 62c85c8 | 2020-06-05 16:19:48 +0000 | [diff] [blame] | 39 | sg_rep_pip |
Douglas Gilbert | cad4899 | 2017-11-15 06:21:21 +0000 | [diff] [blame] | 40 | sg_rep_zones |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 41 | sg_requests |
| 42 | sg_rmsn |
| 43 | sg_rtpg |
Douglas Gilbert | 084021a | 2007-09-29 13:51:35 +0000 | [diff] [blame] | 44 | sg_safte |
Douglas Gilbert | 857d1cc | 2011-06-22 15:13:59 +0000 | [diff] [blame] | 45 | sg_sanitize |
Douglas Gilbert | 543a9ec | 2007-06-27 03:26:00 +0000 | [diff] [blame] | 46 | sg_sat_identify |
Douglas Gilbert | 203814d | 2007-12-01 05:04:11 +0000 | [diff] [blame] | 47 | sg_sat_phy_event |
Douglas Gilbert | 084021a | 2007-09-29 13:51:35 +0000 | [diff] [blame] | 48 | sg_sat_set_features |
Douglas Gilbert | 3a7e166 | 2018-01-28 06:50:39 +0000 | [diff] [blame] | 49 | sg_seek |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 50 | sg_senddiag |
| 51 | sg_ses |
| 52 | sg_start |
Douglas Gilbert | f834051 | 2007-09-01 03:01:06 +0000 | [diff] [blame] | 53 | sg_stpg |
Douglas Gilbert | 3a7e166 | 2018-01-28 06:50:39 +0000 | [diff] [blame] | 54 | sg_stream_ctl |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 55 | sg_sync |
| 56 | sg_turs |
| 57 | sg_verify |
Douglas Gilbert | 8432345 | 2009-06-11 20:41:54 +0000 | [diff] [blame] | 58 | sg_unmap |
Douglas Gilbert | 71e6e2d | 2007-06-27 03:24:23 +0000 | [diff] [blame] | 59 | sg_vpd |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 60 | sg_wr_mode |
Douglas Gilbert | 7502647 | 2007-06-27 03:51:21 +0000 | [diff] [blame] | 61 | sg_write_buffer |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 62 | sg_write_long |
Douglas Gilbert | f5674ee | 2009-03-11 17:53:31 +0000 | [diff] [blame] | 63 | sg_write_same |
Douglas Gilbert | 35242f7 | 2017-09-25 21:57:43 +0000 | [diff] [blame] | 64 | sg_write_verify |
Douglas Gilbert | cad4899 | 2017-11-15 06:21:21 +0000 | [diff] [blame] | 65 | sg_write_x |
| 66 | sg_zone |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 67 | |
| 68 | Most utility names are indicative of the main SCSI command |
| 69 | that they execute. Some utilities are slightly higher level, for |
| 70 | example sg_ses fetches SCSI Enclosure Services (SES) status pages and |
| 71 | can send control pages. Each utility has a man page (placed in |
| 72 | section 8). An overview of sg3_utils can be found at: |
Douglas Gilbert | 2840077 | 2021-04-15 02:13:40 +0000 | [diff] [blame] | 73 | https://sg.danny.cz/sg/sg3_utils.html . |
Douglas Gilbert | 71e6e2d | 2007-06-27 03:24:23 +0000 | [diff] [blame] | 74 | A copy of the "sg3_utils.html" file is in the "doc" subdirectory. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 75 | |
| 76 | |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 77 | The executables and library can be built from the source code in |
| 78 | the tarball and installed with the familiar |
| 79 | "./configure ; make ; make install" sequence. If this fails try |
| 80 | running the "./autogen.sh" script prior to that sequence. There |
| 81 | are generic instruction on configure and friend in the INSTALL file. |
| 82 | |
Douglas Gilbert | 1cca59e | 2011-12-17 02:11:10 +0000 | [diff] [blame] | 83 | Some man pages have examples which use Linux device names which |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 84 | hopefully will not confuse the FreeBSD users. |
| 85 | |
| 86 | Device naming |
| 87 | ============= |
| 88 | In FreeBSD disks have block names like '/dev/da0' with a corresponding |
Douglas Gilbert | 9ccb556 | 2021-03-28 00:58:36 +0000 | [diff] [blame] | 89 | pass-through device name like '/dev/pass0'. Use this command: |
| 90 | "camcontrol devlist" to see that SCSI devices available. To list NVMe |
| 91 | devices: "nvmecontrol devlist" can be used. Any many, but not all |
| 92 | contexts, the device name can be used without the '/dev/' prefix. |
| 93 | FreeBSD is relatively unique in this respect and support for this |
| 94 | abbreviated form has been broken in this package and fixed in |
Douglas Gilbert | 0791cf6 | 2021-05-02 01:09:24 +0000 | [diff] [blame] | 95 | sg3_utils release 1.46 . |
| 96 | |
| 97 | Device naming for NVMe is a bit more complex. Controllers have names |
| 98 | like /dev/nvme0 and namespaces /dev/nvme0ns1 . Partitions are not |
| 99 | supported on /dev/nvme0ns1 type nodes. Instead there are /dev/nvd0 |
| 100 | and /dev/nvd0p<m> where <m> is th partition number starting at 1. |
| 101 | The nvd driver (written by Intel) is not CAM compatible and has its |
| 102 | own utility nvmecontrol which has similar capabilities as camcontrol |
| 103 | has for CAM devices. In FreeBSD release 12 the nda driver was |
| 104 | introduced with names like /dev/nda0 and /dev/nda0n<m>. The difference |
| 105 | is that nda is CAM compatible. From the point of view of this package, |
| 106 | the nda driver is preferred as CAM supports NVMe command timeouts and |
| 107 | the error processing is more mature. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 108 | |
Douglas Gilbert | bccea1a | 2012-01-19 14:09:40 +0000 | [diff] [blame] | 109 | FreeBSD installation |
| 110 | ==================== |
| 111 | The traditional './configure ; make ; make install' sequence from the |
| 112 | top level of the unpacked tarball will work on FreeBSD. But the man pages |
| 113 | will be placed under the /usr/local/share/man directory which unfortunately |
| 114 | is not on the standard manpath. One solution is to add this path by |
| 115 | creating 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 | |
| 119 | FreeBSD 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 |
| 121 | which is now a bit dated. It could be used as a template to point |
| 122 | to more recent versions. |
| 123 | |
Douglas Gilbert | e799fe2 | 2011-02-26 02:23:57 +0000 | [diff] [blame] | 124 | kFreeBSD |
| 125 | ======== |
| 126 | sg3_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 |
| 128 | with Debian 6.0 release. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 129 | |
| 130 | Details |
| 131 | ======= |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 132 | Most of the ported utilities listed above use SCSI command functions |
| 133 | declared in sg_cmds_*.h headers . Those SCSI command functions are |
| 134 | implemented in the corresponding ".c" files. The ".c" files pass SCSI |
| 135 | commands to the host operating system via an interface declared in sg_pt.h . |
| 136 | There are currently five implementations of that interface depending on |
| 137 | the host operating system: |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 138 | - sg_pt_linux.c |
| 139 | - sg_pt_freebsd.c |
| 140 | - sg_pt_osf1.c [Tru64] |
Douglas Gilbert | 543a9ec | 2007-06-27 03:26:00 +0000 | [diff] [blame] | 141 | - sg_pt_win32.c |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 142 | - sg_pt_solaris.c |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 143 | |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 144 | The sg_pt_freebsd.c file uses the FreeBSD CAM SCSI pass through mechanism. |
| 145 | Hence only FreeBSD device nodes that support CAM can be used. These can be |
| 146 | viewed with the "camcontrol devlist" command. To access ATAPI devices (e.g. |
| 147 | ATAPI DVD drives) the kernel may need to be configured with the "atapicam" |
| 148 | device. |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 149 | |
Douglas Gilbert | e799fe2 | 2011-02-26 02:23:57 +0000 | [diff] [blame] | 150 | Attempts to send SCSI commands with data-in or data-out buffers around 64 KB |
| 151 | and larger failed on a FreeBSD 7.0 with an "argument list too long" error |
| 152 | message. There is an associated kernel message (viewable with dmesg) that an |
| 153 | attempt has been made to map <n> bytes which is greater than |
| 154 | DFLTPHYS(65536). Still a problem in FreeBSD 8.1 . Due to CAM overhead the |
| 155 | largest power of 2 that can fit through with one command is 32768 bytes (32 |
| 156 | KB). |
| 157 | |
Douglas Gilbert | bccea1a | 2012-01-19 14:09:40 +0000 | [diff] [blame] | 158 | FreeBSD 9.0 is the most recent version of FreeBSD tested with these |
Douglas Gilbert | 3457b26 | 2010-04-24 20:56:46 +0000 | [diff] [blame] | 159 | utilities. |
Douglas Gilbert | dbdf66d | 2008-12-27 20:21:09 +0000 | [diff] [blame] | 160 | |
Douglas Gilbert | 2e37f3d | 2007-06-27 03:53:07 +0000 | [diff] [blame] | 161 | |
Douglas Gilbert | 68f4f8d | 2007-06-27 03:20:52 +0000 | [diff] [blame] | 162 | |
Douglas Gilbert | dd92db0 | 2012-02-10 23:09:25 +0000 | [diff] [blame] | 163 | Douglas Gilbert |
Douglas Gilbert | 0791cf6 | 2021-05-02 01:09:24 +0000 | [diff] [blame] | 164 | 1st May 2021 |