System Administration Guide: Devices and File Systems

Chapter 2 Accessing Removable Media (Tasks)

This chapter describes how to access removable media from the command line in the Solaris environment.

For information on the procedures associated with accessing removable media, see the following:

For background information on removable media, see Chapter 1, Managing Removable Media (Overview).

Accessing Removable Media (Task Map)

Task 

Description 

For Instructions 

1. (Optional) Add the removable media drive 

Add the removable media drive to your system, if necessary. 

How to Add a New Removable Media Drive

2. (Optional) Decide whether you want to use removable media with or without volume management (vold)

Volume management (vold) runs by default. Decide whether you want to use removable media with or without volume management.

Stopping and Starting Volume Management (vold)

3. Access removable media 

Access different kinds of removable media with or without volume management running. 

How to Access Information on Removable Media

4. (Optional) Copy files or directories 

Copy files or directories from the media as you would from any other location in the file system.  

How to Copy Information From Removable Media

5. (Optional) Configure a system to play musical CDs or DVDs 

You can configure a system to play musical CDs or DVDs, but you will need third-party software to play the media. 

How to Play a Musical CD or DVD

6. Find out if the media still in use 

Before ejecting the media, find out if it is still in use. 

How to Find Out If Removable Media Is Still in Use

7. Eject the Media 

When you finish, eject the media from the drive. 

How to Eject Removable Media

Accessing Removable Media (Overview)

You can access information on removable media with or without using volume manager. For information on accessing information on removable media with CDE's File Manager, see Using Removable Media with File Manager in Solaris Common Desktop Environment: User’s Guide.

Starting in the Solaris 8 6/00 release, volume manager (vold) actively manages all removable media devices. This means any attempt to access removable media with device names such as /dev/rdsk/cntndnsn or /dev/dsk/cntndnsn will be unsuccessful.

Using Removable Media Names

You can access all removable media with different names. The following table describes the different media names that can be accessed with or without volume management.

Table 2–1 Removable Media Names

Media 

Volume Management Device Name 

Volume Management Device Alias Name 

Device Name 

First diskette drive 

/floppy

/vol/dev/aliases/floppy0

/dev/rdiskette

/vol/dev/rdiskette0/

volume-name

First, second, third CD-ROM or DVD-ROM drives 

/cdrom0

/cdrom1

/cdrom2

/vol/dev/aliases/cdrom0

/vol/dev/aliases/cdrom1

/vol/dev/aliases/cdrom2

/vol/dev/rdsk/cntn[dn]/

volume-name

First, second, third Jaz drive 

/rmdisk/jaz0

/rmdisk/jaz1

/rmdisk/jaz2

/vol/dev/aliases/jaz0

/vol/dev/aliases/jaz1

/vol/dev/aliases/jaz2

/vol/dev/rdsk/cntndn/

volume-name

First, second, third Zip drive 

/rmdisk/zip0

/rmdisk/zip1

/rmdisk/zip2

/vol/dev/aliases/zip0

/vol/dev/aliases/zip1

/vol/dev/aliases/zip2

/vol/dev/rdsk/cntndn/

volume-name

First, second, third, PCMCIA drive 

/pcmem/pcmem0

/pcmem/pcmem1

/pcmem/pcmem2

/vol/dev/aliases/pcmem0

/vol/dev/aliases/pcmem1

/vol/dev/aliases/pcmem2

/vol/dev/rdsk/cntndn/

volume-name

Use this table to identify which removable media name to use with specific Solaris commands.

Solaris Command 

Device Name 

Usage Examples 

ls, more, vi

/floppy

/cdrom

/rmdisk/zip0

/rmdisk/jaz0

/pcmem/pcmem0

ls /floppy/myfiles/

more /cdrom/myfiles/filea

fsck, newfs, mkfs

/vol/dev/aliases/floppy0

/vol/dev/rdsk/cntndn

newfs /vol/dev/aliases/floppy0

mkfs -F udfs /vol/dev/rdsk/cntndn

Guidelines for Accessing Removable Media Data

