Monday, May 17, 2010

Commands for mounting and unmounting

Start by looking at the /etc/fstab file for clues to the name of the CD-ROM device. For example, some Linux distributions use the device name /dev/cdrom to refer to CD/DVD-ROM drives, whereas others may use device names such as /dev/hdc, /dev/cdroms/cdrom0, or /dev/cdrecorder( for a DVD/CD-R drive). The entry in /etc/fstab file also tells you the directory where that distribution expects the CD/DVD to be mounted. Some distributions use /media/cdrom as mount point, whereas others use /media/cdrom0, or /media/cdrecorder.

It is customary to use the cdrom term to mean both CD-ROM and DVD-ROM.

Log in as root ( or type su - to become root), insert the DVD-ROM in the DVD drive, and then type the following command:

mount  /dev/hdc /media/cdrom0

This command mounts the file system on the device named /dev/hdc (an IDE DVE/CD-ROM drive) on the /media/cdrom0 directory ( which is also called the mount point) in the Linux file system.

After the mount command successfully completes its task, you can access the files on the DVD-ROM by referring to the /media/cdrom0 directory as the top-level directory of the disc. In other words, to see the contents of the DVD-ROM, type

ls -F /media/cdrom0

When you're done using the DVD-ROM and before you eject it from the drive, you have to unmount the disc drive with the following umount command:

umount  /dev/hdc


You can mount devices on any empty directory on the file system. However, each distribution has customary locations with directories meant for mounting devices. For example, some distributions use directories in /mnt whereas others use the /media directory for the mount points.

No comments:

Search This Blog