System Administration Guide, Volume I
この本のみを検索
PDF 文書ファイルをダウンロードする

Using CDs From the Command Line

13

This chapter describes all the tasks required to use CDs in the Solaris environment from the command line. This is a list of the step-by-step instructions in this chapter.
How to Load a CDpage 203
How to Examine the Contents of a CDpage 204
How to Copy Information From a CDpage 204
How to Find Out If a CD is Still in Usepage 206
How to Eject a CDpage 207
How to Access CDs on Other Systemspage 207
How to Make Local CDs Available to Other Systemspage 209
How to Configure a System to Play Musical CDspage 213
How to Prepare a System for a New CD-ROM Drivepage 214
How to Stop Volume Managementpage 215
How to Restart Volume Managementpage 215

Using CDs

Table 13-1 Task Map: How CDs Are Typically Used

Imported image(504x274)

Using CD Names

When working with CDs, you can identify them by name or with a designator from Table 13-2, below. For brevity, task descriptions use cdrom0, but you can replace it with either the CD name or a different designator.
Table 13-2
CDAlternate Name
First CD-ROM drivecdrom0
Second CD-ROM drivecdrom1
Third CD-ROM drivecdrom2

· How to Load a CD

Insert the CD. Shortly after the light stops flashing (about five to ten seconds), the CD is mounted to /cdrom. To verify that the CD is mounted, perform the task titled, "How to Examine the Contents of a CD," below.

Note - Most CDs are formatted to the ISO 9660 standard, which is portable, so most CDs can be mounted by Volume Management. However, as described in Chapter 16, "How Volume Management Works," UFS CDs are not portable between architectures, so they must be used on the architecture for which they were designed. If you are having trouble mounting a CD, particularly if it is an installation CD, make sure its UFS file system is appropriate for your system's architecture (check the label on the CD).

· How to Examine the Contents of a CD

Use the -L option to the ls command, because some directories under /floppy and /cdrom are symbolic links.

  $ ls -L [-l] /cdrom/cdrom0  

In this command,
-LIncludes symbolic links in the output.
-lLong format. Includes permissions and owners in the output.

Example--Examining the Contents of a CD

The following example lists the contents of the CD loaded into the first CD-ROM directory, /cdrom/cdrom0.

  $ ls -L -l /cdrom/cdrom0  
  dr-xr-xr-x   2  root   sys  2048  Dec 31  1993  tools  
  dr-xr-xr-x   2  root   sys  2048  Dec 31  1993  graphics  

· How to Copy Information From a CD

You can access a CD's files and directories just like any other file system. The only restrictions to be aware of 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.
  1. Make sure the CD is mounted.


  $ ls /cdrom  

The ls command displays the contents of a mounted CD. If no contents are displayed, see the task titled, "How to Load a CD" on page 203.
  1. Copy the files or directories.

To Copy ...Use ...
A filecp
A directorycp -r

Example--Copying Information From a CD

Following are two examples. The first example uses cp to copy a single file from the animals directory of cdrom0 into the system's working directory (denoted by the "."). The second example uses cp -r to copy the entire animals directory into the system's working directory. In both instances, the ls command is used to verify the copy operation.

  $ cp /cdrom/cdrom0/animals/dog.vec .  
  $ ls -l  
  -r-xr-xr-x   2  smith   sys  2048  Dec 31  1994  dog.vec  
  
  $ cp -r /cdrom/cdrom0/animals .  
  $ ls -l  
  dr-xr-xr-x   2  smith   sys  512   Dec 31  1994  animals  
  -r-xr-xr-x   2  smith   sys  2048  Dec 31  1994  dog.vec  

Note that when the CD file or directory is copied into your file system, you become its owner, but it retains the permissions it had on the CD:
-r-xr-xr-x

To overwrite it, you'll need to change the permissions with chmod.

· How to Find Out If a CD is Still in Use

  1. Become root.

  2. Enter the fuser command.

    The fuser command lists the processes that are currently accessing the CD that you specify.


  # fuser -u [-k] /cdrom/cdrom0  

In this command,
-uDisplays the user of the CD.
-kKills the process accessing the CD.

Example--Finding Out If a CD is Still in Use

In the following example, the processes 6400c and 6399c are accessing the /cdrom/cdrom0 directory, and the process owners are root and smith, respectively.

  # fuser -u /cdrom/cdrom0  
  /cdrom/cdrom0: 6400c(root)  6399c(smith)  

You can kill the processes individually (as root), or you can use the fuser command with the -k option, which kills all the processes accessing that file system, as shown in the following example.

  # fuser -u -k /cdrom/cdrom0  
  /cdrom/cdrom0: 6400c(root)Killed  6399c(smith)Killed  

The fuser command may not always identify all the killed processes. To be sure, run it again with the -u option.

· How to Eject a CD

  1. Make sure the CD is not being used.

    Remember, a CD 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 renegade shell hidden behind a desktop tool may be accessing it), use the fuser command, as described in "How to Find Out If a CD is Still in Use" on page 206.

  2. Eject the CD.


  $ eject cdrom0  

· How to Access CDs on Other Systems

