System Administration Guide: Devices and File Systems

Chapter 3 Accessing Removable Media (Tasks)

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

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)

The following task map describes the tasks for accessing removable media.

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.

How to Disable or Enable Removable Media Services

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. Find out if the media is still in use. 

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

How to Determine If Removable Media Is Still in Use

6. Eject the media. 

When you finish, eject the media from the drive. 

How to Eject Removable Media

Accessing Removable Media

You can access information on removable media with or without using volume management. For information on accessing information on removable media with GNOME's File Manager, see the GNOME desktop documentation.

Volume management (vold) actively manages all removable media devices. So, 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 3–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

USB memory stick 

/rmdisk/noname

/vol/dev/aliases/rmdisk0

/vol/dev/dsk/cntndn/volume-name:c

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 generally applies to diskettes. However, some architectures share the same bit structure, so occasionally a UFS format specific to one architecture will be recognized by another architecture. Still, 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. Slices 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 that its UFS file system is appropriate for your system's architecture. For example, you can check the label on the CD or DVD.

ProcedureHow to Add a New Removable Media Drive

Generally, most modern bus types support hot-plugging. If your system's bus type supports hot-plugging, you might only need to do step 5 below. If your system's bus type does not support hot-plugging, you might have to do the following tasks, which are described in steps 1-6 below.

For more information about hot-plugging devices, see Chapter 6, Dynamically Configuring Devices (Tasks).

  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 automatically comes up to multiuser mode.

ProcedureHow to Disable or Enable Removable Media Services

Occasionally, you might want to manage media without using removable media services. This section describes how to disable and enable removable media services.

Disabling these services means that you would have to mount all media manually by using the mount command.

  1. Ensure that the media is not being used.

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

  2. Become superuser.

  3. Select one of the following:

    • Disable removable media services.


      # svcadm disable volfs
      
    • Enable removable media services.


      # svcadm enable volfs
      volume management starting.

ProcedureHow to Access Information on Removable Media

  1. Insert the media.

    The media is mounted after a few seconds.

  2. List the contents of the media.


    % ls /media
    

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


Example 3–1 Accessing Information on Removable Media

This example shows how to access information on a diskette.


$ ls /floppy
myfile

This example shows how to access information on a USB memory stick.


$ ls /rmdisk
rmdisk0/		rmdisk1/

This example shows how to access information on a DVD.


$ ls /cdrom
cdrom0             sol_10_910_sparc

ProcedureHow to Copy Information From Removable Media

You can access files and directories on removable media as with any other file system. The only significant restrictions are related to ownership and permissions.

For instance, if you copy a file from a DVD into your file system, you are the owner. However, you won't have write permissions because the file on the DVD never had them. You must change the permissions yourself.

  1. Ensure that 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 DVD, you would do the following:


    $ cp /cdrom/sol_10_910_sparc/Solaris_10/Tools/add_install_client .
    $ ls -l
    -rwxr-xr-x   1 pmorph	  gelfs   64065 Jul 12  2010 add_install_client

ProcedureHow to Determine If Removable Media Is Still in Use

  1. Become superuser.

  2. Identify the processes that are accessing the media.


    # fuser -u /media
    

    The -u displays the user of the media.

    For more information, see fuser(1M).

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


    # fuser -u -k /media
    

    The -k kills the processes accessing the media.


    Caution – Caution –

    Killing the processes that are accessing the media should only be used in emergency situations.


  4. Verify that the process is gone.


    # pgrep process-ID
    

Example 3–2 Determining If the Media Is Still in Use

The following example shows that the user pmorph, is accessing the /cdrom/sol_10_910_sparc/Solaris_10/Tools directory.


# fuser -u /cdrom/sol_10_910_sparc/Solaris_10/Tools
/cdrom/sol_910_sparc/Solaris_10/Tools:      902c(pmorph)     339c(pmorph)

ProcedureHow to Eject Removable Media

  1. Ensure that 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 DVD (for example, a shell hidden behind a desktop tool might be accessing it), use the fuser command. See How to Determine If Removable Media Is Still in Use.

  2. Eject the media.


    # eject media
    

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


    # eject cdrom
    

    For example, for a USB memory stick, you would do the following:


    # eject rmdisk0
    

    Tip –

    You can view the removable device name with the eject -l command.


Accessing Removable Media on a Remote System (Task Map)

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

Task 

Description 

For Instructions 

1. Make local media available to remote systems. 

configure your system to share its media drives to make any media in those drives available to other systems. 

How to Make Local Media Available to Other Systems

2. Access removable media on remote systems. 

Access the remote media on the local system. 

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. One exception is musical CDs. Once your media drives are shared, other systems can access the media they contain simply by mounting them. For instructions, see How to Access Removable Media on Remote Systems.

  1. Become superuser.

  2. Confirm that the media is loaded.

  3. Add the following entry to the /etc/dfs/dfstab file.

    For example:


    share -F nfs -o ro /cdrom/sol_10_910_sparc
  4. Determine whether the NFS server service is running.


    # svcs *nfs*
    

    The following output is returned from the svcs command if NFS server service is running:


    online         14:28:43 svc:/network/nfs/server:default
  5. Identify the NFS server status, and select one of the following:

    • If the NFS server service is running, go to Step 7.

    • If the NFS server service is not running, go to the next step.

  6. Start the NFS server service.


    # svcadm enable network/nfs/server
    

    Verify that the NFS daemons are running.

    For example:


    # svcs -p svc:/network/nfs/server:default
    STATE          STIME    FMRI
    online         Aug_30   svc:/network/nfs/server:default
                   Aug_30        319 mountd
                   Aug_30        323 nfsd
  7. Verify that the media is indeed available to other systems.

    If the media is available, its share configuration is displayed.


    # share
    -               /cdrom/sol_10_910_sparc   ro   ""  

Example 3–3 Making Local DVDs or CDs Available to Other Systems

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


# vi /etc/dfs/dfstab
(Add the following line:)
# share -F nfs -o ro /media
# svcs *nfs*
# svcadm enable network/nfs/server
# svcs -p svc:/network/nfs/server:default
# share
-               /cdrom/sol_10_910_sparc   ro   ""


Example 3–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.


# vi /etc/dfs/dfstab
(Add the following line, for example)
share -F nfs -o ro /floppy/myfiles
# svcs *nfs*
# svcadm enable network/nfs/server
# svcs -p svc:/network/nfs/server:default
# volcheck -v
media was found
# share
-               /floppy/myfiles   rw   ""  

ProcedureHow to Access Removable Media on Remote Systems

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

  1. Select an existing directory to serve as the mount point. Or create a mount point.


    $ mkdir /directory
    

    where /directory is the name of the directory that you create to serve as a mount point for the remote system's DVD.

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


    $ showmount -e system-name
    
  3. As superuser, mount the media.


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

    Is the name of the system whose media you will mount.

    media-name

    Is the name of the media you want to mount.

    local-mount-point

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

  4. Log out as superuser.

  5. Verify that the media has been mounted.


    $ ls /media
    

Example 3–5 Accessing DVDs or CDs on Remote Systems

The following example shows how to automatically access the remote DVD named sol_10_910_sparc from the remote system starbug using autofs.


% showmount -e starbug
export list for starbug:
/cdrom/sol_10_910_sparc (everyone)
$ /net/starbug/cdrom/sol_10_910_sparc


Example 3–6 Accessing Diskettes on Other Systems

The following example shows how to automatically access myfiles from the remote system mars using autofs.


$ showmount -e mars
$ cd /net/mars
$ ls /floppy
floppy0     myfiles