Mounting and unmounting drives on Linux

by: acul Friday, November 25th, 2011

Before you can use any storage device in Enterprise Linux, the device must first be made a part of the file system. This process is mounting; to attach the drive, you use the mount command. The basic syntax of the mount com- mand is

mount devicename mountpoint

The devicename identifies the device that you want to mount. All files that identify a device are located in the /dev directory. Thus, the system CD-ROM drive is typically identified as /dev/cdrom, and the system floppy drive is usually /dev/fd0.

You usually must be logged in as the root user to mount and unmount drives.

Mount point identifies the directory location on the file system where the device will be accessible. The top-level directory, /mnt, is the typical mount point for other devices, which are listed as subdirectories of /mnt. For exam- ple, if you want to access files from your CD-ROM drive, first mount the drive by entering the following command:

mount /dev/cdrom /mnt/cdrom

The preceding command mounts the cdrom device onto the file system at the directory /mnt/cdrom. To access files from the CD-ROM, all you need to do is to change into the /mnt/cdrom directory.

Although you can mount a device to any directory, I recommend using an empty directory as the mount point. Mounting a device on a directory that contains files will make those files inaccessible while the device is mounted.

To unmount a device from your file system, you use the umount command. For example, if you no longer need to access the CD-ROM drive, you can unmount the device by entering the following command:

umount /mnt/cdrom

This command tells the system to remove the mount point that was created at /mnt/cdrom.

Before you can remove a CD from the CD-ROM drive, you must unmount the device.

« | Home | »

 

Leave a Comment