mstor Special File

Purpose

Provides access to the virtual removable disk device.

Description

The mstor special file provides block and character (raw) access to the virtual removable disk devices, which are backed by the Universal Serial Bus (USB) mass storage devices (such as RDX, flash drives, and storage devices) on the Virtual I/O Server (VIOS). The capability of the AIX® operating system to read from and write to the virtual removable disk drives is validated against the IBM® RDX and a sample of industry standard original equipment manufacturer (OEM) USB flash drives is used as backing store on VIOS.

Note: The AIX Small Computer System Interface (SCSI) disk driver supports virtual removable disks on the AIX Version 6.1 with Technology Level 6100-09, and later, and on the AIX Version 7.1 with Technology Level 7100-03, and later.

The backing USB mass storage devices can be exported to only one client at a time. If the user wants to export the backing device to another client, the virtual removable disk device must be removed from the old client by using the rmdev command and then, the backing device must be remapped to the new client on the VIOS.

The virtual removable disk drivers are configured by using the logical names, such as mstor0 and mstor1 . The driver presents both raw and blocks special files. For example, the raw special file for the mstor0 file is /dev/rmstor0 file, and the block special file is /dev/mstor0. To install raw I/O on a virtual removable disk, all data transfers in multiples of block length (512 bytes) the virtual removable disk device is required. Also, all the lseek subroutines made to the virtual removable disk device driver must set the file offset pointer to a value that is a multiple of the specified logical block size.

A virtual removable disk device cannot be used with the AIX Logical Volume Manager (LVM) or the AIX Journaled File System (JFS) or JFS2 file systems. A virtual removable disk device can be used with the User-defined file system (UDFS) file system, with backup commands, such as tar and the savevg commands, and with media access commands, such as the dd command. The user can also create a mksysb image on the device and can start and install from the device. It can be used as a memory dump device on the AIX operating system.

The virtual removable disk device is dependent on the device or media that is connected and available on the VIOS. When the backing USB disk device is disconnected from the VIOS while the device is still in use on the AIX client, the device becomes unavailable on the client. On reconnecting the USB device to VIOS, the device must be remapped by removing the older mapping and then creating a new mapping, running the cfgmgr command on the AIX client to make the device available again on client. This task can be accomplished by running the following commands:

On Virtual I/O Server
  1. To get the current mapping, run the following command:
    lsmap -all
  2. To remove the current mapping, run the following command:
    rmvdev -vtd VTD of the device from lsmap
  3. To create the new mapping, run the following command:
    mkvdev -vdev usb device -vadapter virtual adapter name
On an AIX client
cfgmgr

The removable disk devices defines a prevent_eject attribute, which has a default value of yes and can be changed by using the System Management Interface Tool (SMIT) interface or the chdev command. If a user sets the value of the prevent_eject attribute as yes, it causes a Media Eject Prevent and Media Eject Allow action while opening and closing of the device. This operation is only applicable if the backing device has ejectable media and this operation is not supported for flash drives.

If the backing device has ejectable media and the prevent_eject attribute is set to no, and the media is ejected from the drive for an exported UDFS file system, the files on the disk cartridge cannot be accessed. To access these files again, the file systems that are mounted from the virtual removable disk drive must be unmounted. The processes that have files in an open state on these file systems must be exited. The processes that have current directories on these file systems must be moved. If these actions fail, perform a forced unmount operation.

Device-Dependent Subroutines

Most virtual disk device operations are implemented by using the open, read, and close subroutines. However, for some purposes, the openx (extended) subroutine must be used..
Subroutines Description
ioctl Subroutine The virtual removable disk device uses SCSI disk device driver for its operation. It supports ioctls operations which are supported by the SCSI disk driver, such as the IOCINFO, DKIOLCMD, DK_PASSTHRU, DKPMR, DKAMR, and DKEJECT operations.
openx Subroutine The openx subroutine is supported to provide more functions to the open sequence. The openx subroutine requires appropriate authority to start. If you attempt to run this subroutine without the access right might results in a return value of -1, with the errno global variable is set to EPERM.

Error Codes

In addition to the error codes listed for the ioctl, open, read, and write subroutines. The following error codes are also supported:
Error code Description
EACCES A subroutine other than ioctl or close was attempted while in diagnostic mode.
EACCES A normal read call was attempted while in diagnostic mode.
EFAULT An incorrect user address.
EBUSY The target device is reserved by another initiator.
EINVAL A nbyte parameter of a read subroutine is not an even multiple of the block size.
EINVAL An attempt was made to configure a device that is still open.
EINVAL An incorrect configuration command is entered.
EMFILE An open call is attempted for a SCSI adapter that already has the maximum permissible number of open devices.
ENOTREADY There is no cartridge in the drive that is attached to VIOS.
ENODEV An attempt was made to access a device that is not defined.
ENODEV An attempt was made to close a device that is not defined.
EMEDIA The media was changed.
EIO A hardware error, an aborted command, invalid request.
EIO An attempt is made to read beyond the end of media.
EPERM The subroutine requires appropriate authority.
ESTALE The media was ejected (without first being closed by the user) and then either reinserted or replaced with a second disk.
ETIMEDOUT An I/O operation exceeded the specified timer value.