Loading and Unloading Virtual Media

In order for a virtual media to be used by an LPAR, the media must first be inserted (loaded) into the associated virtual optical device. This is done by calling the command “vios loadopt“.

Before we do that, let’s first list the available virtual media and the existing virtual optical devices:

$ vios lsmedia ms12-vio1
NAME                  FILE SIZE  OPTICAL  ACCESS
AIX_720500_DVD_1.iso    3.56 GB  None     ro
AIX_720500_DVD_2.iso    4.00 GB  None     ro
AIX_720501_flash.iso    7.56 GB  None     rw
$ vios lsvopt ms12-vio1
VTD       MEDIA     SIZE
aix04_cd  No Media  n/a
vtopt0    No Media  n/a
vtopt1    No Media  n/a
$

We load the virtual medium AIX_720500_DVD_1.iso into the virtual drive of the LPAR aix04 (aix04_cd):

$ vios loadopt ms12-vio1 AIX_720500_DVD_1.iso aix04_cd
$

The output of “vios lsvopt” shows that the named virtual medium is now inserted in the aix04_cd drive:

$ vios lsvopt ms12-vio1
VTD       MEDIA                 SIZE
aix04_cd  AIX_720500_DVD_1.iso    3.56 GB
vtopt0    No Media              n/a
vtopt1    No Media              n/a
$

The virtual medium can then be used immediately on the client LPAR. E.g. by mounting the file system contained on the medium:

aix04 # mount -o ro -V cdrfs /dev/cd0 /cdrom
aix04 # ls -l /cdrom
total 80
drwxr-xr-x    2 4000     4000           2048 Dec  8 2020  7200-05/
-rw-r--r--    1 4000     4000             16 Dec  8 2020  OSLEVEL
-rw-r--r--    1 4000     4000            901 Dec  8 2020  README.aix
drwxrwxr-x    4 4000     4000           2048 Dec  8 2020  RPMS/
-rw-r--r--    1 4000     4000           6529 Dec  8 2020  bosinst.data
-rw-r--r--    1 4000     4000          15430 Dec  8 2020  image.data
drwxr-xr-x    4 4000     4000           2048 Dec  8 2020  installp/
drwxr-xr-x    3 4000     4000           2048 Dec  8 2020  ppc/
drwxr-xr-x    3 4000     4000           2048 Dec  8 2020  root/
drwxr-xr-x   10 4000     4000           2048 Dec  8 2020  usr/
aix04 #

The “vios unloadopt” command can be used to unload (eject) a virtual medium again. However, the medium must no longer be in use in the client LPAR, as the following example shows:

$ vios unloadopt ms12-vio1 aix04_cd
hmc01: viosvrcmd -m ms12 -p ms12-vio1 -c \"unloadopt -vtd aix04_cd\“
ERROR: remote HMC command returned an error (1)
StdErr: HSCL2970 The IOServer command has failed because of the following reason:
StdErr: Unable to perform the requested operation.
StdErr: aix04_cd’ is currently reserved by the client.
StdErr:
StdErr: Use the -release flag to remove the reserve
StdErr:
StdErr: rc=41
$

The virtual media file system is still mounted in the LPAR. You can use the “-r” option to force the medium to be unloaded, but then the mounted file system in the client LPAR hangs in the air and is no longer usable. We therefore first unmount the file system in the client LPAR:

aix04 # umount /cdrom
aix04 #

and then try to unload the media again:

$ vios unloadopt ms12-vio1 aix04_cd
$

There is no error message and a listing of the virtual optical devices also shows that the medium is no longer loaded:

$ vios lsvopt ms12-vio1
VTD       MEDIA     SIZE
aix04_cd  No Media  n/a
vtopt0    No Media  n/a
vtopt1    No Media  n/a
$

A read-only medium can easily be used by several LPARs (virtual optical devices) at the same time:

$ vios lsmedia ms12-vio1
NAME                  FILE SIZE  OPTICAL   ACCESS
AIX_720500_DVD_1.iso    3.56 GB  aix04_cd  ro
AIX_720500_DVD_1.iso    3.56 GB  vtopt0    ro
AIX_720500_DVD_2.iso    4.00 GB  None      ro
AIX_720501_flash.iso    7.56 GB  None      rw
$

However, this is not the case for media with write permissions. Such a medium can only be used once at a time:

$ vios loadopt ms12-vio1 mksysb_aix01.iso aix04_cd
$ vios loadopt ms12-vio1 mksysb_aix01.iso vtopt0
hmc01: viosvrcmd -m ms12 -p ms12-vio1 -c \"loadopt -disk mksysb_aix01.iso -vtd vtopt0\"
ERROR: remote HMC command returned an error (1)
StdErr: HSCL2970 The IOServer command has failed because of the following reason:
StdErr: The specified virtual disk is not read-only, and cannot be
StdErr: loaded into multiple devices simultaneously
StdErr:
StdErr: rc=4
$

This is what the error message says very clearly!