Deleting Virtual Optical Devices

In the following, we show how to delete virtual optical devices using some concrete examples. The command to remove virtual optical devices is “vios rmvopt“. The devices to be deleted are:

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

As the output shows, two of the virtual optical devices (aix04_cd and vtopt0) still have virtual media loaded. All three devices shown should be removed.

We start with the last device (vtopt1). It currently has not loaded any virtual media and we remove this virtual optical device using “vios rmvopt“:

$ vios rmvopt ms12-vio1 vtopt1
$

The virtual optical device has been removed from the virtual I/O server:

$ vios lsvopt ms12-vio1
VTD       MEDIA                 SIZE
aix04_cd  AIX_720500_DVD_1.iso    3.56 GB
vtopt0    AIX_720500_DVD_1.iso    3.56 GB
$

A quick check on the LPAR aix03 to which the removed device belongs, shows that the virtual optical device is still available for AIX:

aix03 # lsdev -l cd0
cd0 Available  Virtual SCSI Optical Served by VIO Server
aix03 #

Since the device was not in use, this is not a problem. But of course it’s not nice to have devices in the kernel that no longer exist. After the next reboot of the LPAR, the device would have the status defined. We also delete the device in the LPAR:

aix03 # rmdev -dl cd0
cd0 deleted
aix03 #

The correct order would be to first remove the virtual CD device in the client LPAR from the operating system (for AIX: rmdev) and only then remove the virtual optical device on the virtual I/O server!

Next we remove the device vtopt0. The medium loaded there is mounted on the client LPAR (aix01). Again, we will first perform the necessary steps in the wrong order to see what happens. The command to remove the drive is successful:

$ vios rmvopt ms12-vio1 vtopt0
$

What happened to the mounted file system on the client LPAR (aix01)? We start an ls command on the LPAR:

aix01 # ls -l /cdrom/usr
/cdrom/usr/bin not found
/cdrom/usr/ccs not found
/cdrom/usr/lib not found
/cdrom/usr/lpp not found
/cdrom/usr/sbin not found
/cdrom/usr/share not found
/cdrom/usr/swlag not found
/cdrom/usr/sys not found
total 0
aix01 #

Access to the data on the virtual medium no longer works, of course!

So before removing the device on the Virtual-I/O server, we would have had to unmount the file system on the client LPAR first, then remove the virtual CD device in the LPAR and only then the virtual optical device on the virtual I/O server can be deleted!

We correct this by doing the umount command and removing the device with rmdev:

aix01 # umount /cdrom
aix01 # rmdev -dl cd0
cd0 deleted
aix01 #

When deleting the last virtual optical device, we now use the correct order of steps! The virtual optical device aix04_cd belongs to the LPAR aix04. We check on the client LPAR aix04 whether the virtual CD is in use:

aix04 # mount | grep cdrfs
         /dev/cd0         /cdrom           cdrfs  Feb 07 16:08 ro             
aix04 #

The virtual CD drive is in use. We stop using it by unmounting the filesystem:

aix04 # umount /cdrom
aix04 #

Next, we delete the cd0 device from the operating system:

aix04 # rmdev -dl cd0
cd0 deleted
aix04 #

Only now do we remove the virtual optical device on the virtual I/O server:

$ vios rmvopt ms12-vio1 aix04_cd
$