You can access a CD on another system by mounting it manually into your file system--provided the other system has exported its CD-ROM according to the instructions in "How to Make Local CDs Available to Other Systems" on page 209.
  1. Select an existing directory to serve as the mount point or create one.


  $ mkdir directory  

In this command,
directory.......Is the name of the directory that you create to serve as a mount point for the other system's CD.
  1. Find the name of the CD you want to mount.

    When you manually mount a remote CD, you cannot use the cdrom0 or cdrom1 variables available with your local CDs. You must use the exact CD name. To find it, use the ls command on the remote system's /cdrom directory. If the automounter is running, you can simply cd to the system whose CD you want to mount and then use the ls command. If the automounter is not running, you'll have to use another method, such as logging in remotely.

  1. As root, mount the CD.


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

In this command,
system-nameIs the name of the system whose CD you will mount.
cd-nameIs the name of the CD you want to mount.
local-mount-pointIs the local directory onto which you will mount the remote CD.

Verification--Accessing CDs on Other Systems

To verify that the CD is indeed mounted, use the ls command to list the contents of the mount point.

  $ ls /cdrom  

Example--Accessing CDs on Other Systems

This example mounts the CD named Solaris_2.5_Install from the remote system mars onto the /cdrom directory of the local system.

  $ cd /net/mars  
  $ ls /cdrom  
  cdrom0     Solaris_2.5_Install  
  $ su  
  Password: password  
  # mount -F nfs ro mars:/cdrom/Solaris_2.5_Install /cdrom  
  # exit  
  $ ls /cdrom  
  Solaris_2.5_Install  

· How to Make Local CDs Available to Other Systems

You can configure your system to share its CD-ROM drives; in other words, make any CDs1 in those drives available to other systems. Once your CD-ROM drives are shared, other systems can access the CDs they contain simply by mounting them, as described in "How to Access CDs on Other Systems" on page 207.
  1. Become root.

  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.
  1. Select an option from the following table.

If ...Then ...
nfsd is runningGo to Step 8
nfsd is not runningContinue with Step 4
  1. Create a dummy directory for nfsd to share.


  # mkdir /dummy-dir  

In this command,
dummy-dir......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 CD-ROM.

1. Except musical CDs.
  1. Add the following entry into /etc/dfs/dfstab.


  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 CD-ROM drive. Note that the comment (preceded by -d) is optional.
  1. Start the NFS daemon.


  # /etc/init.d/nfs.server start  

  1. 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  

  1. Eject any CD currently in the drive.


  # eject cdrom0  

  1. Assign root write permissions to /etc/rmmount.conf.


  # chmod 644 /etc/rmmount.conf  

  1. Add the following lines to /etc/rmmount.conf.


  # File System Sharing  
  share cdrom*  

These lines share any CD 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).
  1. Remove write permissions from /etc/rmmount.conf.


  # chmod 444 /etc/rmmount.conf  

This step returns the file to its default permissions.
  1. Load a CD.

    The CD you now load, and all subsequent CDs, 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 CD, the remote user must mount it by name, according to the instructions in "How to Access CDs on Other Systems" on page 207.

Verification--Making Local CDs Available to Other Systems

To verify that the CD is indeed available to other systems, use the share command. If the CD 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"  
  -    /Solaris_2.5_Install  ro  ""  

Example--Making Local CDs Available to Other Systems

The following example makes any CD loaded into the local system's CD-ROM drive available to other systems on the network.

Imported image(391x382)

· How to Configure a System to Play Musical CDs

You can play musical CDs from a CD-ROM attached to your Solaris system. You'll need to access Workman, which is public domain software, and you must attach external speakers or headphones independently to the CD-ROM drive; speakers attached to the system hardware will not work.
Once you configure your system, you can play a musical CD simply by inserting it into the CD-ROM drive. The workman control panel is automatically displayed on your desktop.
  1. Become root.

  2. Edit /etc/rmmount.conf.

    Add the following line under # Actions, before the cdrom action, as shown in the example below.


  # Actions  
  action cdrom action_workman.so path/workman workman-options  

In this entry,
pathThe directory in which you have placed the Workman software
workman-optionsThe options allowed by the Workman software

Example--Configuring a System to Play Musical CDs

Imported image(498x192)

(1)

Default information for rmmount.conf file

(2) Workman line

· How to Prepare a System for a New CD-ROM Drive

On a system that is properly booted with the boot -r command, Volume Management will automatically recognize a new CD-ROM drive. However, to make sure Volume Management always recognizes a new drive, create the /reconfigure file.
  1. Become root.

  2. Create a file called /reconfigure.


  # touch /reconfigure  

The /reconfigure file makes the Solaris environment check for the presence of any newly installed peripheral devices when you power on or boot your system. After that, Volume Management locates the new device and automatically manages it for you.

Configuring Volume Management

Occasionally, you may want to manage diskettes or CDs without the help of Volume Management. This section describes how to stop and restart it.

· How to Stop Volume Management

  1. Make sure no diskettes or CDs are being used.

    If you are not sure whether you have found all users of the diskette or CD, use the fuser command, as described in "How to Find Out If a CD is Still in Use" on page 206.

  2. Become root.

  3. Enter the stop command.


  # /etc/init.d/volmgt stop  

· How to Restart Volume Management

  1. Become root.

  2. Enter the start command.


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