Most CDs and DVDs are formatted to the ISO 9660 standard, which is portable, so most CDs and DVDs can be mounted by volume management. However, CDs or DVDs with UFS file systems are not portable between architectures, so they must be used on the architecture for which they were designed.

For example, a CD or DVD with a UFS file system for a SPARC platform cannot be recognized by an x86 platform. Likewise, an x86 UFS CD cannot be mounted by volume management on a SPARC platform. The same limitation applies to diskettes. (Actually, some architectures share the same bit structure, so occasionally a UFS format specific to one architecture will be recognized by another architecture, but the UFS file system structure was not designed to guarantee this compatibility).

To accommodate the different formats, the CD or DVD is split into slices, which are similar in effect to partitions on hard disks. The 9660 portion is portable, but the UFS portion is architecture-specific. If you are having trouble mounting a CD or DVD, particularly if it is an installation CD or DVD, make sure its UFS file system is appropriate for your system's architecture (check the label on the CD or DVD).

Accessing Jaz Drives or Zip Drives

You can determine whether accessing your Jaz or Zip drives changes from previous Solaris releases, depending on the following:

ProcedureHow to Add a New Removable Media Drive

Adding a new removable media drive involves creating the /reconfigure file and rebooting the system so that volume management recognizes the new media drive.

Steps
  1. Become superuser.

  2. Create the /reconfigure file.


    # touch /reconfigure
    
  3. Bring the system to run level 0.


    # init 0
    
  4. Turn off power to the system.

  5. Connect the new media drive.

    See your hardware handbook for specific instructions.

  6. Turn on power to the system.

    The system comes up to multiuser mode automatically.

Stopping and Starting Volume Management (vold)

Occasionally, you might want to manage media without the help of volume management. This section describes how to stop and restart volume management.

ProcedureHow to Stop Volume Management (vold)

Steps
  1. Make sure media is not being used.

    If you are not sure whether you have found all users of the media, use the fuser command, as described in How to Find Out If Removable Media Is Still in Use.

  2. Become superuser.

  3. Enter the volmgt stop command.


    # /etc/init.d/volmgt stop
    #

ProcedureHow to Restart Volume Management (vold)

Steps
  1. Become superuser.

  2. Enter the volmgt start command.


    # /etc/init.d/volmgt start
    volume management starting.

ProcedureHow to Access Information on Removable Media

Steps
  1. Insert the media.

    The media is mounted after a few seconds.

  2. Check for media in the drive.


    % volcheck
    

    Use the appropriate device name to access information by using the command-line interface. See Table 2–1 for an explanation of device names.

  3. List the contents of the media.


    % ls /media
    

Example 2–1 Accessing Information on Removable Media

Access information on a diskette as follows:


$ volcheck
$ ls /floppy
myfile

Access information on a Jaz drive as follows:


$ volcheck
$ ls /rmdisk
jaz0/		jaz1/

Access information on a CD-ROM as follows:


$ volcheck
$ ls /cdrom
cdrom0@        solaris_9_sparc

View the symbolic links on a CD-ROM as follows:


$ ls -lL /cdrom/cdrom0
total 24
dr-xr-xr-x   2 root     sys         2048 Dec  3 11:54 s0/
drwxr-xr-x  18 root     root         512 Dec  3 13:09 s1/
drwxr-xr-x   2 root     root         512 Dec  3 13:10 s2/
drwxr-xr-x   2 root     root         512 Dec  3 13:10 s3/
drwxr-xr-x   2 root     root         512 Dec  3 13:10 s4/
drwxr-xr-x   2 root     root         512 Dec  3 13:10 s5/

Access information on a PCMCIA memory card as follows


$ ls /pcmem/pcmem0
pcmem0 myfiles

ProcedureHow to Copy Information From Removable Media

You can access files and directories on removable media just like any other file system. The only significant restrictions are ownership and permissions.

For instance, if you copy a file from a CD into your file system, you'll be the owner, but you won't have write permissions (because the file never had them on the CD). You'll have to change the permissions yourself.

