sg_read_block_limits asks a tape drive for its minimum and maximum block size before a job runs. You will finish with those numbers, a read-only query, and a result that is easy to verify. The examples use sg_read_block_limits from the installed sg3-utils package, version 1.46-3ubuntu4. The program itself reports sg3_utils version 1.08 20180219 on this system.
Allow about ten minutes. You need a Linux shell, the sg3-utils package and the correct tape-device path. Reading the device's limits is not a data transfer, but it does send a SCSI command to hardware. Do this before a tape job, not while another process is actively controlling the drive.
Start with read-only local checks. They need no elevated privileges and do not contact a drive:
$ command -v sg_read_block_limits
/usr/bin/sg_read_block_limits
$ dpkg-query -W -f='${Package} ${Version}\n' sg3-utils
sg3-utils 1.46-3ubuntu4
$ sg_read_block_limits --version
version: 1.08 20180219
The package and utility versions can differ in how they are labelled. The option contract that matters here is the one exposed by this installed binary: one required DEVICE, with optional help, hexadecimal, raw, read-only, verbose and version switches.
Checkpoint: If command -v finds a different copy, stop and inspect its version before relying on examples from another installation.
Use the device node assigned to the drive you intend to query. A typical non-rewinding or rewinding tape node is under /dev/st, but the name is host-specific. Inspect the available nodes without opening one:
$ ls -l /dev/st* /dev/nst* 2>/dev/null
# output varies by host
Replace /dev/st0 below with the exact path for your drive. Do not guess from the order of devices if the host has multiple tape drives. Check your inventory, device rules or the storage team's naming convention first. An incorrect path can query the wrong drive or fail with a permissions error.
Opening the device is normally restricted. If your account cannot access it, first inspect ownership and groups:
$ ls -l /dev/st0
crw-rw---- 1 root tape 9, 0 ... /dev/st0
$ id
Join the approved device-access group, or use sudo according to your site's policy. The command itself does not need root as a rule; access to the device node is the deciding factor.
The manual's ordinary invocation is sg_read_block_limits DEVICE. Its default is to open the device read-write, even though the SCSI operation asks for block limits. Use --readonly explicitly when you are checking a drive:
$ sg_read_block_limits --readonly /dev/st0
Read Block Limits results:
Minimum block size: 1 byte(s)
Maximum block size: 16777215 byte(s), 16383 KB, 15 MB
The values above are typical example output from the manpage. Your drive may report different limits. The minimum is the smallest block size the device advertises for this command; the maximum is the largest. The displayed KB and MB figures are additional readable forms of the maximum, not extra limits.
If the drive requires privileges, prefix the same command with sudo:
$ sudo sg_read_block_limits --readonly /dev/st0
Safety boundary: --readonly controls how the device node is opened. It does not turn a missing or incorrect device path into a safe one, and it does not guarantee that another tape application will welcome a query at that moment. Confirm drive ownership before using sudo.
A successful command exits with status zero. Capture it immediately after the query:
$ sg_read_block_limits --readonly /dev/st0
Read Block Limits results:
Minimum block size: 1 byte(s)
Maximum block size: 16777215 byte(s), 16383 KB, 15 MB
$ printf 'exit status: %s\n' "$?"
exit status: 0
Do not treat text that looks plausible as success if the shell reports a non-zero status. A failed SCSI command can leave you without a trustworthy limit. The manpage directs other exit-status details to sg3_utils(8), so preserve the diagnostic text when you need to escalate a failure.
Common first checks are the device path, permissions and whether the drive is present and available. Re-run ls -l and check the host's tape or backup monitor before changing anything. Do not unload media, reset a drive or stop a service merely because this read failed.
For a human-readable result, leave the options at their defaults apart from --readonly. Add --verbose when you need extra debugging information:
$ sg_read_block_limits --readonly --verbose /dev/st0
# decoded result plus implementation-specific diagnostic output
Verbose output is for troubleshooting, not for parsing. Its exact detail depends on the device and utility build. If you need the response in hexadecimal, use --hex:
$ sg_read_block_limits --readonly --hex /dev/st0
# hexadecimal response; exact bytes depend on the drive
Hex output is useful when comparing a device response with a SCSI specification or a vendor report. It is not the convenient form for a script that needs the decoded minimum and maximum.
--raw writes the response as binary to standard output. Do not send it to the terminal. Redirect it to a new file only when another tool or a support request specifically needs the binary response:
$ sg_read_block_limits --readonly --raw /dev/st0 > block-limits.bin
$ wc -c block-limits.bin
# a small, device-dependent byte count
Shell redirection truncates an existing destination before the command runs. Choose a new filename, or make a deliberate backup first. If the query fails, keep the diagnostic on standard error and remove the incomplete file only after checking that it is not needed for investigation. Do not publish or email raw device responses without reviewing them for operational information.
The command reports the response to SCSI READ BLOCK LIMITS. It does not configure the drive, change a tape format, alter a block size, write tape data or update persistent Linux settings. There is therefore no undo command for the read-only examples. The raw-output example creates a local file; remove that file later with your normal evidence-retention process if it is no longer required.
Do not use the reported maximum as an instruction to reconfigure backup software automatically. A tape application's format, drive firmware, media and transport rules can impose narrower requirements. Use these values as one verified input to the configuration you are reviewing.
sg_read_block_limits binary and package version./dev/st0 was correct.--readonly and checked for exit status zero.