OS Manuals

/usr/bin/sg_unmap

SCSI utilities for Linux, Unix and Windows

From sg3-utils 1.49-r3 (enterprise-packages), captured 2026-11-08 by running sg_unmap --help (exit 0). permalink

Usage: sg_unmap [--all=ST,RN[,LA]] [--anchor] [--dry-run] [--force]
                [--grpnum=GN] [--help] [--in=FILE] [--lba=LBA,LBA...]
                [--num=NUM,NUM...] [--timeout=TO] [--verbose] [--version]
                DEVICE
  where:
    --all=ST,RN[,LA]|-A ST,RN[,LA]    start unmaps at LBA ST, RN blocks
                         per unmap until the end of disk, or until
                         and including LBA LA (last)
    --anchor|-a          set anchor field in cdb
    --dry-run|-d         prepare but skip UNMAP call(s)
    --force|-f           don't ask for confirmation before zapping media
    --grpnum=GN|-g GN    GN is group number field (def: 0)
    --help|-h            print out usage message
    --in=FILE|-I FILE    read LBA, NUM pairs from FILE (if FILE is '-'
                         then stdin is read)
    --lba=LBA,LBA...|-l LBA,LBA...    LBA is the logical block address
                                      to start NUM unmaps
    --num=NUM,NUM...|-n NUM,NUM...    NUM is number of logical blocks to
                                      unmap starting at corresponding LBA
    --timeout=TO|-t TO    command timeout (unit: seconds) (def: 60)
    --verbose|-v         increase verbosity
    --version|-V         print version string and exit

Perform a SCSI UNMAP command. LBA, NUM and the values in FILE are assumed
to be decimal. Use '0x' prefix or 'h' suffix for hex values.
Example to unmap LBA 0x12345:
    sg_unmap --lba=0x12345 --num=1 /dev/sdb
Example to unmap starting at LBA 0x12345, 256 blocks per command:
    sg_unmap --all=0x12345,256 /dev/sg2
until the end if /dev/sg2 (assumed to be a storage device)

WARNING: This utility will destroy data on DEVICE in the given range(s)
that will be unmapped. Unmap is also known as 'trim' and is irreversible.
Options (12)
OptionDescriptionSource
--all STstart unmaps at LBA ST, RN blocks per unmap until the end of disk, or until and including LBA LA (last)help
--grpnum, -g GN|-gsets the 'Group number' field to GN.help + man
--in, -I FILE|-Iread LBA, NUM pairs from FILE (if FILE is '-' then stdin is read)help + man
--lba, -l LBALBA is the logical block address to start NUM unmapshelp + man
--num, -n NUMNUM is number of logical blocks to unmap starting at corresponding LBAhelp + man
--timeout, -t TO|-twhere TO is a timeout value (in seconds) for the UNMAP command.help + man
-a, --anchorsets the 'Anchor' bit in the command (introduced in sbc3r22). (in the manual page but not in --help)man
-d, --dry-runperform all the preparation, including opening DEVICE plus sending a 'standard' SCSI INQUIRY command (and optionally a READ CAPACITY), but exit before performing any SCSI UNMAP commands. (in the manual page but not in --help)man
-f, --forcebypass the 15 second warning period that occurs before any UNMAP commands are sent. (in the manual page but not in --help)man
-h, --helpoutput the usage message then exit. (in the manual page but not in --help)man
-v, --verboseincrease the level of verbosity, (i.e. debug output). (in the manual page but not in --help)man
-V, --versionprint the version string and then exit. (in the manual page but not in --help)man
Exit status (1) from the manual page
0it is successful

Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.