1SG_UNMAP(8)                        SG3_UTILS                       SG_UNMAP(8)
2
3
4

NAME

6       sg_unmap - sends a SCSI UNMAP command
7

SYNOPSIS

9       sg_unmap      [--anchor]     [--grpnum=GN]     [--help]     [--in=FILE]
10       [--lba=LBA,LBA...]   [--num=NUM,NUM...]   [--timeout=TO]    [--verbose]
11       [--version] DEVICE
12

DESCRIPTION

14       Send  a  SCSI  UNMAP  command  to  DEVICE  to unmap one or more logical
15       blocks. This command was introduced in  SBC-3  revision  18  under  the
16       broad  heading  of  "logical  block  provisioning" or more specifically
17       "thin provisioning".  Logical blocks may also be unmapped by  the  SCSI
18       WRITE SAME (16 and 32 byte cdbs); see sg_write_same. The unmap capabil‐
19       ity is closely related to the ATA DATA SET MANAGEMENT command with  the
20       "Trim" bit set.
21
22       Logical  blocks  to  be unmapped can be specified in one of two ways to
23       this utility. One way is by supplying the (start) LBAs to the  '--lba='
24       option and the corresponding number(s) to unmap to the '--num=' option.
25       The other way is by putting (start) LBA and  number  pairs  in  a  file
26       whose name is given to the '--in=' option. All values are assumed to be
27       decimal unless prefixed by "0x" (or "0X") or have a  trailing  "h"  (or
28       "H") in which case they are interpreted as hexadecimal.
29
30       When the '--lba=' option is given then the '--num=' option must also be
31       given. If one has a comma separated list as its argument then the other
32       must  have  the  same number of elements in its list. The arguments can
33       use a single space as a separator but need to be in quotes  or  escaped
34       to not be misinterpreted by the shell.
35
36       With  the '--in=FILE' option an even number of values must be found and
37       are interpreted as pairs: the first value in each pair  is  a  starting
38       LBA  and  the second value is the number to unmap from that LBA. Every‐
39       thing from and including a "#" on a line is ignored as are blank lines.
40       Values  may  be  comma,  space  and tab separated or appear on separate
41       lines.
42

OPTIONS

44       Arguments to long options are mandatory for short options as well.
45
46       -a, --anchor
47              sets the 'Anchor' bit in the command (introduced in sbc3r22).
48
49       -g, --grpnum=GN
50              sets the 'Group number' field to GN.  Defaults  to  a  value  of
51              zero.  GN should be a value between 0 and 31.
52
53       -h, --help
54              output the usage message then exit.
55
56       -I, --in=FILE
57              where  FILE is a file name containing pairs of values. The first
58              member of each pair is a starting LBA and the second  member  of
59              the  pair  is  the  number  of  logical blocks to unmap from and
60              including that starting LBA. Values are interpreted  as  decimal
61              unless  indicated  otherwise. This option cannot be present with
62              the '--lba=' option.
63
64       -l, --lba=LBA,LBA...
65              where LBA,LBA... is a string of comma (or space) separated  val‐
66              ues  that  are  interpreted as starting logical block addresses.
67              Each number is interpreted as decimal unless prefixed by '0x' or
68              '0X'  (or  it  has a trailing 'h' or 'H'). An argument that con‐
69              tains any space separators needs  to  be  quoted  (or  otherwise
70              escaped).  When  this  option  is given then the '--num=' option
71              must also be given and they must contain the same number of ele‐
72              ments in their arguments.
73
74       -n, --num=NUM,NUM...
75              where  NUM,NUM... is a string of comma (or space) separated val‐
76              ues that are interpreted as a number of logical blocks to unmap.
77              Each number is interpreted as decimal unless prefixed by '0x' or
78              '0X' (or it has a trailing 'h' or 'H'). Note that  0  blocks  is
79              acceptable. An argument that contains any space separators needs
80              to be quoted (or otherwise escaped).  When this option is  given
81              then  the  '--lba=' option must also be given and they must con‐
82              tain the same number of elements in their arguments.
83
84       -t, --timeout=TO
85              where TO is a timeout value (in seconds) for the UNMAP  command.
86              The default value is 60 seconds.
87
88       -v, --verbose
89              increase the level of verbosity, (i.e. debug output).
90
91       -V, --version
92              print the version string and then exit.
93

NOTES

95       Some  limits: an LBA can be up to 64 bits, a NUM up to 32 bits (imposed
96       by structure of UNMAP SCSI command parameter data). The NUM is  further
97       constrained  by  the  MAXIMUM UNMAP LBA COUNT field in the BLOCK LIMITS
98       VPD page (0xb0). The maximum number of LBA,NUM pairs is limited to  128
99       by  this  utility  and  may be further constrained by the MAXIMUM UNMAP
100       BLOCK DESCRIPTOR COUNT field in the BLOCK LIMITS VPD page.
101
102       Since it is unclear how long the UNMAP command will take to  execute  a
103       '--timeout=" option has been provided. The default timeout period is 60
104       seconds. If all the logical blocks on a  logical  unit  (e.g.   a  disk
105       drive)  are  to  be unmapped then the FORMAT UNIT SCSI command (see the
106       sg_format utility) may be considered as an alternative.
107
108       Support for thin provisioning is  indicated  by  the  TPE  bit  in  the
109       response  to  the  SCSI  READ CAPACITY (16) command (see the sg_readcap
110       utility).
111
112       In  the  examples  directory  of  the  sg3_utils  package  there  is  a
113       sg_unmap_example.txt file that shows the format that the '--in=' option
114       accepts.
115

EXIT STATUS

117       The exit status of sg_unmap is 0 when it is successful.  Otherwise  see
118       the sg3_utils(8) man page.
119

AUTHORS

121       Written by Douglas Gilbert.
122

REPORTING BUGS

124       Report bugs to <dgilbert at interlog dot com>.
125
127       Copyright © 2009-2010 Douglas Gilbert
128       This  software is distributed under a FreeBSD license. There is NO war‐
129       ranty; not even for MERCHANTABILITY or FITNESS FOR  A  PARTICULAR  PUR‐
130       POSE.
131

SEE ALSO

133       sg_format,sg_get_lba_status,sg_readcap,sg_write_same(sg3_utils)
134
135
136
137sg3_utils-1.29                    March 2010                       SG_UNMAP(8)
Impressum