1SG_UNMAP(8) SG3_UTILS SG_UNMAP(8)
2
3
4
6 sg_unmap - sends a SCSI UNMAP command
7
9 sg_unmap [--grpnum=GN] [--help] [--in=FILE] [--lba=LBA,LBA...]
10 [--num=NUM,NUM...] [--timeout=TO] [--verbose] [--version] DEVICE
11
13 Send a SCSI UNMAP command to DEVICE to unmap one or more logical
14 blocks. Introduced in SBC-3 revision 18 under the broad heading of
15 "logical block provisioning" or more specifically "thin provisioning".
16 Logical blocks may also be unmapped by the SCSI WRITE SAME (16 and 32
17 byte cdbs); see sg_write_same. The unmap capability is closely related
18 to the ATA DATA SET MANAGEMENT command with the "Trim" bit set.
19
20 Logical blocks to be unmapped can be specified in one of two ways to
21 this utility. One way is by supplying the (start) LBAs to the '--lba='
22 option and the corresponding number(s) to unmap to the '--num=' option.
23 The other way is by putting (start) LBA and number pairs in a file
24 whose name is given to the '--in=' option. All values are assumed to be
25 decimal unless prefixed by "0x" (or "0X") or have a trailing "h" (or
26 "H") in which case they are interpreted as hexadecimal.
27
28 When the '--lba=' option is given then the '--num=' option must also be
29 given. If one has a comma separated list as its argument then the other
30 must have the same number of elements in its list. The arguments can
31 use a single space as a separator but need to be in quotes or escaped
32 to not be misinterpreted by the shell.
33
34 With the '--in=FILE' option an even number of values must be found and
35 are interpreted as pairs: the first value in each pair is a starting
36 LBA and the second value is the number to unmap from that LBA. Every‐
37 thing from and including a "#" on a line is ignored as are blank lines.
38 Values may be comma, space and tab separated or appear on separate
39 lines.
40
42 Arguments to long options are mandatory for short options as well.
43
44 -g, --grpnum=GN
45 sets the 'Group number' field to GN. Defaults to a value of
46 zero. GN should be a value between 0 and 31.
47
48 -h, --help
49 output the usage message then exit.
50
51 -I, --in=FILE
52 where FILE is a file name containing pairs of values. The first
53 member of each pair is a starting LBA and the second member of
54 the pair is the number of logical blocks to unmap from and
55 including that starting LBA. Values are interpreted as decimal
56 unless indicated otherwise. This option cannot be present with
57 the '--lba=' option.
58
59 -l, --lba=LBA,LBA...
60 where LBA,LBA... is a string of comma (or space) separated val‐
61 ues that are interpreted as starting logical block addresses.
62 Each number is interpreted as decimal unless prefixed by '0x' or
63 '0X' (or it has a trailing 'h' or 'H'). An argument that con‐
64 tains any space separators needs to be quoted (or otherwise
65 escaped). When this option is given then the '--num=' option
66 must also be given and they must contain the same number of ele‐
67 ments in their arguments.
68
69 -n, --num=NUM,NUM...
70 where NUM,NUM... is a string of comma (or space) separated val‐
71 ues that are interpreted as a number of logical blocks to unmap.
72 Each number is interpreted as decimal unless prefixed by '0x' or
73 '0X' (or it has a trailing 'h' or 'H'). Note that 0 blocks is
74 acceptable. An argument that contains any space separators needs
75 to be quoted (or otherwise escaped). When this option is given
76 then the '--lba=' option must also be given and they must con‐
77 tain the same number of elements in their arguments.
78
79 -t, --timeout=TO
80 where TO is a timeout value (in seconds) for the UNMAP command.
81 The default value is 60 seconds.
82
83 -v, --verbose
84 increase the level of verbosity, (i.e. debug output).
85
86 -V, --version
87 print the version string and then exit.
88
90 Some limits: an LBA can be up to 64 bits, a NUM up to 32 bits (imposed
91 by structure of UNMAP SCSI command parameter data). The NUM is further
92 constrained by the MAXIMUM UNMAP LBA COUNT field in the BLOCK LIMITS
93 VPD page (0xb0). The maximum number of LBA,NUM pairs is limited to 128
94 by this utility and may be further constrained by the MAXIMUM UNMAP
95 BLOCK DESCRIPTOR COUNT field in the BLOCK LIMITS VPD page.
96
97 Since it is unclear how long the UNMAP command will take to execute a
98 '--timeout=" option has been provided. The default timeout period is 60
99 seconds. If all the logical blocks on a logical unit (e.g. a disk
100 drive) are to be unmapped then the FORMAT UNIT SCSI command (see the
101 sg_format utility) may be considered as an alternative.
102
103 Support for thin provisioning is indicated by the TPE bit in the
104 response to the SCSI READ CAPACITY (16) command (see the sg_readcap
105 utility).
106
107 In the examples directory of the sg3_utils package there is a
108 sg_unmap_example.txt file that shows the format that the '--in=' option
109 accepts.
110
112 The exit status of sg_unmap is 0 when it is successful. Otherwise see
113 the sg3_utils(8) man page.
114
116 Written by Douglas Gilbert.
117
119 Report bugs to <dgilbert at interlog dot com>.
120
122 Copyright © 2009 Douglas Gilbert
123 This software is distributed under a FreeBSD license. There is NO war‐
124 ranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PUR‐
125 POSE.
126
128 sg_format,sg_readcap,sg_write_same(sg3_utils)
129
130
131
132sg3_utils-1.28 June 2009 SG_UNMAP(8)