Steps
  1. Make sure the media is mounted.


    $ ls /media
    

    The ls command displays the contents of a mounted media. If no contents are displayed, see How to Access Information on Removable Media.

  2. (Optional) Copy the files or directories.

    For example, for a CD, you would do the following:


    $ cp /cdrom/sol_9_1202_sparc/s0/Solaris_9/Tools/add_install_client .
    $ ls -l
    -rwxr-xr-x   1 pmorph	gelfs    59586 Jan 16  2004 add_install_client*

    For example, for a PCMCIA memory card, you would do the following:


    $ cp /pcmem/pcmem0/readme2.doc .
    $ cp -r /pcmem/pcmem0/morefiles .
    

ProcedureHow to Play a Musical CD or DVD

To play musical media from a media drive attached to a system running the Solaris release, you'll need to access public domain software, such as xmcd, that is available from the following locations:

Keep the following in mind when using the xmcd software with CDDA (CD Digital Audio) support to play musical media:

Consider the following issues as well:

Once you install the xmcd software, you can play a musical CD simply by inserting it into the CD-ROM drive and starting the xmcd control panel.

Steps
  1. Install the xmcd software.

  2. Insert the media into the media drive.

  3. Invoke the xmcd command.


    % ./xmcd &
    

ProcedureHow to Find Out If Removable Media Is Still in Use

Steps
  1. Become superuser.

  2. Identify the processes accessing the media.


    # fuser -u [-k] /media
    
    -u

    Displays the user of the media.

    -k

    Kills the process accessing the media.

    For more information on using the fuser command, see fuser(1M).

  3. (Optional) Kill the process accessing the media.


    # fuser -u -k /media
    

    Caution – Caution –

    Killing the process accessing the media should only be used in emergency situations.


  4. Verify the process is gone.


    # pgrep process-ID
    

Example 2–2 Finding Out If the Media Is Still in Use

The following example shows that the process 26230c, owner pmorph, is accessing the /cdrom/sol_9_1202_sparc/s0/Solaris_9/Tools/ directory.


# fuser -u /cdrom/sol_9_1202_sparc/s0/Solaris_9/Tools/
/cdrom/sol_9_1202_sparc/s0/Solaris_9/Tools/:     7258c(pmorph) 

ProcedureHow to Eject Removable Media

Steps
  1. Make sure the media is not being used.

    Remember, media is “being used” if a shell or an application is accessing any of its files or directories. If you are not sure whether you have found all users of a CD (a shell hidden behind a desktop tool might be accessing it), use the fuser command, as described in How to Find Out If Removable Media Is Still in Use.

  2. Eject the media.


    # eject media
    

    For example, for a CD, you would do the following


    # eject cdrom
    

    For example, for a PCMCIA memory card, you would do the following:


    # eject pcmem0
    

Accessing Removable Media on a Remote System (Task Map)

The following table describes the tasks need to access removable media on a remote system.

Task 

Description 

For Instructions 

1. Make local media available to remote systems 

Add the removable media drive to your system, if necessary. 

How to Make Local Media Available to Other Systems

2. Access removable media on remote systems 

Insert the media into the drive.  

How to Access Information on Removable Media

ProcedureHow to Make Local Media Available to Other Systems

You can configure your system to share its media drives to make any media in those drives available to other systems. (This does not apply to musical CDs.) Once your media drives are shared, other systems can access the media they contain simply by mounting them, as described in How to Access Removable Media on Remote Systems.

