%%
%%
-\section*{Autochangers Support}
-\label{_ChapterStart18}
-\index[general]{Support!Autochangers }
-\index[general]{Autochangers Support }
-\addcontentsline{toc}{section}{Autochangers Support}
-
-\subsection*{Autochangers -- General}
-\index[general]{General!Autochangers -- }
-\index[general]{Autochangers -- General }
-\addcontentsline{toc}{subsection}{Autochangers -- General}
+\chapter{Autochanger Support}
+\label{AutochangersChapter}
+\index[general]{Support!Autochanger }
+\index[general]{Autochanger Support }
Bacula provides autochanger support for reading and writing tapes. In
-order to work with an autochanger, Bacula requires three things, each of
+order to work with an autochanger, Bacula requires a number of things, each of
which is explained in more detail after this list:
\begin{itemize}
\item A script that actually controls the autochanger according to commands
sent by Bacula. We furnish such a script that works with {\bf mtx} found in
- the {\bf depkgs} distribution. This script works only with single drive
- autochangers.
+ the {\bf depkgs} distribution.
+
\item That each Volume (tape) to be used must be defined in the Catalog and
have a Slot number assigned to it so that Bacula knows where the Volume is in
- the autochanger. This is generally done with the {\bf label} command. See
+ the autochanger. This is generally done with the {\bf label} command,
+ but can also done after the tape is labeled using the {\bf update slots}
+ command. See
below for more details. You must pre-label the tapes manually before
- using them.
+ using them.
+
\item Modifications to your Storage daemon's Device configuration resource to
identify that the device is a changer, as well as a few other parameters.
+
\item You should also modify your Storage resource definition in the
Director's configuration file so that you are automatically prompted for the
Slot when labeling a Volume.
+
\item You need to ensure that your Storage daemon (if not running as root)
has access permissions to both the tape drive and the control device.
+
\item You need to have {\bf Autochanger = yes} in your Storage resource
in your bacula-dir.conf file so that you will be prompted for the
slot number when you label Volumes.
\end{itemize}
-In version 1.37, there is a new \ilink{Autochanger
+In version 1.37 and later, there is a new \ilink{Autochanger
resource}{AutochangerRes} that permits you to group Device resources thus
-creating a multi-drive autochanger. If you have a multi-drive autochanger,
-you must use this new resource. If you have a single drive autochanger,
-it is recommended, but not required.
+creating a multi-drive autochanger. If you have an autochanger,
+you {\bf must} use this new resource.
Bacula uses its own {\bf mtx-changer} script to interface with a program
that actually does the tape changing. Thus in principle, {\bf mtx-changer}
-can be adapted to function with any autochanger program. The current
+can be adapted to function with any autochanger program, or you can
+call any other script or program. The current
version of {\bf mtx-changer} works with the {\bf mtx} program. However,
FreeBSD users have provided a script in the {\bf examples/autochangers}
directory that allows Bacula to use the {\bf chio} program.
Bacula also supports autochangers with barcode
readers. This support includes two Console commands: {\bf label barcodes}
-and {\bf update slots}. For more details on these commands, see the ``Barcode
-Support'' section below.
+and {\bf update slots}. For more details on these commands, see the "Barcode
+Support" section below.
Current Bacula autochanger support does not include cleaning, stackers, or
-silos. However, under certain conditions, you may be able to make Bacula
-work with stackers (gravity feed and such). Support for multi-drive
+silos. Stackers and silos are not supported because Bacula expects to
+be able to access the Slots randomly.
+However, if you are very careful to setup Bacula to access the Volumes
+in the autochanger sequentially, you may be able to make Bacula
+work with stackers (gravity feed and such).
+
+Support for multi-drive
autochangers requires the \ilink{Autochanger resource}{AutochangerRes}
introduced in version 1.37. This resource is also recommended for single
drive autochangers.
just a question of adapting the {\bf mtx-changer} script (or selecting one
already adapted) for proper interfacing. You can find a list of autochangers
supported by {\bf mtx} at the following link:
-\elink{http://mtx.badtux.net/compatibility.php}
-{http://mtx.badtux.net/compatibility.php}.
+\elink{http://mtx.opensource-sw.net/compatibility.php}
+{http://mtx.opensource-sw.net/compatibility.php}.
The home page for the {\bf mtx} project can be found at:
-\elink{http://mtx.badtux.net/}{http://mtx.badtux.net/}.
+\elink{http://mtx.opensource-sw.net/}{http://mtx.opensource-sw.net/}.
+
+Note, we have feedback from some users that there are certain
+incompatibilities between the Linux kernel and mtx. For example between
+kernel 2.6.18-8.1.8.el5 of CentOS and RedHat and version 1.3.10 and 1.3.11
+of mtx. This was fixed by upgrading to a version 2.6.22 kernel.
+
+In addition, apparently certain versions of mtx, for example, version
+1.3.11 limit the number of slots to a maximum of 64. The solution was to
+use version 1.3.10.
If you are having troubles, please use the {\bf auto} command in the {\bf
btape} program to test the functioning of your autochanger with Bacula. When
root.root}, so you will need to ensure that the Storage daemon has sufficient
permissions to access the autochanger.
+Some users have reported that the the Storage daemon blocks under certain
+circumstances in trying to mount a volume on a drive that has a different
+volume loaded. As best we can determine, this is simply a matter of
+waiting a bit. The drive was previously in use writing a Volume, and
+sometimes the drive will remain BLOCKED for a good deal of time (up to 7
+minutes on a slow drive) waiting for the cassette to rewind and to unload
+before the drive can be used with a different Volume.
+
\label{SCSI devices}
-\subsection*{Knowing What SCSI Devices You Have}
+\section{Knowing What SCSI Devices You Have}
\index[general]{Have!Knowing What SCSI Devices You }
\index[general]{Knowing What SCSI Devices You Have }
\index[general]{SCSI devices}
\index[general]{devices!SCSI}
-\addcontentsline{toc}{subsection}{Knowing What SCSI Devices You Have}
Under Linux, you can
first, {\bf /dev/sg1} for the second, ...) on the {\bf Changer Device = }
Bacula directive.
+For more detailed information on what SCSI devices you have please see
+the \ilink{Linux SCSI Tricks}{SCSITricks} section of the Tape Testing
+chapter of this manual.
+
Under FreeBSD, you can use:
\footnotesize
Please check that your Storage daemon has permission to access this
device.
-\label{scripts}
+The following tip for FreeBSD users comes from Danny Butroyd:
+on reboot Bacula will NOT have permission to
+control the device /dev/pass0 (assuming this is your changer device).
+To get around this just edit the /etc/devfs.conf file and add the
+following to the bottom:
+\footnotesize
+\begin{verbatim}
+own pass0 root:bacula
+perm pass0 0666
+own nsa0.0 root:bacula
+perm nsa0.0 0666
+\end{verbatim}
+\normalsize
+
+This gives the bacula group permission to write to the nsa0.0 device
+too just to be on the safe side. To bring these changes into effect
+just run:-
+
+/etc/rc.d/devfs restart
-\subsection*{Example Scripts}
+Basically this will stop you having to manually change permissions on these
+devices to make Bacula work when operating the AutoChanger after a reboot.
+
+\label{scripts}
+\section{Example Scripts}
\index[general]{Scripts!Example }
\index[general]{Example Scripts }
-\addcontentsline{toc}{subsection}{Example Scripts}
Please read the sections below so that you understand how autochangers work
with Bacula. Although we supply a default {\bf mtx-changer} script, your
\label{Slots}
-\subsection*{Slots}
+\section{Slots}
\index[general]{Slots }
-\addcontentsline{toc}{subsection}{Slots}
To properly address autochangers, Bacula must know which Volume is in each
{\bf slot} of the autochanger. Slots are where the changer cartridges reside
Bacula will not automatically use a Volume in your autochanger unless it is
labeled and the slot number is stored in the catalog and the Volume is marked
-as InChanger. For each Volume in your
+as InChanger. This is because it must know where each volume is (slot) to
+be able to load the volume.
+For each Volume in your
changer, you will, using the Console program, assign a slot. This information
is kept in {\bf Bacula's} catalog database along with the other data for the
volume. If no slot is given, or the slot is set to zero, Bacula will not
attempt to use the autochanger even if all the necessary configuration records
-are present. In addition, the console {\bf mount} command does not cause
-Bacula to operate the autochanger, it only tells Bacula to read any tape that
-may be in the drive.
+are present. When doing a {\bf mount} command on an autochanger, you must
+specify which slot you want mounted. If the drive is loaded with a tape
+from another slot, it will unload it and load the correct tape, but
+normally, no tape will be loaded because an {\bf unmount} command causes
+Bacula to unload the tape in the drive.
+
You can check if the Slot number and InChanger flag are set by doing a:
\begin{verbatim}
in the Console program.
\label{mult}
-\subsection*{Multiple Devices}
-\index[general]{Devices!Multiple }
-\index[general]{Multiple Devices }
-\addcontentsline{toc}{subsection}{Multiple Devices}
+\section{Multiple Devices}
+\index[general]{Devices!Multiple}
+\index[general]{Multiple Devices}
Some autochangers have more than one read/write device (drive). The
-new
-\ilink{Autochanger resource}{AutochangerRes} introduced in version
+new \ilink{Autochanger resource}{AutochangerRes} introduced in version
1.37 permits you to group Device resources, where each device
represents a drive. The Director may still reference the Devices (drives)
directly, but doing so, bypasses the proper functioning of the
Device} (control channel) as the first drive, but a different {\bf Archive
Device}.
+As a default, Bacula jobs will prefer to write to a Volume that is
+already mounted. If you have a multiple drive autochanger and you want
+Bacula to write to more than one Volume in the same Pool at the same
+time, you will need to set \ilink{Prefer Mounted Volumes} {PreferMountedVolumes}
+in the Directors Job resource to {\bf no}. This will cause
+the Storage daemon to maximize the use of drives.
+
+
\label{ConfigRecords}
-\subsection*{Device Configuration Records}
+\section{Device Configuration Records}
\index[general]{Records!Device Configuration }
\index[general]{Device Configuration Records }
-\addcontentsline{toc}{subsection}{Device Configuration Records}
Configuration of autochangers within Bacula is done in the Device resource of
the Storage daemon. Four records: {\bf Autochanger}, {\bf Changer Device},
\input{autochangerres}
\label{example}
-\subsection*{An Example Configuration File}
+\section{An Example Configuration File}
\index[general]{Example Configuration File }
\index[general]{File!Example Configuration }
-\addcontentsline{toc}{subsection}{Example Configuration File}
The following two resources implement an autochanger:
LabelMedia = no;
AutomaticMount = yes;
AlwaysOpen = yes;
- Mount Anonymous Volumes = no;
}
\end{verbatim}
\normalsize
the path to the {\bf Changer Command} to correspond to the values used on your
system.
+\section{A Multi-drive Example Configuration File}
+\index[general]{Multi-drive Example Configuration File }
+
+The following resources implement a multi-drive autochanger:
+
+\footnotesize
+\begin{verbatim}
+Autochanger {
+ Name = "Autochanger"
+ Device = Drive-1, Drive-2
+ Changer Device = /dev/sg0
+ Changer Command = "/etc/bacula/mtx-changer %c %o %S %a %d"
+}
+
+Device {
+ Name = Drive-1
+ Drive Index = 0
+ Media Type = DDS-4
+ Archive Device = /dev/nst0 # Normal archive device
+ Autochanger = yes
+ LabelMedia = no;
+ AutomaticMount = yes;
+ AlwaysOpen = yes;
+}
+
+Device {
+ Name = Drive-2
+ Drive Index = 1
+ Media Type = DDS-4
+ Archive Device = /dev/nst1 # Normal archive device
+ Autochanger = yes
+ LabelMedia = no;
+ AutomaticMount = yes;
+ AlwaysOpen = yes;
+}
+
+\end{verbatim}
+\normalsize
+
+where you will adapt the {\bf Archive Device}, the {\bf Changer Device}, and
+the path to the {\bf Changer Command} to correspond to the values used on your
+system.
\label{SpecifyingSlots}
-\subsection*{Specifying Slots When Labeling}
+\section{Specifying Slots When Labeling}
\index[general]{Specifying Slots When Labeling }
\index[general]{Labeling!Specifying Slots When }
-\addcontentsline{toc}{subsection}{Specifying Slots When Labeling}
If you add an {\bf Autochanger = yes} record to the Storage resource in your
Director's configuration file, the Bacula Console will automatically prompt
For each tape in the changer containing a barcode, Bacula will mount the tape
and then label it with the same name as the barcode. An appropriate Media
record will also be created in the catalog. Any barcode that begins with the
-same characters as specified on the ``CleaningPrefix=xxx'' command, will be
+same characters as specified on the "CleaningPrefix=xxx" command, will be
treated as a cleaning tape, and will not be labeled. For example with:
Please note that Volumes must be pre-labeled to be automatically used in
Any slot containing a barcode of CLNxxxx will be treated as a cleaning tape
and will not be mounted.
-\label{Magazines}
+\section{Changing Cartridges}
+\index[general]{Changing Cartridges }
+If you wish to insert or remove cartridges in your autochanger or
+you manually run the {\bf mtx} program, you must first tell Bacula
+to release the autochanger by doing:
+
+\footnotesize
+\begin{verbatim}
+unmount
+(change cartridges and/or run mtx)
+mount
+\end{verbatim}
+\normalsize
+
+If you do not do the unmount before making such a change, Bacula
+will become completely confused about what is in the autochanger
+and may stop function because it expects to have exclusive use
+of the autochanger while it has the drive mounted.
+
-\subsection*{Dealing with Multiple Magazines}
+\label{Magazines}
+\section{Dealing with Multiple Magazines}
\index[general]{Dealing with Multiple Magazines }
\index[general]{Magazines!Dealing with Multiple }
-\addcontentsline{toc}{subsection}{Dealing with Multiple Magazines}
If you have several magazines or if you insert or remove cartridges from a
magazine, you should notify Bacula of this. By doing so, Bacula will as
\footnotesize
\begin{verbatim}
+unmount
+(remove magazine)
+(insert new magazine)
update slots
+mount
\end{verbatim}
\normalsize
\begin{enumerate}
\item You can manually set the Slot and InChanger flag using the {\bf update
volume} command in the Console (quite painful).
+
\item You can issue a
- \footnotesize
+\footnotesize
\begin{verbatim}
update slots scan
\end{verbatim}
the magazine in turn and update the information (Slot, InChanger flag) in the
catalog. This is quite effective but does take time to load each cartridge
into the drive in turn and read the Volume label.
+
\item You can modify the mtx-changer script so that it simulates an
autochanger with barcodes. See below for more details.
- \end{enumerate}
+\end{enumerate}
\label{simulating}
-
-\subsection*{Simulating Barcodes in your Autochanger}
+\section{Simulating Barcodes in your Autochanger}
\index[general]{Autochanger!Simulating Barcodes in your }
\index[general]{Simulating Barcodes in your Autochanger }
-\addcontentsline{toc}{subsection}{Simulating Barcodes in your Autochanger}
You can simulate barcodes in your autochanger by making the {\bf mtx-changer}
script return the same information that an autochanger with barcodes would do.
your autochanger will appear to Bacula to be an autochanger with barcodes.
\label{updateslots}
-\subsection*{The Full Form of the Update Slots Command}
+\section{The Full Form of the Update Slots Command}
\index[general]{Full Form of the Update Slots Command }
\index[general]{Command!Full Form of the Update Slots }
-\addcontentsline{toc}{subsection}{Full Form of the Update Slots Command}
If you change only one cartridge in the magazine, you may not want to scan all
Volumes, so the {\bf update slots} command (as well as the {\bf update slots
not find any Volume names so will do nothing.
\label{FreeBSD}
-\subsection*{FreeBSD Issues}
+\section{FreeBSD Issues}
\index[general]{Issues!FreeBSD }
\index[general]{FreeBSD Issues }
-\addcontentsline{toc}{subsection}{FreeBSD Issues}
If you are having problems on FreeBSD when Bacula tries to select a tape, and
the message is {\bf Device not configured}, this is because FreeBSD has made
autochanger testing.
\label{AutochangerTesting}
-\subsection*{Testing the Autochanger and Adapting Your mtx-changer Script}
-\index[general]{Testing the Autochanger and Adapting Your mtx-changer Script }
-\index[general]{Script!Testing the Autochanger and Adapting Your mtx-changer }
-\addcontentsline{toc}{subsection}{Testing the Autochanger and Adapting Your
-mtx-changer Script}
+\section{Testing Autochanger and Adapting mtx-changer script}
+\index[general]{Testing the Autochanger }
+\index[general]{Adapting Your mtx-changer script}
+
Before attempting to use the autochanger with Bacula, it is preferable to
-``hand-test'' that the changer works. To do so, we suggest you do the
+"hand-test" that the changer works. To do so, we suggest you do the
following commands (assuming that the {\bf mtx-changer} script is installed in
{\bf /etc/bacula/mtx-changer}):
\begin{description}
\item [Make sure Bacula is not running.]
- \index[sd]{Make sure Bacula is not running. }
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ list \ 0 \ /dev/nst0 \ 0]
- \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ list \ 0 \ /dev/nst0 \ 0
- }
+\index[sd]{mtx-changer list}
+
This command should print:
\footnotesize
if {\bf /dev/sg0} is incorrect. For example, on FreeBSD systems, the
autochanger SCSI control device is generally {\bf /dev/pass2}.
-\item [/etc/bacula/mtx-changer \ /dev/sg0 \ slots \ 0 \ /dev/nst0 \ 0]
- \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ slots \ 0 \ /dev/nst0 \ 0
- }
+\item [/etc/bacula/mtx-changer \ /dev/sg0 \ slots ]
+\index[sd]{mtx-changer slots}
+
This command should return the number of slots in your autochanger.
-\item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ ]
- \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ }
- If a tape is loaded, this should cause it to be unloaded.
+\item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ 1 \ /dev/nst0 \ 0 ]
+\index[sd]{mtx-changer unload}
+
+ If a tape is loaded from slot 1, this should cause it to be unloaded.
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ load \ 3 \ /dev/nst0 \ 0 ]
- \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ load \ 3 \ /dev/nst0 \ 0
- }
-Assuming you have a tape in slot 3, it will be loaded into the read slot (0).
+\index[sd]{mtx-changer load}
+
+Assuming you have a tape in slot 3, it will be loaded into drive (0).
\item [/etc/bacula/mtx-changer \ /dev/sg0 \ loaded \ 0 \ /dev/nst0 \ 0]
- \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ loaded \ 0 \ /dev/nst0 \
- 0 }
-It should print ``3''
+\index[sd]{mtx-changer loaded}
-\item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload]
- \index[sd]{/etc/bacula/mtx-changer \ /dev/sg0 \ unload }
- \end{description}
+It should print "3"
+Note, we have used an "illegal" slot number 0. In this case, it is simply
+ignored because the slot number is not used. However, it must be specified
+because the drive parameter at the end of the command is needed to select
+the correct drive.
+
+\item [/etc/bacula/mtx-changer \ /dev/sg0 \ unload \ 3 /dev/nst0 \ 0]
+
+will unload the tape into slot 3.
+
+\end{description}
Once all the above commands work correctly, assuming that you have the right
{\bf Changer Command} in your configuration, Bacula should be able to operate
\footnotesize
\begin{verbatim}
#!/bin/sh
-/etc/bacula/mtx-changer /dev/sg0 unload
-/etc/bacula/mtx-changer /dev/sg0 load 3
+/etc/bacula/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
+/etc/bacula/mtx-changer /dev/sg0 load 3 /dev/nst0 0
mt -f /dev/st0 rewind
mt -f /dev/st0 weof
\end{verbatim}
\footnotesize
\begin{verbatim}
#!/bin/sh
-/etc/bacula/mtx-changer /dev/sg0 unload
+/etc/bacula/mtx-changer /dev/sg0 unload 1 /dev/nst0 0
mt -f /dev/st0 offline
-/etc/bacula/mtx-changer /dev/sg0 load 3
+/etc/bacula/mtx-changer /dev/sg0 load 3 /dev/nst0 0
mt -f /dev/st0 rewind
mt -f /dev/st0 weof
\end{verbatim}
\lt{}bacula-source\gt{}/examples/devices} that implement the above features,
so they may be a help to you in getting your script to work.
-If Bacula complains ``Rewind error on /dev/nst0. ERR=Input/output error.'' you
+If Bacula complains "Rewind error on /dev/nst0. ERR=Input/output error." you
most likely need more sleep time in your {\bf mtx-changer} before returning to
Bacula after a load command has been completed.
\label{using}
-\subsection*{Using the Autochanger}
+\section{Using the Autochanger}
\index[general]{Using the Autochanger }
\index[general]{Autochanger!Using the }
-\addcontentsline{toc}{subsection}{Using the Autochanger}
Let's assume that you have properly defined the necessary Storage daemon
Device records, and you have added the {\bf Autochanger = yes} record to the
Once all your Volumes are labeled, Bacula will automatically load them as they
are needed.
-To ``see'' how you have labeled your Volumes, simply enter the {\bf list
+To "see" how you have labeled your Volumes, simply enter the {\bf list
volumes} command from the Console program, which should print something like
the following:
\label{Barcodes}
-\subsection*{Barcode Support}
+\section{Barcode Support}
\index[general]{Support!Barcode }
\index[general]{Barcode Support }
-\addcontentsline{toc}{subsection}{Barcode Support}
Bacula provides barcode support with two Console commands, {\bf label
barcodes} and {\bf update slots}.
\label{interface}
-\subsection*{Bacula Autochanger Interface}
+\section{Bacula Autochanger Interface}
\index[general]{Interface!Bacula Autochanger }
\index[general]{Bacula Autochanger Interface }
-\addcontentsline{toc}{subsection}{Bacula Autochanger Interface}
Bacula calls the autochanger script that you specify on the {\bf Changer
Device} statement. Normally this script will be the {\bf mtx-changer} script
-that we can provide, but it can in fact be any program. The only requirements
-are that the ``commands'' that Bacula uses are {\bf loaded}, {\bf load}, {\bf
+that we provide, but it can in fact be any program. The only requirement
+for the script is that it must understand the commands that
+Bacula uses, which are {\bf loaded}, {\bf load}, {\bf
unload}, {\bf list}, and {\bf slots}. In addition,
each of those commands must return the information in the precise format as
specified below:
\footnotesize
\begin{verbatim}
- Currently the changer commands used are:
- loaded -- returns number of the slot that is loaded in
- the drive or 0 if the drive is empty.
+ loaded -- returns number of the slot that is loaded, base 1,
+ in the drive or 0 if the drive is empty.
load -- loads a specified slot (note, some autochangers
require a 30 second pause after this command) into
the drive.
\normalsize
Bacula checks the exit status of the program called, and if it is zero, the
-data is accepted. If the exit status is non-zero, Bacula ignores any
-information returned and treats the drive as if it is not an autochanger.
+data is accepted. If the exit status is non-zero, Bacula will print an
+error message and request the tape be manually mounted on the drive.