How can I determine how much space is remaining on an LTO tape?

If I seek to the end and check the status, I can see I am on file number 17, but what I do not know is how large each file was.

$ mt -f /dev/nst1 eod
$ mt -f /dev/nst1 status
SCSI 2 tape drive:
File number=17, block number=0, partition=0.
Tape block size 0 bytes. Density code 0x44 (LTO-3).
Soft error count since last status=0
General status bits on (81010000):

Short of reading the entire strip, how can I determine the used / free capacity of the tape?

  • 1
    Reading all of the data wouldn't help you much in determining the remaining capacity. Capacity varies depending on wear on the tape heads and quality of the tape. If you do read all the data you'd actually get a better estimate by measuring how much time it took to read rather than counting the number of bytes you read.
    – kasperd
    Jul 15 '17 at 16:13
  • 1
    And then there's the compression and fake capacity issue...
    – Overmind
    Jan 16 '18 at 13:55
  • @Overmind Compression is optional, but yes if it is turned on you will get an even less usable result by simply counting the bytes you read from the tape. Even in that case my advice still stands. Reading the entire tape and measuring how much time it took does give a reasonable estimate of how much of the tape capacity has been used. I don't know what you mean by fake capacity.
    – kasperd
    Feb 13 '18 at 23:19
  • I mean the actual declared-by-the-manufacturer capacity of the tape is fake (usually twice the actual one). They say a specific capacity (i.e. 1.6TB at 2:1 compression ratio, which practically means that the tape is 0.8TB). It's like saying my 10TB WD gold HDD is 20TB because I archived my data there at 2:1 compression ratio.
    – Overmind
    Feb 14 '18 at 6:17

You can find the remaining tape capacity in the SCSI logs, along with many other interesting tidbits such as compression ratio, read/write failures, drive/tape history, etc.

sg_logs -a /dev/nst1

This utility is available in distro packages commonly named sg3-utils or sg3_utils.

You're looking for lines such as:

  • Main partition remaining capacity (in MiB)
  • Megabytes written to tape (subtract from uncompressed capacity)
  • Data bytes written to media by WRITE commands (subtract from uncompressed capacity)

Failing that, you can try vendor-specific tools. For example HP has HPE Library & Tape Tools, which works on all HP-compatible* drives. Buried in its menus you can find the ability to create and view a report of a drive which offers all the info found in sg_logs and more.

And failing all that, you can just write incompressible data until the end of tape and do the maths on the blocks written to figure what was remaining (goes without saying this is a bit nasty):

dd if=/dev/urandom of=/dev/nst1 bs=1M status=progress iflag=fullblock


openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt < /dev/zero | dd of=/dev/nst1 bs=1M status=progress iflag=fullblock

I've used nst1 throughout this answer as that is the device in the original question, update as necessary.


First of all: this is not going to be easy.

There is a chip in the tape cartridge that offers a wide variety of information. That chip is called MAM (media auxiliary memory). The information can be read using SCSI command "READ ATTRIBUTE" on the tape drive while the tape is loaded. One of the attributes is "REMAINING CAPACITY IN PARTITION". This contains the amount of bytes that can be written to the current tape partition. Which leads to the question: what is a tape partition? Recent versions of LTO (LTO 5 and newer) tapes can be partitioned (LTFS uses two partitions).

If your tape was partitioned, each of your partitions will have an amount of free space and you will need to loop over all partitions to get each partitions free space information.

If you want to know more about MAM, take a look at IBM's LTO-8 SCSI Reference that explains this in detail (section 6.5 starting on page 355 contains the interesting stuff). If you need a starting point on how to implement this, maybe you should take a look at maminfo or this issue in sg3_utils issue tracker.

I'm not sure this information is updated immediately after a write to the tape. Maybe it is only update on unmount which would make retrieving accurate information even harder. I'm also not sure how this behaves when you overwrite the tape. You'll probably have to figure this out on your own.


I am not sure but maybe i can offer you to use ibm's software ITDT , it has a lot of abilities to do on tape libraries and lto tapes , maybe you can have a look around that software , it has such ability as Retrieve and display cartridge usage and health information.


Here is one more software solution: https://github.com/Kevin-Nakamoto/LTO-CM-Read

This is an open-source Linux bash script which allows us to read MAM information via SCSI command. This is a kind of software wrapper for "READ ATTRIBUTE" command that Andreas has already suggested in the previous post. All you have to do is to install sg3-utils or sg3_utils, and then run the script. You will see "Remaining Capacity In Partition" as well as "Maximum Capacity In Partition" as a result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.