This document discusses how to this CD-ROM under Linux (or any Unix-like operating system) or under Microsoft Windows. There are two issues to consider in particular: how to mount and unmount the CD-ROM, and how to access files on the CD-ROM.
In this document, “$
” will indicate the
ordinary user’s shell prompt or the Cygwin shell prompt (under
Microsoft Windows), and “#
” will indicate the
root superuser’s shell prompt. Anything in a bold
monospaced font is what you are expected to type in; an
ordinary monospaced font is used for the computer’s
response. Please note that this document doesn’t show
every response from the computer! Something like
“Start » Settings » Control Panel” means
that you click on the Start button, select the Settings sub-menu and
finally click on Control Panel.
In order to use a CD-ROM under Linux (or any Unix-like operating system), you must first mount it. Mounting a CD-ROM (or any other physical media, such as a floppy disk, a ZIP disk or a hard drive) tells the operating system which block device to use and where that device is to appear within the directory tree — the mount point. Once you have finished using the CD-ROM, you must unmount it.
The canonical command to mount the CD-ROM under Linux is:
# | mount -t iso9660 -o ro device dir |
The block device device specifies the physical device or bus the CD-ROM is attached to. On most Linux systems, you can use /dev/cdrom, which would be a symbolic link to something like /dev/hdc for an ATAPI CD-ROM, selected as a master device, on the secondary IDE cable.
The mount point dir specifies where the contents of the CD-ROM are to appear. In Linux and other Unix-like operating systems, every file and directory that can be accessed appears in a single directory tree starting from “/”, the root directory. The mount point dir, then, is simply a directory within that directory tree.
You can use any directory that you like for the mount point dir, as long as that directory exists and is empty. The convention under Linux is to use either /mnt/cdrom or /cdrom.
So, for a typical Linux system, the command you would use to mount a CD-ROM would be:
# | mount -t iso9660 -o ro /dev/cdrom /mnt/cdrom |
Remember that only the root superuser can run this version of the
mount
command, so you need to log in as root to do this. For
the safety and security of your own computer, you should log out as soon
as you have entered this command successfully. Better yet, learn how to
use the su
command. You should never do your
ordinary work as root! To do so invites the whole world to crack into
your computer, destroy your data and use your system to attack others.
Once you have mounted the CD-ROM, you can access files and directories on that CD-ROM as if they were part of your directory tree — as, in fact, they now are. For example, if you mounted the CD-ROM on /mnt/cdrom, you can view the file you are now reading (stored on the CD-ROM as unsw/common/cdrom-mounting.html) by typing something like:
$ | more /mnt/cdrom/unsw/common/cdrom-mounting.html |
Of course, if you used a different mount point than /mnt/cdrom, substitute that mount point as appropriate. For example, if you used /cdrom, you would type:
$ | more /cdrom/unsw/common/cdrom-mounting.html |
To free you from the hassles of mounting and unmounting CD-ROMs in the Laboratory, you can access the contents of this Companion CD-ROM by using ~course/cdrom instead of /mnt/cdrom. For example, if you are studying ELEC2041, you can use ~elec2041/cdrom on the Laboratory computers — and you don’t have to mount or unmount any CD-ROMs:
$ | more ~elec2041/cdrom/unsw/common/cdrom-mounting.html |
Once you have finished using the CD-ROM, you need to unmount it. The operating system makes you do this so that it can check that nothing is, in fact, using the CD-ROM when you try to eject it.
To unmount the CD-ROM, you need to enter the following command as the root superuser:
# | umount dir |
The directory dir is the mount point that you used for
mounting the CD-ROM in the first place (eg, /mnt/cdrom). And please note that the command is
umount
, not unmount
: the first “n”
is missing!
If you get an error message stating that “device is busy”, it means that something is still using files and/or directories on the CD-ROM. Even something as simple as having your current directory set to some directory on the CD-ROM is enough to get you this message.
If you are new to Linux and Unix in general, you should take the time to read a book like Learning Red Hat Linux by Bill McCarty (O’Reilly and Associates, ISBN 0-596-00071-5) or Running Linux by Matt Welsh et. al. (O’Reilly and Associates, ISBN 0-596-00272-6).
If you would like the full technical details of the mount
command, you should refer to mount
(8). This cryptic notation
simply means you look up the page for mount
in section 8 of
the on-line Linux Reference Manual. You do this by typing:
$ | man 8 mount |
If you want to be able to mount and unmount CD-ROMs without being logged in as the root superuser, you need to modify the file /etc/fstab to include the following line:
/dev/cdrom /mnt/cdrom iso9660 defaults,noauto,user,ro 0 0 |
Please note that you may need to replace /dev/cdrom with
whatever you used as the block device for the mount
command,
and /mnt/cdrom with whatever you used for the mount point.
In addition, do check that you don’t already have a line similar to
this one in /etc/fstab!
Once you have modified /etc/fstab, you can type the following commands as an ordinary user:
$ | mount /mnt/cdrom |
$ | umount /mnt/cdrom |
For more information, see fstab
(5), mount
(8)
and umount
(8).
You do not need to mount and unmount CD-ROMs under Microsoft Windows. This is because there is no Unix-like concept of a single directory tree. Instead, multiple directory trees exist, each starting with a drive letter and colon.
This lack of mounting and unmounting sounds like a benefit to users — and it often is! However, it does mean that you are the one responsible for figuring out which drive letter belongs to the CD-ROM. In many systems it is “D:”, but this may not be the case on yours. If it is not, you need to replace every occurrence of “D:” on this CD-ROM with whatever is appropriate for your system.
Another major difference between Microsoft Windows and Linux (and other
Unix-like operating systems) is the fact that Windows uses
“\
” to separate directory and filename elements,
whereas Unix uses “/
”. This CD-ROM uses the Unix
format, not the Windows format, for filenames. For example, the document
you are currently reading can be found as unsw/common/cdrom-mounting.html on this CD-ROM. Under
Windows, you would use D:\unsw\common\cdrom-mounting.html instead (assuming, of
course, that your CD-ROM appears as drive “D:”). In other words, replace every
“/
” with a “\
” and
prepend the drive letter and colon.
If this is not enough to confuse you, the Cygwin Unix emulator, which
you may need to use to run the GNU
Tools, is a Unix-like system. In other words, it
does use “/
”! But since it is only an
emulator and not a real operating system of its own, it does not have the
same semantics for the mount
command that a real Linux or
Unix-like system does. Instead, the CD-ROM “magically”
appears in the directory /cygdrive/d, where the
“d
” is the same as the drive letter for your
CD-ROM.
What all this means is that, once you have installed Cygwin under Microsoft Windows, you can access this document by opening a Cygwin command line (usually by selecting Start » Programs » Cygwin » Cygwin Bash Shell) and typing:
$ | more /cygdrive/d/unsw/common/cdrom-mounting.html |
In the Digital Systems Laboratory, you can access the contents of this CD-ROM by using ~course/cdrom instead of /cygdrive/d. For example, if you are studying ELEC2041, you can use ~elec2041/cdrom on the Laboratory computers — and you don’t have to bring in your own copy of this CD-ROM:
$ | more ~elec2041/cdrom/unsw/common/cdrom-mounting.html |
The relationship between directory paths under Microsoft Windows and
under the Cygwin Unix emulator can be quite complex. As already
mentioned, Cygwin uses Unix-style paths with “/
”
path separators; Windows uses “\
”. Furthermore,
Cygwin presents you with a virtual root directory: when you are
in the Cygwin Bash Shell window, it is as if you are in a real Unix
environment with /
as your root directory — with no
drive letters.
This virtual root directory is just an illusion, however. Each
directory in Cygwin is actually mapped to a directory in the underlying
Windows file system. You use the cygpath
(1) utility program
to map between the two. For example:
$ cygpath --windows / |
C:\cygwin |
$ cygpath --unix 'D:\README.html' |
/cygdrive/d/README.html |
$ cygpath --windows ~elec2041/cdrom |
C:\cygwin\home\elec2041\cdrom |
By the way, please note that the results your computer gives might be different to what is shown above. In particular, the path ~elec2041/cdrom will only work in the Laboratory!
If you would like the full technical details about how the Cygwin Unix
emulator works, you should definitely consult the Cygwin User’s
Guide on this CD-ROM. You should also refer to
cygpath
(1) and mount
(1). This cryptic notation
simply means you look up the page for cygpath
or
mount
in the on-line Cygwin Reference Manual. You do this by
typing:
$ | man cygpath |