Steps
  1. Become superuser.

  2. Find out whether the NFS daemon (nfsd) is running.


    # ps -ef | grep nfsd
    root 14533    1 17 10:46:55 ?     0:00 /usr/lib/nfs/nfsd -a 16
    root 14656  289  7 14:06:02 pts/3 0:00 grep nfsd

    If the daemon is running, a line for /usr/lib/nfs/nfsd will appear, as shown above. If the daemon is not running, only the grep nfsd line will appear.

  3. Identify the nfsd status and select one of the following:

    1. If nfsd is running, go to Step 8.

    2. If nfsd is not running, continue with Step 4.

  4. Create a dummy directory for nfsd to share.


    # mkdir / dummy-dir
    

    The dummy-dir mount point can be any directory name. For example, dummy. This directory will not contain any files. Its only purpose is to “wake up” the NFS daemon so that it notices your shared media drive.

  5. Add the following entry into the /etc/dfs/dfstab file.


    share -F nfs -o ro [-d comment] /dummy-dir
    

    When you start the NFS daemon, it will see this entry, “wake up,” and notice the shared media drive. Note that the comment (preceded by -d) is optional.

  6. Start the NFS daemon.


    # /etc/init.d/nfs.server start
    
  7. Verify that the NFS daemon is indeed running.


    # ps -ef | grep nfsd
    root 14533    1 17 10:46:55 ?     0:00 /usr/lib/nfs/nfsd -a 16
    root 14656  289  7 14:06:02 pts/3 0:00 /grep nfsd
  8. Eject any media currently in the drive.


    # eject media
    
  9. Assign root write permissions to the /etc/rmmount.conf file.


    # chmod 644 /etc/rmmount.conf
    
  10. Add the following lines to the /etc/rmmount.conf file.


    # File System Sharing
    share media*

    These lines share any media loaded into your system's CD-ROM drive. You can, however, limit sharing to a particular CD or series of CDs, as described in share(1M).

  11. Remove write permissions from the /etc/rmmount.conf file.


    # chmod 444 /etc/rmmount.conf
    

    This step returns the file to its default permissions.

  12. Load the media.

    The media you now load, and all subsequent media, will be available to other systems. Remember to wait until the light on the drive stops blinking before you verify this task.

    To access the media, the remote user must mount it by name, according to the instructions in How to Access Removable Media on Remote Systems.

  13. Verify that the media is indeed available to other systems by using the share command.

    If the media is available, its share configuration will be displayed. (The shared dummy directory will also be displayed.)


    # share
    -    /dummy  ro "dummy dir to wake up NFS daemon"
    -    /cdrom/sol_9_1202_sparc/s5   ro   ""  
    -    /cdrom/sol_9_1202_sparc/s4   ro   ""  
    -    /cdrom/sol_9_1202_sparc/s3   ro   ""  
    -    /cdrom/sol_9_1202_sparc/s2   ro   ""  
    -    /cdrom/sol_9_1202_sparc/s1   ro   ""  
    -    /cdrom/sol_9_1202_sparc/s0   ro   ""  

Example 2–3 Making Local CDs Available to Other Systems

The following example shows how to make any local CD available to other systems on the network.


# ps -ef | grep nfsd
    root 10127  9986  0 08:25:01 pts/2    0:00 grep nfsd
    root 10118     1  0 08:24:39 ?        0:00 /usr/lib/nfs/nfsd -a
# mkdir /dummy
# vi /etc/dfs/dfstab
(Add the following line:)
 share -F nfs -o ro  /dummy
# eject cdrom0
# chmod 644 /etc/rmmount.conf
# vi /etc/rmmount.conf
(Add the following line to the File System Sharing section:)
 share cdrom*
# chmod 444 /etc/rmmount.conf
(Load a CD.)
# share
-               /dummy   ro   ""  
-               /cdrom/sol_9_1202_sparc/s5   ro   ""  
-               /cdrom/sol_9_1202_sparc/s4   ro   ""  
-               /cdrom/sol_9_1202_sparc/s3   ro   ""  
-               /cdrom/sol_9_1202_sparc/s2   ro   ""  
-               /cdrom/sol_9_1202_sparc/s1   ro   ""  
-               /cdrom/sol_9_1202_sparc/s0   ro   ""  


Example 2–4 Making Local Diskettes Available to Other Systems

The following example shows how to make any local diskette available to other systems on the network.


# ps -ef | grep nfsd
    root 10127  9986  0 08:25:01 pts/2    0:00 grep nfsd
    root 10118     1  0 08:24:39 ?        0:00 /usr/lib/nfs/nfsd -a
