In a classical environment with IBM® AIX® logical partitions (LPARs), mounting or unmounting a CD requires administrator rights on the Virtual I/O Server (VIOS). It can be a very costly process if this operation has to be done frequently.
The aim of this article is to provide tools and methods for users, without administrator rights, to manage the CD/DVD mount and umount operations on an AIX LPAR.
Users might want to do such operations easily without external help (from system administrator or Help Desk). A simple procedure can help users to perform this basic operation.
The following example explains the global architecture, preliminary actions, and current operations.
- One Virtual I/O Server called VIOS on which the Virtual Media Library is created.
- One LPAR called LPAR1 on which the set of tools (scripts) are implemented
- Another LPAR called LPAR2, which is the target where the CD or the DVD is mounted.
LPAR1 and LPAR2 could be gathered in a single LPAR, but we prefer in our example to have two distinct LPARs one for tools, another to manage the CD/DVD.
Table 1 and Table 2 describe all the necessary steps to mount or unmount a CD/DVD. The steps can be manual or automatic.
Table 1. Steps to mount a CD/DVD
|1||Put an ISO CD file on the AIX server (LPAR1)||User + command (scp or ftp command) or the ISO file on the NFS share|
|2||Push the ISO file to the Virtual Media Library||User + mount_CD.ksh script|
|3||Perform an automatic virtualization process on the VIOS||Automatic process on the VIOS|
|4||Mount the CD on the AIX server (LPAR2)||User + mount command|
Table2. Steps to unmount a CD/DVD
|1||Unmount the CD on the AIX server (LPAR2)||User + umount command|
|2||Perform an automatic virtualization process on the VIOS||User + umount_CD.ksh script|
|3||Perform an automatic removal of the IOS CD file||Automatic process on the VIOS|
Before running the mount or unmount process, you must perform some preliminary actions:
- Create a tools account on the VIOS without administrator rights. The tools account belongs to the staff group.
- Create a Virtual Media Library on the VIOS and change the ownership of the Virtual Media Library to the tools account.
- Create a working directory on the VIOS.
- Create a tools account on the LPAR1 server.
- Create a Secure Shell (SSH) public key for the tools account on LPAR1 without passphrase and add it into the ~tools/.ssh/authorized_keys file on the VIOS.
- Create a virtual target for a file-backed virtual optical device.
Account creation on the VIOS as root user
Create a tools account without administrator rights on the VIOS.
Listing 1. Creating a user on VIOS
# mkuser id=301 pgrp=staff home=/home/tools shell=/bin/ksh tools
Virtual Media Library on the VIOS
For more information about creating a Virtual Media Library on a VIOS, refer to VIOLoadISo on the IBM developerWorks® wiki.
After you create the Virtual Media Library, change the ownership to the tools account and provide
rw permissions to the tools account and staff group.
Creating a working directory on the VIOS
A working directory is required on the VIOS. It contains flag files used by an automatic script.
Listing 2. Creating a working directory
# mkdir –p /var/tools/CDs # chown tools:staff /var/tools/CDs # chmod 775 /var/tools/CDs
Account creation on the LPAR1 server as root user
Listing 3. Creating a user on the LPAR1 server
# mkuser id=xxx pgrp=staff home=/home/tools shell=/bin/ksh tools
Where xxx is the user ID.
Create an SSH public key for the tools account on the LPAR1 server
This public key is added to the authorized_keys file of the VIOS tool account. Here, we used an empty passphrase.
Listing 4. SSH key creation
$ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/tools/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/tools/.ssh/id_dsa. Your public key has been saved in /home/tools/.ssh/id_dsa.pub. ….
On the VIOS, add this generated public key into the ~tools/.ssh/authorized_keys file. At this point on the LPAR1 server, the tools account is able to launch commands on the VIOS as tools account.
Create a virtual target for a file-backed virtual optical device
As a padmin user on the VIOS, use the
mkdev command to create your virtual optical device assigned to
Listing 5. Create virtual optical device
$ mkvdev -fbo -vadapter vhost# vtopt# Available
vhost# is the virtual Small Computer System Interface (VSCSI) device for the VIOS LPAR2 — you can check this with the
lsmap –all command. The
mkdev command creats the
vhost# and associated
vtopt#. These two name are used as parameters in scripts.
Four scripts, one on the VIOS and three on the LPAR1 server, need to be implemented.
One script on the VIOS is dedicated for the automatic process:
Three scripts on LPAR1 are the user's script:
On the VIOS, the mnt_CD.ksh script is scheduled for every minute and checks the flag files to perform the mount or unmount operations. This script also creates a report about the virtual optical device and the Virtual Media Library.
The mnt_CD.ksh script must be created in the padmin user's home directory. This script checks the existing flag files that are created in the /var/tools/CDs folder by the user's scripts from LPAR1.
|Flag file||Description||Action done by the script|
|ISO_file.mount||Contains the ISO file name to mount||Loads the virtual optical disk (ISO file) from the Virtual Medial Library into the virtual optical device|
|ISO_file.umount||Is the trigger for removing the virtual optical device||Removes a virtual optical media disk from a virtual optical device|
|ISO_file.remove||Contains the ISO file name to remove||Removes the corresponding ISO file name|
After each iteration, the script removes the existing flag file. A report is also produced by the script. You can find more details in the mount_CD.ksh script.
Some parameters inside the mnt_CD.ksh script must be set according to your local configuration.
Listing 6. mnt_CD.ksh script
$ ls -l /home/padmin/mnt_CD.ksh -rwxr-xr-x 1 padmin staff 1929 Sep 23 08:46 /home/padmin/mnt_CD.ksh
This script must be croned inside the root's crontab file.
Listing 7. Adding an new entry in the root's crontab file
#crontab –e Append the following entry : * * * * * su - padmin " -c mnt_CD.ksh " > /tmp/MNT_CD.log 2>&1 Save and close file.
From the LPAR1 server, the tools user is able to launch scripts to mount or unmount CDs. Three scripts are available:
|mount_CD.ksh||Copy or mount the ISO file|
|umount_CD.ksh||Unmount or delete the ISO file|
|check_CD.ksh||Display the report generated by the automatic script on the VIOS|
Before using the mount_CD.ksh or umount_CD.ksh scripts check your configuration with the check_CD.ksh script.
The check_CD.ksh script displays reports generated by the
periodic script on VIOS. The
-h option provides information about the usage. The syntax for the check_CD.ksh script is
This script generates a report from the VIO and displays it as a status. The report is divided into three parts:
The first part provides the results about the latest operation done by the periodic script. The second part provides the status about the virtual device that is mapped to LPAR2 (in particular, about the virtual optical device and its backing device), and the third part provides information about the Virtual Media Repository.
Example 1. check_CD.ksh output
INFO - : DATE: 09/28/11 TIME: 02:28:00 --> ========= Tasks done by script ======== INFO - : DATE: 09/28/11 TIME: 02:28:00 --> No CD to mount INFO - : DATE: 09/28/11 TIME: 02:28:00 --> No CD to umount INFO - : DATE: 09/28/11 TIME: 02:28:00 --> No Removal requested INFO - : DATE: 09/28/11 TIME: 02:28:00 --> =================== Vhost status =================================== SVSA Physloc Client Partition ID --------------- -------------------------------------------- ------------------ vhost9 U9117.MMA.10D8D22-V2-C44 0x00000010 …… …… VTD vtopt1 Status Available LUN 0x8400000000000000 Backing device /var/vio/VMLibrary/HACMP_5.4.1.iso Physloc INFO - : DATE: 09/28/11 TIME: 02:28:01 --> =================== CD Library list ================================ Size(mb) Free(mb) Parent Pool Parent Size Parent Free 16322 7456 lparvg 2856960 2049024 Name File Size Optical Access HACMP_5.4.1.iso 457 vtopt1 rw IBM_Installation_Toolkit_42.iso 1590 None rw TEST_Toolkit_42.iso 1590 None rw VIO21-1108.iso 67 None rw rhel_srv_56_ppc.iso 3680 vtopt0 rw
The mount_CD.ksh script is used to copy, if necessary, an ISO file on the Virtual Media Library and add it to the virtual optical device that is linked to the LPAR2 server. Scripts must be launched as the tools user. The following syntax applies:
mount_CD.ksh <-f <ISO file>> [-c] [-h]
The options are:
|-f <ISO file>||Indicates the ISO file to transfer and mount|
|-c||Indicates that the ISO file must be copied to the VIOS (inside the Virtual Media Library)|
Before mounting the CD, make sure that the backing device associated with the virtual optical device is free. Check it by using the check_CD.ksh script.
Example 2. Copying the MY_CD.iso file and mounting it
$ mount_CD.ksh –f MY_CD.iso –c
Example 3. Mounting an already copied ISO file on the LPAR1 server as the tools user
$ mount_CD.ksh –f MY_CD.iso
Wait for at least 1 minute to make sure that the ISO file is defined in the virtual optical device. Check this by using the check_CD.ksh script and the verification line about the backing device of the virtual optical device.
After making sure that everything is fine, you can mount the CD on the LPAR2 server with an appropriate mount command.
On the LPAR2 server, run the following command:
$ mount -o ro -v cdrfs /dev/cd# /mnt
/dev/cd# is the associated device to the virtual optical device on the VIOS.
umount_CD.ksh <-f <ISO file>> [-r [-h]
The umount_CD.ksh script is used to remove, if necessary, an ISO file in the Virtual Media Library and to free the backing device associated with the virtual optical device. Scripts must be launched as the tools user.
|-f <ISO file>||Indicates the ISO file to remove (inside the Virtual Media Library)|
|-r||Indicates that the ISO file must be removed (inside the Virtual Media Library)|
Before releasing the backing device, the CD must be unmounted from the LPAR2 server.
Example 4. Remove only an existing ISO file, MY_CD.iso
$ umount_CD.ksh -r MY_CD.iso
Check the results with the check_CD.ksh script and verify that the MY_CD.iso file does not exist in the Media Library List.
Example 5. Releasing the backing device for the virtual optical device
$ umount_CD.ksh –u
Check the results with the check_CD.ksh script and verify that the backing device is released.
In this article, we describe how to mount a CD/DVD on an LPAR without having any administrator rights on the VIOS. This example is not very complicated, as we have a separate LPAR (LPAR1 and LPAR2), but it is not mandatory. You can have only one LPAR or more than one targeted LPAR by improving the scripts. You can also improve the scripts to add more functionality. Nevertheless, the basis is described to offer this service.
Download shell scripts
- Refer to the following links for more information relating to virtual optical devices.
- The VIOS_Optical_Commands wiki gives information about the VIO server optical commands.
- The More on Virtual Optical Devices article describes the commands to manage virtual optical devices.
- Creating a Virtual Optical drive in a HMC-Managed VIOS Partition.
- Join the developerWorks community, a professional network and a unified set of community tools for connecting, sharing, and collaborating.