Nov 262013
 

This article was written some months go, but only published today.

I recently acquired a new tape auto-changer / library. I have already run some simple tests on the library, and all seems well. I already have an existing Bacula installation and my plan is to add this new auto-changer into that.

The Devices

The following is a list of the devices associated with my auto-changer. The output has been trimmed to exclude other devices.

$ sudo camcontrol devlist
Password:
<QUANTUM DLT8000 0250>             at scbus12 target 4 lun 0 (pass13,sa1)
<OVERLAND LXB 0524>                at scbus12 target 6 lun 0 (ch1,pass14)

Looking at the Bacula documentation for auto-changers, I used that as the basis for my old DEC auto-changer. Therefore, I’m just going to copy & paste that for my Overland auto-changer.

The bacula-dir.conf changes

These are the entries in my bacula-dir.conf:

# Definition of DEC DLT 7000 tape storage device
Storage {
  Name       = DigitalTapeLibrary
  Address    = kraken.example.org
  SDPort     = 9103
  Password   = "NotMyPassword"

  AutoChanger = Yes

  Device     = DTL01
  Media Type = DLT
}


# Definition of Overland DLT 8000 tape storage device
Storage {
  Name       = OverlandTapeLibrary
  Address    = kraken.unixathome.org
  SDPort     = 9103
  Password   = "NotMyPassword"

  AutoChanger = Yes

  Device     = DTL02
  Media Type = DLT
}

NOTE: the same Password entry is used for both Storage resources because they reside within the same bacula-sd. That is, the password is not for the Storage resource itself. It is for the bacula-sd in question. It corresponds to this entry in bacula-sd.conf:

#
# List Directors who are permitted to contact Storage daemon
#
Director {
  Name = my-dir
  Password = "NotMyPassword"
}

The bacula-sd.conf changes

These are the entries in my bacula-sd.conf file. Note that both tape libraries are connected to the same bacula-sd.

Autochanger {
  Name            = "OverlandTapeLibrary"
  Device          = "DTL02"
  Description     = "Overland DLT MinilibraryXpress (model LXM8115)."
  Changer Device  = /dev/pass14
  Changer Command = "/usr/local/sbin/mtx-changer %c %o %S %a %d"
}

Device {
  Name                    = "DTL02"
  Description             = "Overland DLT MinilibraryXpress (model LXM8115) - first drive"
  Media Type              = DLT
  Archive Device          = /dev/nsa1

  Autochanger             = yes
  Drive Index             = 0

  Offline On Unmount      = no
  Hardware End of Medium  = no
  BSF at EOM              = yes
  Backward Space Record   = no
  Fast Forward Space File = yes
  TWO EOF                 = yes

  Spool Directory         = /home/bacula/spooling-lib
  Maximum Spool Size      = 11759496889
  Maximum Job Spool Size  = 11759496889    # 10GB
}

I wonder about line 25. Should that line be different for each auto-changer?

Invoking the changes and contacting the SD

After issuing a reload command in bconsole (which gets baucla-dir to reload its configuration) and restarting bacula-sd, I tried the following in bconsole:

*st st
The defined Storage resources are:
     1: File
     2: MegaFile
     3: FileRemote
     4: FileRemoteTLS
     5: DLT
     6: DigitalTapeLibrary
     7: OverlandTapeLibrary
     8: DLTRemote
     9: DLTRemoteTLS
Select Storage resource (1-9): 7
Connecting to Storage daemon OverlandTapeLibrary at kraken.unixathome.org:9103

kraken-sd Version: 5.2.6 (21 February 2012) amd64-portbld-freebsd8.2 freebsd 8.2-STABLE
Daemon started 07-Dec-12 19:57. Jobs: run=0, running=0.
 Heap: heap=0 smbytes=30,497 max_bytes=124,202 bufs=107 max_bufs=109
 Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0

Running Jobs:
No Jobs running.
====

Jobs waiting to reserve a drive:
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name
===================================================================
113580  Incr         28    48.18 M  OK       07-Dec-12 09:44 CopyToTape-Inc
113582  Incr        310    4.384 M  OK       07-Dec-12 09:44 CopyToTape-Inc
113545  Incr        231    35.94 M  OK       07-Dec-12 09:44 CopyToTape-Inc
113586  Full          1    1.945 G  OK       07-Dec-12 09:56 CopyToTape-Full
113585  Full          1    3.252 G  OK       07-Dec-12 10:11 CopyToTape-Full
113589  Incr         67    467.1 K  OK       07-Dec-12 10:12 nyi_maildir
113590  Incr         47    19.92 M  OK       07-Dec-12 12:02 nyi_maildir
113591  Incr         87    13.91 M  OK       07-Dec-12 14:01 nyi_maildir
113592  Incr         35    9.344 M  OK       07-Dec-12 16:04 nyi_maildir
113593  Incr         47    9.211 M  OK       07-Dec-12 18:03 nyi_maildir
====

