Displaying Virtual Optical Device Info with lsvopt

Edit: Some links no longer work.

Originally posted September 29, 2015 on AIXchange

I have a client that works with virtual optical devices, having built one for each LPAR on its system. The client wanted to know the easiest way to display these devices along with all of the virtual media (both the media already loaded into the devices, and the media available to load).

I’ve covered this topic before (see here and here), but it’s worth revisiting.

The client created the virtual optical devices using this command:

    mkvdev –fbo –vadapter vhostX –dev somename

Media from the DVD drive was copied using this command:

    mkvopt –name cdname.iso –dev cd0 –ro

Media was verified with the lsrep command, which displays the size of the client’s virtual media repository, along with the names, sizes and access of all the .iso images (either ro or rw). (Note: I recommend monitoring the size of your own media repository, particularly if you plan on adding more media.) While similar information can be found with ls –la /var/vio/VMLibrary, lsrep seems a bit more user friendly.

On this project, I worked directly with a guy with an IBM i background and limited familiarity with the VIO server. In my experience it seems that people accustomed to IBM i tend to look for an HMC GUI method to manipulate the VIO server or some other easier way of doing things compared to messing around with UNIX command line stuff. In this instance, he was trying to avoid a couple of common uses of the lsmap command:

* lsmap -vadapter vhostX — This would require him to specify the vadapter parameter and go through the adapters one by one.

* lsmap –all | more — He didn’t want to have to scroll through all of the resulting output.

Fortunately, the lsvopt command provided the alternative to all that pain. With lsvopt, he could inventory the virtual media devices, displaying the name of each device, the media that was loaded, and the size of the loaded media.

Since I mentioned it, note that lsvopt is also a handy when it comes to VIO server upgrades. See this section of the release notes:

Before installing the VIOS Update Release 2.2.3.50
The update could fail if there is a loaded media repository.

Checking for a loaded media repository
To check for a loaded media repository, and then unload it, follow these steps.
    To check for loaded images, run the following command: $ lsvopt
    The Media column lists any loaded media.
    To unload media images, run the following commands on all Virtual Target Devices that have loaded images: $ unloadopt -vtd <file-backed_virtual_optical_device>
    To verify that all media are unloaded, run the following command again: $ lsvopt
    The command output should show No Media for all VTDs.

While a lot of you rely on lsmap, I still run into people who don’t know about lsvopt. Plus, a refresher never hurts.