# mkdir /dummy
# vi /etc/dfs/dfstab
(Add the following line:)
share -F nfs -o ro  /dummy
# eject floppy0
# chmod 644 /etc/rmmount.conf
# vi /etc/rmmount.conf
(Add the following line to the File System Sharing section.)
share floppy*
# chmod 444 /etc/rmmount.conf
(Load a diskette.)
# volcheck -v
media was found
# share
-               /dummy   ro   ""  
-               /floppy/myfiles   rw   ""  


Example 2–5 Making Local PCMCIA Memory Cards Available to Other Systems

The following example shows how to make any local PCMCIA memory card available to other systems on the network.


# ps -ef | grep nfsd
    root 10127  9986  0 08:25:01 pts/2    0:00 grep nfsd
    root 10118     1  0 08:24:39 ?        0:00 /usr/lib/nfs/nfsd -a
# mkdir /dummy
# vi /etc/dfs/dfstab
(Add the following line:)
share -F nfs -o ro  /dummy
# eject pcmem0
# chmod 644 /etc/rmmount.conf
# vi /etc/rmmount.conf
(Add the following line to the File System Sharing section:)
share floppy*
# chmod 444 /etc/rmmount.conf
(Load a PCMCIA memory card.)
# volcheck -v
media was found
# share
-               /dummy   ro   ""  
-               /pcmem/myfiles   rw   ""  

ProcedureHow to Access Removable Media on Remote Systems

You can access media on a remote system by mounting it manually into your file system, provided the other system has shared its media according to the instructions in How to Make Local Media Available to Other Systems.

Steps
  1. Select an existing directory to serve as the mount point or create one.


    $ mkdir directory
    

    directory is the name of the directory that you create to serve as a mount point for the other system's CD.

  2. Find the name of the media you want to mount.


    $ showmount -e system-name
    

    For example:


    export list for starbug:
    /dummy                     (everyone)
    /cdrom/sol_9_1202_sparc/s5 (everyone)
    /cdrom/sol_9_1202_sparc/s4 (everyone)
    /cdrom/sol_9_1202_sparc/s3 (everyone)
    /cdrom/sol_9_1202_sparc/s2 (everyone)
    /cdrom/sol_9_1202_sparc/s1 (everyone)
    /cdrom/sol_9_1202_sparc/s0 (everyone)

    As superuser, mount the media.


    # mount -F nfs -o ro system-name:/media/media-name local-mount-point
    
    system-name

    The name of the system whose media you will mount.

    media-name

    The name of the media you want to mount.

    local-mount-point

    The local directory onto which you will mount the remote media.

  3. Log out as superuser.

  4. Verify that the media is mounted.


    $ ls /media
    

Example 2–6 Accessing CDs on Other Systems

The following example shows how to mount the CD named sol_9_1202_sparc from the remote system starbug onto the /mnt directory of the local system.


$ showmount -e starbug
export list for starbug:
/dummy                     (everyone)
/cdrom/sol_9_1202_sparc/s5 (everyone)
/cdrom/sol_9_1202_sparc/s4 (everyone)
/cdrom/sol_9_1202_sparc/s3 (everyone)
/cdrom/sol_9_1202_sparc/s2 (everyone)
/cdrom/sol_9_1202_sparc/s1 (everyone)
/cdrom/sol_9_1202_sparc/s0 (everyone)
$ su
Password: password
# mount -F nfs -o ro starbug:/cdrom/sol_9_1202_sparc/s0 /mnt
# exit
$ ls /mnt
Copyright  Solaris_9 


Example 2–7 Accessing Diskettes on Other Systems

The following example shows how to mount the diskette named myfiles from the remote system mars onto the /floppy directory of the local system.


$ cd /net/mars
$ ls /floppy
floppy0     myfiles
$ su
Password: password
# mount -F nfs mars:/floppy/myfiles /floppy
# exit
$ ls /floppy
myfiles


Example 2–8 Accessing PCMCIA Memory Cards on Other Systems

The following example shows how to mount the PCMCIA memory card named myfiles from the remote system mars onto the /pcmem directory of the local system.


$ cd /net/mars
$ ls /pcmem
pcmem0     myfiles
$ su
Password: password
# mount -F nfs mars:/pcmem/myfiles /pcmem
# exit
$ ls /pcmem
myfiles