Device status:
Autochanger "DigitalTapeLibrary" with devices:
   "DTL01" (/dev/nsa0)
Autochanger "OverlandTapeLibrary" with devices:
   "DTL02" (/dev/nsa1)
Device "MegaFile" (/storage/compressed/bacula/volumes) is not open.
Device "DTL01" (/dev/nsa0) open but no Bacula volume is currently mounted.
    Slot 5 is loaded in drive 0.
    Total Bytes Read=0 Blocks Read=0 Bytes/block=0
    Positioned at File=0 Block=0
Device "DTL02" (/dev/nsa1) open but no Bacula volume is currently mounted.
    Slot 2 is loaded in drive 0.
    Total Bytes Read=0 Blocks Read=0 Bytes/block=0
    Positioned at File=0 Block=0
====

Used Volume status:
====

====

*

NOTES:

  1. Line 9 is the new tape library (autochanger) entry I just added to bacula-dir.conf.
  2. Lines 45-46 represent the autochanger resource added to bacula-sd.conf
  3. Lines 52-53 represent the DLT02 device added to bacula-sd.conf

OK, so now I know Bacula knows about the new tape library.

Using the auto-changer from bconsole

First step, let’s try updating the slots. That’s a very good command for testing your configuration.

*update slots storage=OverlandTapeLibrary
Connecting to Storage daemon OverlandTapeLibrary at kraken.unixathome.org:9103 ...
Connecting to Storage daemon OverlandTapeLibrary at kraken.unixathome.org:9103 ...
3306 Issuing autochanger "slots" command.
Device "DTL02" has 15 slots.
Connecting to Storage daemon OverlandTapeLibrary at kraken.unixathome.org:9103 ...
3306 Issuing autochanger "list" command.
Catalog record for Volume "ETU145" updated to reference slot 1.
Catalog record for Volume "ETU140" updated to reference slot 2.
*

Success! Now, let’s try mounting a tape.

*mount storage=OverlandTapeLibrary
Enter autochanger slot: 1
3307 Issuing autochanger "unload slot 2, drive 0" command.
3304 Issuing autochanger "load slot 1, drive 0" command.
3305 Autochanger "load slot 1, drive 0", status is OK.
block.c:275 Volume data error at 0:0! Wanted ID: "BB02", got "TS-S". Buffer discarded.
3902 Cannot mount Volume on Storage Device ""DTL02" (/dev/nsa1)" because:
Requested Volume "" on "DTL02" (/dev/nsa1) is not a Bacula labeled Volume, because: ERR=block.c:275 Volume data error at 0:0! Wanted ID: "BB02", got "TS-S". Buffer discarded.
3905 Device ""DTL02" (/dev/nsa1)" open but no Bacula volume is mounted.
If this is not a blank tape, try unmounting and remounting the Volume.
*

OK, I know what happened here. This is not a Bacula tape. It was, but is no longer. I overwrote it. The barcode label is ETU145. That Volume still exists in the Catalog. Thus, I must delete the Volume and then issue a label command.

*delete volume=ETU145

This command will delete volume ETU145
and all Jobs saved on that volume from the Catalog
Are you sure you want to delete Volume "ETU145"? (yes/no): yes
*label
The defined Storage resources are:
     1: File
     2: MegaFile
     3: FileRemote
     4: FileRemoteTLS
     5: DLT
     6: DigitalTapeLibrary
     7: OverlandTapeLibrary
     8: DLTRemote
     9: DLTRemoteTLS
Select Storage resource (1-9): 7
Enter new Volume name: ETU145
Enter slot (0 or Enter for none):
Defined Pools:
     1: FullFileNoNextPool
     2: Default
     3: FullFile
     4: DiffFile
     5: IncrFile
     6: IncrFileNoNextPool
     7: FullsFile
     8: FullBackupsFile
     9: FilePool
    10: Scratch
    11: MegaFilePool
    12: Fulls
    13: Differentials
    14: Incrementals
