Douglas Gilbert | 15a477c | 2021-09-04 17:23:12 +0000 | [diff] [blame] | 1 | .TH SG_XCOPY "8" "September 2021" "sg3_utils\-1.47" SG3_UTILS |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 2 | .SH NAME |
Douglas Gilbert | 7cbe22a | 2012-11-21 00:39:11 +0000 | [diff] [blame] | 3 | sg_xcopy \- copy data to and from files and devices using SCSI EXTENDED |
| 4 | COPY (XCOPY) |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 5 | .SH SYNOPSIS |
| 6 | .B sg_xcopy |
| 7 | [\fIbs=BS\fR] [\fIconv=CONV\fR] [\fIcount=COUNT\fR] [\fIibs=BS\fR] |
| 8 | [\fIif=IFILE\fR] [\fIiflag=FLAGS\fR] [\fIobs=BS\fR] [\fIof=OFILE\fR] |
| 9 | [\fIoflag=FLAGS\fR] [\fIseek=SEEK\fR] [\fIskip=SKIP\fR] [\fI\-\-help\fR] |
| 10 | [\fI\-\-version\fR] |
| 11 | .PP |
Douglas Gilbert | a918d1a | 2019-01-23 16:25:58 +0000 | [diff] [blame] | 12 | [\fIapp=\fR0|1] [\fIbpt=BPT\fR] [\fIcat=\fR0|1] [\fIdc=\fR0|1] [\fIfco=\fR0|1] |
Douglas Gilbert | 43c7d12 | 2013-06-28 17:44:32 +0000 | [diff] [blame] | 13 | [\fIid_usage=\fR{hold|discard|disable}] [\fIlist_id=ID\fR] [\fIprio=PRIO\fR] |
Douglas Gilbert | 02ec79b | 2013-05-08 13:21:30 +0000 | [diff] [blame] | 14 | [\fItime=\fR0|1] [\fIverbose=VERB\fR] [\fI\-\-on_dst|\-\-on_src\fR] |
| 15 | [\fI\-\-verbose\fR] |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 16 | .SH DESCRIPTION |
| 17 | .\" Add any additional description here |
| 18 | .PP |
| 19 | Copy data to and from any files. Specialized for "files" that are Linux SCSI |
Douglas Gilbert | 43c7d12 | 2013-06-28 17:44:32 +0000 | [diff] [blame] | 20 | devices that support the SCSI EXTENDED COPY (XCOPY) command. |
| 21 | .PP |
Douglas Gilbert | 43c7d12 | 2013-06-28 17:44:32 +0000 | [diff] [blame] | 22 | This utility |
| 23 | has similar syntax and semantics to |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 24 | .B dd(1) |
| 25 | but with no "conversions" is supported. |
| 26 | .PP |
| 27 | The first group in the synopsis above are "standard" Unix |
| 28 | .B dd(1) |
| 29 | operands. The second group are extra options added by this utility. |
Douglas Gilbert | 02ec79b | 2013-05-08 13:21:30 +0000 | [diff] [blame] | 30 | Both groups are defined below in combined, alphabetical order. |
| 31 | .PP |
Douglas Gilbert | 5f1cabf | 2013-12-14 02:20:41 +0000 | [diff] [blame] | 32 | By default the XCOPY command is sent to \fIOFILE\fR. This can be changed |
Douglas Gilbert | cf49114 | 2016-03-02 22:04:21 +0000 | [diff] [blame] | 33 | with the \fI\-\-on_src\fR or \fIiflag=xflag\fR options which cause the XCOPY |
Douglas Gilbert | 5f1cabf | 2013-12-14 02:20:41 +0000 | [diff] [blame] | 34 | command to be sent to \fIIFILE\fR instead. Also see the section on |
| 35 | ENVIRONMENT VARIABLES. |
Douglas Gilbert | e502efd | 2014-03-10 10:17:47 +0000 | [diff] [blame] | 36 | .PP |
Douglas Gilbert | a918d1a | 2019-01-23 16:25:58 +0000 | [diff] [blame] | 37 | In the SPC\-4 standard the T10 committee has expanded the XCOPY command so |
| 38 | that it now has two variants: "LID1" (for a List Identifier length of 1 byte) |
| 39 | and "LID4" (for a List Identifier length of 4 bytes). This utility supports |
| 40 | the older, LID1 variant which is also found in SPC\-3 and earlier. While the |
| 41 | LID1 variant in SPC\-4 is command level (binary) compatible with XCOPY as |
| 42 | defined in SPC\-3, some of the command naming has changed. This utility uses |
| 43 | the older, SPC\-3 XCOPY names. |
| 44 | .PP |
Douglas Gilbert | e502efd | 2014-03-10 10:17:47 +0000 | [diff] [blame] | 45 | The ddpt utility supports the same xcopy(LID1) functionality as this utility |
| 46 | with the same options and flags. Additionally ddpt supports a subset of |
| 47 | xcopy(LID4) functionality variously called "xcopy version 2, lite" or ODX. |
| 48 | ODX is a market name and stands for Offloaded Data Xfer (i.e. transfer). |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 49 | .SH OPTIONS |
| 50 | .TP |
Douglas Gilbert | a918d1a | 2019-01-23 16:25:58 +0000 | [diff] [blame] | 51 | \fBapp\fR={0|1} |
| 52 | if 1 start the destination of the copy at the end of OFILE. This assumes |
| 53 | that OFILE is a regular file. The default is 0 in which case the destination |
| 54 | of the copy starts at the beginning of OFILE (possibly offset be SEEK). This |
| 55 | option cannot be used with the \fIseek=SEEK\fR option. |
| 56 | .TP |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 57 | \fBbpt\fR=\fIBPT\fR |
| 58 | each IO transaction will be made using \fIBPT\fR blocks (or less if near |
Douglas Gilbert | a059c85 | 2018-08-13 05:24:09 +0000 | [diff] [blame] | 59 | the end of the copy). Default is 128 for logical block sizes less that 2048 |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 60 | bytes, otherwise the default is 32. So for bs=512 the reads and writes |
| 61 | will each convey 64 KiB of data by default (less if near the end of the |
| 62 | transfer or memory restrictions). When cd/dvd drives are accessed, the |
Douglas Gilbert | a059c85 | 2018-08-13 05:24:09 +0000 | [diff] [blame] | 63 | logical block size is typically 2048 bytes and bpt defaults to 32 which again |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 64 | implies 64 KiB transfers. |
| 65 | .TP |
| 66 | \fBbs\fR=\fIBS\fR |
| 67 | where \fIBS\fR |
| 68 | .B must |
Douglas Gilbert | a059c85 | 2018-08-13 05:24:09 +0000 | [diff] [blame] | 69 | be the logical block size of the physical device (if either the input or |
| 70 | output files are accessed via SCSI commands). Note that this differs from |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 71 | .B dd(1) |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 72 | which permits \fIBS\fR to be an integral multiple. Defaults to the |
Douglas Gilbert | a059c85 | 2018-08-13 05:24:09 +0000 | [diff] [blame] | 73 | device logical block size. |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 74 | .TP |
Douglas Gilbert | 43c7d12 | 2013-06-28 17:44:32 +0000 | [diff] [blame] | 75 | \fBcat\fR={0|1} |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 76 | sets the SCSI EXTENDED COPY command segment descriptor CAT bit to 0 or |
Douglas Gilbert | e2a8a0b | 2013-03-14 00:26:26 +0000 | [diff] [blame] | 77 | 1 (default: 0). The CAT bit (in conjunction with the PAD bit) controls |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 78 | the handling of residual data. See section |
| 79 | .B HANDLING OF RESIDUAL DATA |
| 80 | for details. |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 81 | .TP |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 82 | \fBconv\fR=\fBCONV\fR |
| 83 | all \fBCONV\fR arguments are ignored. |
| 84 | .TP |
| 85 | \fBcount\fR=\fICOUNT\fR |
| 86 | copy \fICOUNT\fR blocks from \fIIFILE\fR to \fIOFILE\fR. Default is the |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 87 | minimum (\fIIFILE\fR if \fIdc=0\fR or \fIOFILE\fR if \fIdc=1\fR) |
| 88 | number of blocks that SCSI devices report from SCSI READ CAPACITY |
| 89 | commands or that block devices (or their partitions) report. Normal |
| 90 | files are not probed for their size. If \fIskip=SKIP\fR or |
Douglas Gilbert | 8bdc552 | 2019-03-02 01:03:55 +0000 | [diff] [blame] | 91 | \fIseek=SEEK\fR are given and the count is derived (i.e. not |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 92 | explicitly given) then the derived count is scaled back so that the |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 93 | copy will not overrun the device. If the file name is a block device |
| 94 | partition and \fICOUNT\fR is not given then the size of the partition |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 95 | rather than the size of the whole device is used. If \fICOUNT\fR is |
Douglas Gilbert | 5915919 | 2012-12-22 03:05:14 +0000 | [diff] [blame] | 96 | not given (or \fIcount=\-1\fR) and cannot be derived then an error |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 97 | message is issued and no copy takes place. |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 98 | .TP |
Douglas Gilbert | a918d1a | 2019-01-23 16:25:58 +0000 | [diff] [blame] | 99 | \fBdc\fR={0|1} |
| 100 | sets the SCSI EXTENDED COPY command segment descriptor DC bit to 0 or |
| 101 | 1 (default: 0). The DC bit controls whether \fICOUNT\fR |
| 102 | refers to the source (\fIdc=0\fR) or the target (\fIdc=1\fR) descriptor. |
| 103 | .TP |
| 104 | \fBfco\fR={0|1} |
| 105 | sets the SCSI EXTENDED COPY command segment descriptor FCO bit to 0 or |
| 106 | 1 (default: 0). The Fast Copy Only (FCO) bit set will result in the |
| 107 | copy being done but a technique faster than SCSI READ and WRITE commands. |
| 108 | If the copy cannot but done in a faster manner then a sense key of "Copy |
| 109 | aborted" with and additional sense of "Fast copy not possible" is |
| 110 | returned. |
| 111 | .TP |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 112 | \fBibs\fR=\fIBS\fR |
| 113 | if given must be the same as \fIBS\fR given to 'bs=' option. |
| 114 | .TP |
Douglas Gilbert | 43c7d12 | 2013-06-28 17:44:32 +0000 | [diff] [blame] | 115 | \fBid_usage\fR={hold|discard|disable} |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 116 | sets the SCSI EXTENDED COPY command parameter list field called LIST ID |
Douglas Gilbert | 853b6b4 | 2013-02-08 05:12:53 +0000 | [diff] [blame] | 117 | USAGE to 0 if the argument is 'hold', to 2 if the argument is 'discard', |
| 118 | or to '3' if the argument is 'disable'. |
Douglas Gilbert | e65afc2 | 2015-03-11 16:54:10 +0000 | [diff] [blame] | 119 | .br |
| 120 | If the device has the ability to hold data (as indicated by "held data |
| 121 | limit" being greater than zero) then \fIid_usage\fR defaults to 'hold' |
| 122 | otherwise it defaults to 'discard'. |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 123 | .TP |
| 124 | \fBif\fR=\fIIFILE\fR |
| 125 | read from \fIIFILE\fR instead of stdin. If \fIIFILE\fR is '\-' then stdin |
| 126 | is read. Starts reading at the beginning of \fIIFILE\fR unless \fISKIP\fR |
| 127 | is given. |
| 128 | .TP |
| 129 | \fBiflag\fR=\fIFLAGS\fR |
| 130 | where \fIFLAGS\fR is a comma separated list of one or more flags outlined |
| 131 | below. These flags are associated with \fIIFILE\fR and are ignored when |
| 132 | \fIIFILE\fR is stdin. |
| 133 | .TP |
Douglas Gilbert | e65afc2 | 2015-03-11 16:54:10 +0000 | [diff] [blame] | 134 | \fBlist_id\fR=\fIID\fR |
| 135 | sets the SCSI EXTENDED COPY command parameter list field called LIST |
| 136 | IDENTIFIER to \fIID\fR. \fIID\fR should be a value between 0 and |
| 137 | 255 (inclusive). \fIID\fR usually defaults to 1 unless |
| 138 | \fIid_usage=disable\fR in which case it defaults to 0. |
| 139 | .TP |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 140 | \fBobs\fR=\fIBS\fR |
| 141 | if given must be the same as \fIBS\fR given to 'bs=' option. |
| 142 | .TP |
| 143 | \fBof\fR=\fIOFILE\fR |
| 144 | write to \fIOFILE\fR instead of stdout. If \fIOFILE\fR is '\-' then writes |
| 145 | to stdout. If \fIOFILE\fR is /dev/null then no actual writes are performed. |
| 146 | If \fIOFILE\fR is '.' (period) then it is treated the same way as |
| 147 | /dev/null (this is a shorthand notation). If \fIOFILE\fR exists then it |
| 148 | is _not_ truncated; it is overwritten from the start of \fIOFILE\fR |
| 149 | unless 'oflag=append' or \fISEEK\fR is given. |
| 150 | .TP |
| 151 | \fBoflag\fR=\fIFLAGS\fR |
| 152 | where \fIFLAGS\fR is a comma separated list of one or more flags outlined |
| 153 | below. These flags are associated with \fIOFILE\fR and are ignored when |
| 154 | \fIOFILE\fR is /dev/null, '.' (period), or stdout. |
| 155 | .TP |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 156 | \fBprio\fR=\fIPRIO\fR |
| 157 | sets the SCSI EXTENDED COPY command parameter list field called PRIORITY |
| 158 | to \fIPRIO\fR. The default value is 1. |
| 159 | .TP |
| 160 | \fBseek\fR=\fISEEK\fR |
| 161 | start writing \fISEEK\fR bs\-sized blocks from the start of \fIOFILE\fR. |
| 162 | Default is block 0 (i.e. start of file). |
| 163 | .TP |
| 164 | \fBskip\fR=\fISKIP\fR |
| 165 | start reading \fISKIP\fR bs\-sized blocks from the start of \fIIFILE\fR. |
| 166 | Default is block 0 (i.e. start of file). |
| 167 | .TP |
Douglas Gilbert | 43c7d12 | 2013-06-28 17:44:32 +0000 | [diff] [blame] | 168 | \fBtime\fR={0|1} |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 169 | when 1, times transfer and does throughput calculation, outputting the |
| 170 | results (to stderr) at completion. When 0 (default) doesn't perform timing. |
| 171 | .TP |
| 172 | \fBverbose\fR=\fIVERB\fR |
| 173 | as \fIVERB\fR increases so does the amount of debug output sent to stderr. |
| 174 | Default value is zero which yields the minimum amount of debug output. |
| 175 | A value of 1 reports extra information that is not repetitive. A value |
| 176 | 2 reports cdbs and responses for SCSI commands that are not repetitive |
| 177 | (i.e. other that READ and WRITE). Error processing is not considered |
| 178 | repetitive. Values of 3 and 4 yield output for all SCSI commands (and |
| 179 | Unix read() and write() calls) so there can be a lot of output. |
| 180 | .TP |
Douglas Gilbert | 02ec79b | 2013-05-08 13:21:30 +0000 | [diff] [blame] | 181 | \fB\-h\fR, \fB\-\-help\fR |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 182 | outputs usage message and exits. |
| 183 | .TP |
Douglas Gilbert | 02ec79b | 2013-05-08 13:21:30 +0000 | [diff] [blame] | 184 | \fB\-\-on_dst\fR |
Douglas Gilbert | 5f1cabf | 2013-12-14 02:20:41 +0000 | [diff] [blame] | 185 | send the XCOPY command to the output file/device (i.e. \fIOFILE\fR). This is |
| 186 | the default unless overridden by the \fI\-\-on_src\fR or \fIiflag=xflag\fR |
| 187 | options. Also see the section below on ENVIRONMENT VARIABLES. |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 188 | .TP |
Douglas Gilbert | 02ec79b | 2013-05-08 13:21:30 +0000 | [diff] [blame] | 189 | \fB\-\-on_src\fR |
Douglas Gilbert | 5f1cabf | 2013-12-14 02:20:41 +0000 | [diff] [blame] | 190 | send the XCOPY command to the input file/device (i.e. \fIIFILE\fR). |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 191 | .TP |
Douglas Gilbert | 02ec79b | 2013-05-08 13:21:30 +0000 | [diff] [blame] | 192 | \fB\-v\fR, \fB\-\-verbose\fR |
| 193 | equivalent to \fIverbose=1\fR. When used twice, equivalent to |
| 194 | \fIverbose=2\fR, etc. |
| 195 | .TP |
| 196 | \fB\-V\fR, \fB\-\-version\fR |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 197 | outputs version number information and exits. |
| 198 | .SH FLAGS |
| 199 | Here is a list of flags and their meanings: |
| 200 | .TP |
| 201 | append |
| 202 | causes the O_APPEND flag to be added to the open of \fIOFILE\fR. For regular |
| 203 | files this will lead to data appended to the end of any existing data. |
| 204 | Cannot be used together with the \fIseek=SEEK\fR option as they conflict. |
| 205 | The default action of this utility is to overwrite any existing data |
| 206 | from the beginning of the file or, if \fISEEK\fR is given, starting at |
| 207 | block \fISEEK\fR. Note that attempting to 'append' to a device file (e.g. |
| 208 | a disk) will usually be ignored or may cause an error to be reported. |
| 209 | .TP |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 210 | excl |
| 211 | causes the O_EXCL flag to be added to the open of \fIIFILE\fR and/or |
| 212 | \fIOFILE\fR. |
| 213 | .TP |
| 214 | flock |
| 215 | after opening the associated file (i.e. \fIIFILE\fR and/or \fIOFILE\fR) |
| 216 | an attempt is made to get an advisory exclusive lock with the flock() |
| 217 | system call. The flock arguments are "FLOCK_EX | FLOCK_NB" which will |
| 218 | cause the lock to be taken if available else a "temporarily unavailable" |
| 219 | error is generated. An exit status of 90 is produced in the latter case |
| 220 | and no copy is done. |
| 221 | .TP |
| 222 | null |
| 223 | has no affect, just a placeholder. |
Douglas Gilbert | e8a28a4 | 2013-10-08 14:24:59 +0000 | [diff] [blame] | 224 | .TP |
| 225 | pad |
| 226 | sets the SCSI EXTENDED COPY command segment descriptor PAD bit. The |
| 227 | PAD bit (in conjunction with the CAT bit) controls the handling of |
| 228 | residual data.(See section |
| 229 | .B HANDLING OF RESIDUAL DATA |
| 230 | for details. |
| 231 | .TP |
| 232 | xcopy |
| 233 | has no affect; for compatibility with ddpt. |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 234 | .SH HANDLING OF RESIDUAL DATA |
| 235 | The \fIpad\fR and \fIcat\fR bits control the handling of residual |
| 236 | data. As the data can be specified either in terms of source or target |
Douglas Gilbert | a059c85 | 2018-08-13 05:24:09 +0000 | [diff] [blame] | 237 | logical block size and both might have different block sizes residual data |
| 238 | is likely to happen in these cases. |
| 239 | If both logical block sizes are identical these bits have no effect as |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 240 | residual data will not occur. |
| 241 | .PP |
| 242 | If none of these bits are set, the EXTENDED COPY command will be |
| 243 | aborted with additional sense 'UNEXPECTED INEXACT SEGMENT'. |
| 244 | .PP |
| 245 | If only the \fIcat\fR bit is set the residual data will be retained |
| 246 | and made available for subsequent segment descriptors. Residual data |
| 247 | will be discarded for the last segment descriptor. |
| 248 | .PP |
| 249 | If the \fIpad\fR bit is set for the source descriptor only, any |
| 250 | residual data for both source or destination will be discarded. |
| 251 | .PP |
| 252 | If the \fIpad\fR bit is set for the target descriptor only any |
| 253 | residual source data will be handled as if the \fIcat\fR bit is set, |
| 254 | but any residual destination data will be padded to make a whole block |
| 255 | transfer. |
| 256 | .PP |
| 257 | If the \fIpad\fR bit is set for both source and target any residual |
| 258 | source data will be discarded, and any residual destination data will |
| 259 | be padded. |
Douglas Gilbert | 5f1cabf | 2013-12-14 02:20:41 +0000 | [diff] [blame] | 260 | .SH ENVIRONMENT VARIABLES |
| 261 | If the command line invocation does not explicitly (and unambiguously) |
| 262 | indicate whether the XCOPY SCSI command should be sent to \fIIFILE\fR (i.e. |
| 263 | the source) or \fIOFILE\fR (i.e. the destination) then a check is |
| 264 | made for the presence of the XCOPY_TO_SRC and XCOPY_TO_DST environment |
| 265 | variables. If either one exists (but not both) then it indicates where |
| 266 | the SCSI XCOPY command will be sent. By default the XCOPY command is |
| 267 | sent to \fIOFILE\fR. |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 268 | .SH RETIRED OPTIONS |
| 269 | Here are some retired options that are still present: |
| 270 | .TP |
| 271 | append=0 | 1 |
| 272 | when set, equivalent to 'oflag=append'. When clear the action is |
| 273 | to overwrite the existing file (if it exists); this is the default. |
| 274 | See the 'append' flag. |
| 275 | .SH NOTES |
Douglas Gilbert | a93e55e | 2014-09-18 05:20:09 +0000 | [diff] [blame] | 276 | Copying data behind an Operating System's back can cause problems. In the |
| 277 | case of Linux, users should look at this link: |
Douglas Gilbert | 2840077 | 2021-04-15 02:13:40 +0000 | [diff] [blame] | 278 | https://linux\-mm.org/Drop_Caches |
Douglas Gilbert | a93e55e | 2014-09-18 05:20:09 +0000 | [diff] [blame] | 279 | .br |
| 280 | This command sequence may be useful: |
| 281 | .br |
| 282 | sync; echo 3 > /proc/sys/vm/drop_caches |
| 283 | .PP |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 284 | Various numeric arguments (e.g. \fISKIP\fR) may include multiplicative |
| 285 | suffixes or be given in hexadecimal. See the "NUMERIC ARGUMENTS" section |
| 286 | in the sg3_utils(8) man page. |
| 287 | .PP |
| 288 | The \fICOUNT\fR, \fISKIP\fR and \fISEEK\fR arguments can take 64 bit |
| 289 | values (i.e. very big numbers). Other values are limited to what can fit in |
| 290 | a signed 32 bit number. |
| 291 | .PP |
| 292 | All informative, warning and error output is sent to stderr so that |
| 293 | dd's output file can be stdout and remain unpolluted. If no options |
| 294 | are given, then the usage message is output and nothing else happens. |
| 295 | .PP |
Douglas Gilbert | e8a28a4 | 2013-10-08 14:24:59 +0000 | [diff] [blame] | 296 | If a device supports xcopy operations then it should set the 3PC |
| 297 | field (3PC stands for Third Party Copy) in its standard INQUIRY response. |
| 298 | This utility will attempt a xcopy operation irrespective of the value |
| 299 | in the 3PC field but if it is zero (cleared) one would expect the |
| 300 | xcopy operation to fail. |
| 301 | .PP |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 302 | The status of the SCSI EXTENDED COPY command can be queried with |
| 303 | .B sg_copy_results(sg3_utils) |
| 304 | .PP |
Douglas Gilbert | 5915919 | 2012-12-22 03:05:14 +0000 | [diff] [blame] | 305 | Currently only block\-to\-block transfers are implemented; \fIIFILE\fR |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 306 | and \fIOFILE\fR must refer to a SCSI block device. |
Douglas Gilbert | 02ec79b | 2013-05-08 13:21:30 +0000 | [diff] [blame] | 307 | .PP |
Douglas Gilbert | 4ea6481 | 2012-11-12 23:48:34 +0000 | [diff] [blame] | 308 | No account is taken of partitions so, for example, /dev/sbc2, /dev/sdc, |
| 309 | /dev/sg2, and /dev/bsg/3:0:0:1 would all refer to the same thing: the |
| 310 | whole logical unit (i.e. the whole disk) starting at LBA 0. So any |
| 311 | partition indication (e.g. /dev/sdc2) is ignored. The user should set |
| 312 | \fISKIP\fR, \fISEEK\fR and \fICOUNT\fR with information obtained |
Douglas Gilbert | 5915919 | 2012-12-22 03:05:14 +0000 | [diff] [blame] | 313 | from a command like 'fdisk \-l \-u /dev/sdc' to account for partitions. |
Douglas Gilbert | 7fcdff5 | 2013-08-19 18:51:18 +0000 | [diff] [blame] | 314 | .PP |
| 315 | XCOPY (LID1) capability has been added to the ddpt utility which is in |
| 316 | a package of the same name. The ddpt utility will run on other |
| 317 | OSes (e.g. FreeBSD and Windows) while sg_xcopy only runs on Linux. Also |
| 318 | ddpt permits the arguments to \fIibs=\fR and \fIibs=\fR to be different. |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 319 | .SH EXAMPLES |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 320 | Copy 2M of data from the start of one device to another: |
| 321 | .PP |
| 322 | # sg_xcopy if=/dev/sdo of=/dev/sdp count=2048 list_id=2 dc=1 |
| 323 | .br |
| 324 | sg_xcopy: if=/dev/sdo skip=0 of=/dev/sdp seek=0 count=1024 |
| 325 | .br |
| 326 | Start of loop, count=1024, bpt=65535, lba_in=0, lba_out=0 |
| 327 | .br |
| 328 | sg_xcopy: 1024 blocks, 1 command |
| 329 | .PP |
| 330 | Check the status of the EXTENDED COPY command: |
| 331 | .PP |
Douglas Gilbert | 5915919 | 2012-12-22 03:05:14 +0000 | [diff] [blame] | 332 | # sg_copy_results \-\-status \-\-list_id=2 /dev/sdp |
Douglas Gilbert | 68167d1 | 2012-09-19 20:30:07 +0000 | [diff] [blame] | 333 | .br |
| 334 | Receive copy results (copy status): |
| 335 | Held data discarded: Yes |
| 336 | Copy manager status: Operation completed without errors |
| 337 | Segments processed: 1 |
| 338 | Transfer count units: 0 |
| 339 | Transfer count: 0 |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 340 | .SH SIGNALS |
| 341 | The signal handling has been borrowed from dd: SIGINT, SIGQUIT and |
| 342 | SIGPIPE output the number of remaining blocks to be transferred and |
| 343 | the records in + out counts; then they have their default action. |
| 344 | SIGUSR1 causes the same information to be output yet the copy continues. |
| 345 | All output caused by signals is sent to stderr. |
| 346 | .SH EXIT STATUS |
| 347 | The exit status of sg_xcopy is 0 when it is successful. Otherwise see |
| 348 | the sg3_utils(8) man page. |
| 349 | .PP |
| 350 | An additional exit status of 90 is generated if the flock flag is given |
| 351 | and some other process holds the advisory exclusive lock. |
| 352 | .SH AUTHORS |
| 353 | Written by Hannes Reinecke and Douglas Gilbert. |
| 354 | .SH "REPORTING BUGS" |
| 355 | Report bugs to <dgilbert at interlog dot com>. |
| 356 | .SH COPYRIGHT |
Douglas Gilbert | 15a477c | 2021-09-04 17:23:12 +0000 | [diff] [blame] | 357 | Copyright \(co 2000\-2021 Hannes Reinecke and Douglas Gilbert |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 358 | .br |
| 359 | This software is distributed under the GPL version 2. There is NO |
| 360 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 361 | .SH "SEE ALSO" |
Douglas Gilbert | 2840077 | 2021-04-15 02:13:40 +0000 | [diff] [blame] | 362 | There is a web page discussing sg_dd at https://sg.danny.cz/sg/sg_dd.html |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 363 | .PP |
| 364 | A POSIX threads version of this utility called |
| 365 | .B sgp_dd |
| 366 | is in the sg3_utils package. Another version from that package is called |
| 367 | .B sgm_dd |
| 368 | and it uses memory mapped IO to speed transfers from sg devices. |
| 369 | .PP |
| 370 | The lmbench package contains |
| 371 | .B lmdd |
| 372 | which is also interesting. For moving data to and from tapes see |
| 373 | .B dt |
Douglas Gilbert | 2840077 | 2021-04-15 02:13:40 +0000 | [diff] [blame] | 374 | which is found at https://www.scsifaq.org/RMiller_Tools/index.html |
Douglas Gilbert | 63918a9 | 2012-09-08 03:20:30 +0000 | [diff] [blame] | 375 | .PP |
| 376 | To change mode parameters that effect a SCSI device's caching and error |
| 377 | recovery see |
| 378 | .B sdparm(sdparm) |
| 379 | .PP |
| 380 | See also |
Douglas Gilbert | e502efd | 2014-03-10 10:17:47 +0000 | [diff] [blame] | 381 | .B dd(1), sg_copy_results(sg3_utils), ddrescue(GNU), ddpt,ddptctl(ddpt) |