📄 lsg09.htm
字号:
<BR><B>By default most Linux versions include four Sound Blaster-type CD-ROM </B><B>device drivers.</A></B>
<BR>
<P><A NAME="I2"></A>If you use more than one controller for these types of CD-ROM drives, you must create a new major device number (26, 27, and so on) for each controller. Few Linux installations will have more than one CD-ROM drive, let alone more than one controller for multiple CD-ROM drives. In case you're curious, the commands to create a second controller card with two CD-ROM drives of the same type attached are
<BR>
<PRE>
<FONT COLOR="#000080">mknod /dev/sbpcd0 b 26 0
mknod /dev/sbpcd1 b 26 1</FONT></PRE>
<P>A device file for a Sony CD-ROM drive is usually created with the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">mknod /dev/cdu31a b 15 0</FONT></PRE>
<P>which uses the device file /dev/cdu31a (based on the most common Sony CD-ROM drive model, the CDU31A or CDU33A) and has a major device number of 15. Additional CD-ROM drives of the same type would have incrementing minor device numbers. Sony CDU535 and CDU531 CD-ROM drives use a different device driver:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">mknod /dev/cdu535 b 24 0</FONT></PRE>
<P>This driver corresponds to the features these models offer.
<BR>
<P>Mitsumi CD-ROM drives (also popular in multimedia packages) are supported with the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">mknod /dev/mcd b 23 0</FONT></PRE>
<P>which lists the device file /dev/mcd and a major device number of 23. Minor device numbers increment if more than one CD-ROM drive of the same type is used.
<BR>
<P>If you are supporting two different models of CD-ROM drives on the same system (off two different cards), you must create two device files, one for each drive. For example, if you were running both a Mitsumi and Sony drive, you would issue the commands shown previously for the two drives. Because the major and minor device numbers as well as the device files are different, having two drives poses no problems to Linux.
<BR>
<P>Once you have created the device files with the mknod command, link the new device driver to the file /dev/cdrom to make the CD-ROM drive easier to access (and the device driver file easier to remember). You can then call the file /dev/cdrom instead of the more complex device file. For example, to link a Mitsumi device file to /dev/cdrom, issue the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">ln -s /dev/mcd /dev/cdrom</FONT></PRE>
<P>Then all references to /dev/cdrom apply to /dev/mcd. Substitute the name of the device driver you have installed for /dev/mcd, of course. When you perform a directory listing of the /dev/cdrom device, you see an arrow after the name showing its link. For example, this entry
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">lrwxrwxrwx 1 root root 9 Oct 16 15:58 cdrom -> /dev/scd0</FONT></PRE>
<P>shows that /dev/cdrom is symbolically linked to /dev/scd0.
<BR>
<P>As a last step, if you intend to play audio-only CD discs through the CD-ROM drive you installed, you must make sure the permissions on the device file allow read and write access. You can do this with the command:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">chmod 666 /dev/cdrom</FONT></PRE>
<P>assuming you have the /dev/cdrom link set up. Substitute the name of your CD-ROM device driver if you don't use the links.
<BR>
<BR>
<A NAME="E69E82"></A>
<H4 ALIGN=CENTER>
<CENTER>
<FONT SIZE=4 COLOR="#FF0000"><B>Mount and Test the CD-ROM Drive</B></FONT></CENTER></H4>
<BR>
<P>Now that the kernel has been rebuilt and the device files are properly set, the CD-ROM drive can be tested. Reboot the Linux system and watch the messages displayed when the machine boots. Depending on the type of CD-ROM drive you have added, you should see some status messages that indicate the CD-ROM drive is recognized and communicating properly.
<BR>
<P>For most IDE and proprietary CD-ROM drives, you see a message similar to Trying to detect a Panasonic CD-ROM drive at... followed by an address. This message tells you that the kernel is searching for what it believes will be a Panasonic CD-ROM device at a particular address. You provided the information about the type of CD-ROM drive and its address when the kernel was configured for the drive. If the CD-ROM is found properly, a message such as 1 Panasonic CD-ROM at... is displayed. Otherwise, you see an error message that tells you the drive couldn't be found.
<BR>
<P>SCSI CD-ROM device drivers sometimes display status messages, but not always. A typical SCSI CD-ROM message is the following:
<BR>
<PRE>
<FONT COLOR="#000080">Vendor: TOSHIBA Model: CD-ROM XM-3401TA Rev: 1094
Type: CD-ROM ANSI SCSI revision: 02
Detected scsi CD-ROM sr0 at scsi0, id 3, lun 0</FONT></PRE>
<P>This message shows thatthe CD-ROM was configured with SCSI ID 3. In this case, the kernel got the name and model number of the drive from the on-board SCSI electronics (a neat feature of SCSI devices).
<BR>
<P>If you can't read the messages about the CD-ROM drive when you boot Linux because the screen scrolls by too quickly, you can recover all the boot messages with the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">dmesg</FONT></PRE>
<P>The dmesg utility tells the kernel ring buffer to show the startup messages. This utility provides a handy way to get help with troublesome devices (not just CD-ROM drives) by sending the output to a file then e-mailing it to a technical support person. If you want, you can pipe the dmesg output to a paging utility like less or more:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">dmesg | less</FONT></PRE>
<P>This command lets you scroll backwards and forwards through the startup messages until you find what you are looking for.
<BR>
<P>If you installed your CD-ROM drive using a script or installation utility, the CD-ROM will probably be mounted automatically due to changes made in the startup commands. If the changes were not made or you installed your CD-ROM drivers manually, you will have to mount the CD-ROM onto your filesystem manually. (You can tell whether the mount was performed automatically by trying to read the CD-ROM directory.) You should mount and unmount CD-ROM drives while you are logged in as superuser (root).
<BR>
<P>When you mount a CD-ROM drive (or any other device), it is mounted into a subdirectory on the Linux filesystem tree. For convenience, it is useful to mount the CD-ROM drive in a subdirectory called /cdrom (which you must create before you try mounting the CD-ROM there). That way, you can change to the CD-ROM contents quickly. To mount an ISO 9660 CD-ROM on the /cdrom directory, issue the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">mount -t iso9660 -r /dev/cdrom /cdrom</FONT></PRE>
<P>The -t option of the mount command indicates the type of filesystem. The -r option mounts the CD-ROM as a read-only device because you cannot write to it. This option is not strictly necessary, but it prevents many error messages should you accidentally try to write to the CD-ROM disc. The device name /dev/cdrom refers to the device file; if you didn't link to this name earlier, use the actual device file name. Finally, /cdrom is the mount point. You can mount the CD-ROM disk anywhere.
<BR>
<P>If you receive an error message when you try the mount command, it is probably because the device file doesn't exist or the CD-ROM drive wasn't recognized during startup. Check all the installation information mentioned earlier and try rebooting the system. If you tried to mount the CD-ROM at a mount point that Linux couldn't reach (perhaps because the directory doesn't exist), check the mount point and create it if necessary. The directory you are mounting the CD-ROM onto must be empty.
<BR>
<P>To test the mount, try changing to the CD-ROM mount point and perform a directory listing. For example, if you mounted the CD-ROM at /cdrom, issue these commands:
<BR>
<PRE>
<FONT COLOR="#000080">cd /cdrom
ls</FONT></PRE>
<P>If you get error messages at this point, either there is no disk in the CD-ROM (or it is inserted improperly) or the filesystem is of the wrong type. The error message should give you a clue as to the problem. If you didn't see anything when you performed the ls command, the disk may be improperly spun up, inserted incorrectly, or of the wrong filesystem type. If you did get a directory listing, all is well, and you can move around the CD-ROM disc as if it were part of your normal filesystem (which it is as far as Linux is concerned).
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>If you want to use the CD-ROM drive to play audio CD discs, the drive should not be mounted. If it is mounted by default, unmount it before playing an audio CD.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>To remove a CD-ROM disc or remove the CD-ROM drive from access, you must unmount the CD-ROM drive. You cannot unmount a drive that is currently in use or is being accessed. Also, the CD-ROM drive cannot invoke any processes. To unmount the CD-ROM drive, use the umount command with the name of the mount point (not the name of the CD-ROM device):
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">umount /cdrom</FONT></PRE>
<P>This command will unmount the CD-ROM drive and make the directory it was mounted on empty.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>Do not change CD discs without unmounting the drive first! When you want to change discs, unmount the CD-ROM drive, change discs, and then remount the drive. If you do not follow this process, the entire Linux filesystem may become corrupt!</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>Some CD-ROM drives require you to eject the disk caddy with the command
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">eject</FONT></PRE>
<P>This command helps clear the filesystem table from memory. Most versions of Linux (including the one provided with this book's CD-ROM) do not support the eject command by default, although some CD-ROM drivers can add it.
<BR>
<BR>
<A NAME="E68E49"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Using /etc/fstab</B></FONT></CENTER></H3>
<BR>
<P>The /etc/fstab file is used to control the mounting of devices when Linux boots. If you want to mount the CD-ROM automatically every time you start up Linux (if it isn't done already), modify the file /etc/fstab to include the mount. The format of the fstab command for a system mounting two filesystems and a SCSI CD-ROM is as follows:
<BR>
<PRE>
<FONT COLOR="#000080">/dev/sda3 / ext2 defaults 1 1
/dev/sda1 /dos msdos defaults 1 1
/dev/scd0 /cdrom iso9660 ro 1 1</FONT></PRE>
<P>Each line in the /etc/fstab file refers to a different filesystem. Fields on each line must be separated with whitespace (either tabs or spaces). The order of filesystems in the /etc/fstab file is important, as they are followed when the filesystems are mounted or unmounted. Therefore, the primary filesystem must be mounted first, followed by the subsidiary filesystems.
<BR>
<P>In previous example, the primary Linux filesystem /dev/sda3 is mounted first. It is an ext2 filesystem type. The DOS partition /dev/sda1 is then mounted in the directory /dos, followed by the SCSI CD-ROM drive mounted in /cdrom. If the /dev/sda3 filesystem were not mounted first, the other two commands would fail.
<BR>
<P>The different fields in the /etc/fstab file are as follows:
<BR>
<UL>
<LI>The filesystem name of the block special device (usually the partition or device name)
<BR>
<BR>
<LI>The mount point for the filesystem. Swap partitions that are mounted have the mount point specified as none.
<BR>
<BR>
<LI>The type of filesystem the device uses. Currently, the following values are valid: mini, ext, ext2, xiafs, msdos, hpfs, iso9660 (CD-ROMs), nfs (network file systems), swap (for swap space), and ignore. If the filesystem type is ignore, the entry is ignored. This type is used to include disk partitions that are not currently in use.
<BR>
<BR>
<LI>The mount options used with the filesystem. This command-separated list usually contains just the type of mount. You can display a complete list of options with the mount man page. Most disks have the default value, which is ro (read-only) for CD-ROMs.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -