Tape Hardware Compression and Blocking Size

CommunityEnterprise

You should be able to verify the tape compression status with sysfs on Linux.

cat /sys/class/scsi_tape/nst0/default_compression

You can turn it on by using (on Linux, as root):

mt -f /dev/nst0 defcompression 1

and of course, if you use a zero instead of the one at the end, you will turn it off.

You can use tapeinfo to get quite a bit of information about your tape drive. This program is called using the SCSI control device. On Linux for tape drive /dev/nst0, this is usually /dev/sg0, while on FreeBSD for /dev/nsa0, the control device is often /dev/pass2. For example on my LTO-9 drive (/dev/nst0), I get the following:

tapeinfo -f /dev/sg46

Product Type: Tape Drive
Vendor ID: 'IBM     '
Product ID: 'ULTRIUM-TD9     '
Revision: 'PA60'
Attached Changer API: No
SerialNumber: '10510059BB'
TapeAlert[35]: Undefined.
MinBlock: 1
MaxBlock: 8388608
SCSI ID: 0
SCSI LUN: 0
Ready: yes
BufferedMode: yes
Medium Type: 0x98
Density Code: 0x60
BlockSize: 0
DataCompEnabled: yes
DataCompCapable: yes
DataDeCompEnabled: yes
CompType: 0xff
DeCompType: 0xff
BOP: yes
Block Position: 0
Partition 0 Remaining Kbytes: -1
Partition 0 Size in Kbytes: -1
ActivePartition: 0
EarlyWarningSize: 0
NumPartitions: 0
MaxPartitions: 3

where the DataCompEnabled: yes means that tape hardware compression is turned on. You can turn it on and off (yes|no) by using the mt commands given above.

Also, this output will tell you if the BlockSize is non-zero and hence set for a particular block size. If this is the case, then the tape device must be configured with a “fixed block size”, which means to set the Minimum block size and the Maximum block size to the same value, the “non-zero” value reported by tapeinfo. Otherwise, if it is reported as zero, Bacula will normally attempt to write blocks of 64,512 bytes, except the last block of the job which will generally be shorter. It is possible to try setting the default block size to zero using the mt -f /dev/nst0 defblksize 0 command as shown above. On FreeBSD, this would be something like: mt -f /dev/nsa0 blocksize 0.

On some operating systems with some tape drives, the amount of data that can be written to the tape and whether or not compression is enabled is determined by the density usually the mt -f /dev/nst0 setdensity xxx command. Often mt -f /dev/nst0 status will print out the current density code that is used with the drive. Most systems, but unfortunately not all, set the density to the maximum by default. On some systems, you can also get a list of all available density codes with: mt -f /dev/nst0 densities or a similar mt command. Note, for DLT and SDLT devices, no-compression versus compression is very often controlled by the density code. On FreeBSD systems, the compression mode is set using mt -f /dev/nsa0 comp xxx where xxx is the mode you want. In general, see man mt for the options available on your system.

Note, some of the above mt commands may not be persistent depending on your system configuration. That is they may be reset if a program other than Bacula uses the drive or, as is frequently the case, on reboot of your system.

If your tape drive requires fixed block sizes (very unusual), you can use the following records:

Minimum Block Size = nnn
Maximum Block Size = nnn

in your Storage daemon’s Device resource to force Bacula to write fixed size blocks (where you sent nnn to be the same for both of the above records). This should be done only if your drive does not support variable block sizes, or you have some other strong reasons for using fixed block sizes. As mentioned above, a small fixed block size of 512 or 1024 bytes will be very inefficient. Try to set any fixed block size to something like 64,512 bytes or larger if your drive will support it.

Go back to: Troubleshooting.