In this third and final blog entry on using tape devices with Linux in an IBM i environment, I'll show you how the image catalog and virtual device capabilities of IBM i can be leveraged to make virtual tape resources available to a hosted Linux partition.
In previous blog entries in this series, I've shown you how tape devices can be moved between IBM i and Linux and how physical tape devices can be used with PowerLinux. In this final part, I'll concentrate on how the virtual tape library feature in IBM i can be leveraged to make virtual tape available to Linux.
For several releases, the IBM i OS has had support for virtual tape devices and virtual tape libraries. It's possible to leverage those virtual devices from a Linux partition through the vSCSI connection between Linux and the IBM i partition, but there are several configuration items you need to be aware of.
Network Server Description
The Network Server Description (NWSD) is used to define which optical and tape devices to make available to the Linux OS. By default, all optical and tape devices are made available, regardless of whether they are physical or virtual devices. The Restricted device resources (RSTDDEVRSC) field of the NWSD can be used to limit the optical and tape devices that are mapped through the NWSD to the guest partition. Any device listed in the Restricted device resources field will NOT be mapped to the partition.
A common issue that comes up when guest partitions are using storage from an IBM i partition is that tape devices suddenly aren't available to the IBM i OS. This occurs because tape devices can only be mapped to one partition at a time, unlike optical devices, which can be mapped to multiple partitions simultaneously. When a NWSD is varied on any tape device that's in a varied off state in the IBM i OS and not defined as restricted, the device is made available to the guest partition. This means that if IBM i tries to vary on the tape device, the vary on will fail (my previous blog entry on moving tape devices between Linux and IBM i explains how to work around that issue).
Virtual Tape Device and Image Catalog
The image catalog feature of IBM i, along with Virtual Tape Device, can be used to make a virtual tape available to the Linux partition. The virtual tape device is created with the CRTDEVTAP command, as follows:
where DEVD specifies the name to be assigned to the tape device, and RSRCNAME indicates that the resource is a virtual resource.
UPDATE (17-July-2013): When creating the virtual tape device it is imperative to make sure that the 'Unload device at vary off' (UNLOAD) is set to *NO (the default is *YES). If the setting is not changed from the default then Linux will not see a mounted volume since the volume will have been unmounted when the tape device is varried off later in these instructions.
The image catalog is created with the CRTIMGCLG command, as follows:
where IMGCLG specifies the name to assign to the image catalog, DIR indicates the directory to store the image catalog entries, and TYPE indicates that the image catalog is for tape resources (as opposed to optical resources).
A virtual tape resource is added to the catalog with the following command:
where IMGCLG specifies the name of the image catalog that the entry is to be added to, FROMFILE indicates that a new entry is to be created, and TOFILE indicates the name assigned to the file created in the target directory of the image catalog for this catalog entry.
The next step in the process is to load the image catalog onto the virtual tape device; however, before the catalog can be loaded, the virtual tape device needs to be in a varied on state:
where CFGOBJ indicates the name of the virtual tape device, CFGTYPE indicates that the command will operate on a device, and STATUS indicates that the device is to be varied on.
Once the virtual optical tape device has been varied on, the image catalog can be loaded:
where IMGCLG indicates the name of the image catalog to load and DEV indicates the device to load the image catalog on to.
After the catalog has been mounted, use option 6 (mount) of the WRKIMGCLGE command to mount the correct tape resource. Remember that tape devices (regardless of whether they are real or virtual) can only be allocated to one partition at a time, so once the correct image has been mounted from the image catalog, the virtual tape device needs to be varied off:
In the command above, CFGOBJ indicates the name of the virtual tape device, CFGTYPE indicates that the command will operate on a device, and STATUS indicates that the device is to be varied off.
Accessing the Tape from Linux
Now that the tape has been mounted on the virtual tape device and the tape device has been put into a varied off state in the hosting IBM i partition, it can be accessed from the Linux partition. Refer to my previous blog entry on moving tape devices between Linux and IBM i for the commands to access the tape device from Linux and for releasing the tape device from Linux so that IBM i can have access to it again. You can also find out more on tape devices, Linux, and IBM i in the first blog in this series, "Using Physical Tape Devices with PowerLinux."