Select the Pool (1-14): 10
Connecting to Storage daemon OverlandTapeLibrary at kraken.unixathome.org:9103 ...
Sending label command for Volume "ETU145" Slot 0 ...
No slot defined in catalog (slot=0) for Volume "" on "DTL02" (/dev/nsa1).
Cartridge change or "update slots" may be required.
block.c:275 Volume data error at 0:0! Wanted ID: "BB02", got "TS-S". Buffer discarded.
3000 OK label. VolBytes=64512 DVD=0 Volume="ETU145" Device="DTL02" (/dev/nsa1)
Catalog record for Volume "ETU145", Slot 0  successfully created.
Requesting to mount DTL02 ...
3001 Device ""DTL02" (/dev/nsa1)" is mounted with Volume "ETU145"
*

There. Done.

Next. Let’s umount that tape, and load in the other tape.

*umount storage=OverlandTapeLibrary
3307 Issuing autochanger "unload slot 1, drive 0" command.
3002 Device ""DTL02" (/dev/nsa1)" unmounted.
*mount storage=OverlandTapeLibrary
Enter autochanger slot: 2
3301 Issuing autochanger "loaded? drive 0" command.
3302 Autochanger "loaded? drive 0", result: nothing loaded.
3304 Issuing autochanger "load slot 2, drive 0" command.
3305 Autochanger "load slot 2, drive 0", status is OK.
3902 Cannot mount Volume on Storage Device ""DTL02" (/dev/nsa1)" because:
Requested Volume "" on "DTL02" (/dev/nsa1) is not a Bacula labeled Volume, because: ERR=block.c:1014 Read zero bytes at 0:0 on device "DTL02" (/dev/nsa1).
3905 Device ""DTL02" (/dev/nsa1)" open but no Bacula volume is mounted.
If this is not a blank tape, try unmounting and remounting the Volume.
*delete volume=ETU140

This command will delete volume ETU140
and all Jobs saved on that volume from the Catalog
Are you sure you want to delete Volume "ETU140"? (yes/no): yes
*label storage=OverlandTapeLibrary volume=ETU140
Enter slot (0 or Enter for none):
Defined Pools:
     1: FullFileNoNextPool
     2: Default
     3: FullFile
     4: DiffFile
     5: IncrFile
     6: IncrFileNoNextPool
     7: FullsFile
     8: FullBackupsFile
     9: FilePool
    10: MegaFilePool
    11: Fulls
    12: Differentials
    13: Incrementals
    14: Scratch
Select the Pool (1-14): 14
Connecting to Storage daemon OverlandTapeLibrary at kraken.unixathome.org:9103 ...
Sending label command for Volume "ETU140" Slot 0 ...
No slot defined in catalog (slot=0) for Volume "" on "DTL02" (/dev/nsa1).
Cartridge change or "update slots" may be required.
3000 OK label. VolBytes=64512 DVD=0 Volume="ETU140" Device="DTL02" (/dev/nsa1)
Catalog record for Volume "ETU140", Slot 0  successfully created.
Requesting to mount DTL02 ...
3001 Device ""DTL02" (/dev/nsa1)" is mounted with Volume "ETU140"
*

As you can see, I had to label the other tape too…. Next: we run some btape tests.

The btape test

btape is a Bacula utility for testing your tape drive. In order to run it, I’ve stopped bacula-sd. I will now manually load a tape into the drive and run btape.

$ /usr/local/sbin/mtx-changer /dev/pass14 load 1 /dev/sa1 0 0
Loading media from Storage Element 1 into drive 0...done
$ btape -c /usr/local/etc/bacula-sd.conf /dev/nsa1
Tape block granularity is 1024 bytes.
btape: butil.c:290 Using device: "/dev/nsa1" for writing.
07-Dec 20:43 btape JobId 0: 3301 Issuing autochanger "loaded? drive 0" command.
07-Dec 20:43 btape JobId 0: 3302 Autochanger "loaded? drive 0", result is Slot 1.
btape: btape.c:477 open device "DTL02" (/dev/nsa1): OK
*test

=== Write, rewind, and re-read test ===

I'm going to write 10000 records and an EOF
then write 10000 records and an EOF, then rewind,
and re-read the data to verify that it is correct.

This is an *essential* feature ...

btape: btape.c:1155 Wrote 10000 blocks of 64412 bytes.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:1171 Wrote 10000 blocks of 64412 bytes.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:1213 Rewind OK.
10000 blocks re-read correctly.
Got EOF on tape.
10000 blocks re-read correctly.
=== Test Succeeded. End Write, rewind, and re-read test ===

