Tape Hardware Compression and Blocking Size
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):
become super user
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 even
if it is not an autochanger. 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 DDS-4 drive
(/dev/nst0), I get the following:
tapeinfo -f /dev/sg0
Product Type: Tape Drive
Vendor ID: ’HP ’
Product ID: ’C5713A ’
Revision: ’H107’
Attached Changer: No
MinBlock:1
MaxBlock:16777215
SCSI ID: 5
SCSI LUN: 0
Ready: yes
BufferedMode: yes
Medium Type: Not Loaded
Density Code: 0x26
BlockSize: 0
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.
Bacula is not likely to work in such a situation because it will normally attempt to
write blocks of 64,512 bytes, except the last block of the job which will generally be
shorter. The first thing to try is 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.
Also, note that the Medium Type field of the output of tapeinfo
reports
Not Loaded, which is not correct. As a consequence, you should ignore that field as
well as the Attached Changer field.
To recover files from tapes written in fixed block mode, click here.
See also
Go back to:
Go to:
Go back to the Troubleshooting chapter.
Go back to the Tape Autochanger Setup chapter.
Go back to the main Advanced Features Usage page.