btape: btape.c:1281 Block position test
btape: btape.c:1293 Rewind OK.
Reposition to file:block 0:4
Block 5 re-read correctly.
Reposition to file:block 0:200
Block 201 re-read correctly.
Reposition to file:block 0:9999
Block 10000 re-read correctly.
Reposition to file:block 1:0
Block 10001 re-read correctly.
Reposition to file:block 1:600
Block 10601 re-read correctly.
Reposition to file:block 1:9999
Block 20000 re-read correctly.
=== Test Succeeded. End Write, rewind, and re-read test ===



=== Append files test ===

This test is essential to Bacula.

I'm going to write one record  in file 0,
                   two records in file 1,
             and three records in file 2

btape: btape.c:579 Rewound "DTL02" (/dev/nsa1)
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:477 open device "DTL02" (/dev/nsa1): OK
btape: btape.c:579 Rewound "DTL02" (/dev/nsa1)
btape: btape.c:1425 Now moving to end of medium.
btape: btape.c:630 Moved to end of medium.
We should be in file 3. I am at file 3. This is correct!

Now the important part, I am going to attempt to append to the tape.

btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:579 Rewound "DTL02" (/dev/nsa1)
Done appending, there should be no I/O errors

Doing Bacula scan of blocks:
1 block of 64448 bytes in file 1
End of File mark.
2 blocks of 64448 bytes in file 2
End of File mark.
3 blocks of 64448 bytes in file 3
End of File mark.
1 block of 64448 bytes in file 4
End of File mark.
Total files=4, blocks=7, bytes = 451,136
End scanning the tape.
We should be in file 4. I am at file 4. This is correct!

The above Bacula scan should have output identical to what follows.
Please double check it ...
=== Sample correct output ===
1 block of 64448 bytes in file 1
End of File mark.
2 blocks of 64448 bytes in file 2
End of File mark.
3 blocks of 64448 bytes in file 3
End of File mark.
1 block of 64448 bytes in file 4
End of File mark.
Total files=4, blocks=7, bytes = 451,136
=== End sample correct output ===

If the above scan output is not identical to the
sample output, you MUST correct the problem
or Bacula will not be able to write multiple Jobs to
the tape.

Skipping read backwards test because BSR turned off.


=== Forward space files test ===

This test is essential to Bacula.

I'm going to write five files then test forward spacing

btape: btape.c:579 Rewound "DTL02" (/dev/nsa1)
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:1912 Wrote one record of 64412 bytes.
btape: btape.c:1914 Wrote block to device.
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:609 Wrote 1 EOF to "DTL02" (/dev/nsa1)
btape: btape.c:579 Rewound "DTL02" (/dev/nsa1)
btape: btape.c:1639 Now forward spacing 1 file.
We should be in file 1. I am at file 1. This is correct!
btape: btape.c:1651 Now forward spacing 2 files.
We should be in file 3. I am at file 3. This is correct!
btape: btape.c:579 Rewound "DTL02" (/dev/nsa1)
btape: btape.c:1664 Now forward spacing 4 files.
We should be in file 4. I am at file 4. This is correct!

btape: btape.c:1682 Now forward spacing 1 more file.
We should be in file 5. I am at file 5. This is correct!

=== End Forward space files test ===


Ah, I see you have an autochanger configured.
To test the autochanger you must have a blank tape
 that I can write on in Slot 1.

Do you wish to continue with the Autochanger test? (y/n):  y


=== Autochanger test ===

3301 Issuing autochanger "loaded" command.
Slot 1 loaded. I am going to unload it.
3302 Issuing autochanger "unload 1 0" command.
unload status=OK 0
3303 Issuing autochanger "load 1 0" command.
3303 Autochanger "load 1 0" status is OK.
btape: btape.c:477 open device "DTL02" (/dev/nsa1): OK
btape: btape.c:1569 Rewound "DTL02" (/dev/nsa1)
btape: btape.c:1576 Wrote EOF to "DTL02" (/dev/nsa1)

The test autochanger worked!!

*q
btape: smartall.c:404 Orphaned buffer: btape 280 bytes at 801a17628 from jcr.c:362

That’s an interesting message at the end… That’s probably a btape bug and it’s not freeing up a buffer properly. I’m sure it’s nothing to worry about.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive