In modern computers, the data you use can be stored on many different devices. First, the HDD ( Hard Drive Disk), then the removable media, like the Floppies and CD-ROMs(CD’s). If you are regular Windows user, then you probably know that the different filesystems in this operating system are available to you automatically. But, in Linux, every user should execute a process called mounting. Mounting means assigning physical location to every storage device you mount. Mounting is done by using the mount command. In order to use this command successfully, you must also specify a mount point and the device you would like to mount. For example, to mount your CD-ROM drive (assuming it resides in /dev/cdrom):
$mount /dev/cdrom /mnt/cdrom
Here, the first parameter to the mount command is “/dev/cdrom”. It is , of course the device we would like to mount, the CD-ROM in this case. The second parameter is the mount point, saying that we would like to mount the content of the CD-ROM to the /mnt/cdrom directory. But, every Linux system can be configured to have default mount points for particular devices. This configuration usually is stored in the /etc/fstab file.
The fstab file resides in the /etc directory. It is nothing more then a configuration file for every device, showing how it can be mounted and where. Changing the fstab file means changing your system configuration, so only the root user has to right to edit it.
Here an example is shown of a typical fstab file:
/dev/hda2 / ext2 defaults 1 1 /dev/hdb1 /home ext2 defaults 1 2 /dev/cdrom /media/cdrom auto ro,noauto,user,exec 0 0 /dev/fd0 /media/floppy auto rw,noauto,user,sync 0 0 proc /proc proc defaults 0 0 /dev/hda1 swap swap pri=42 0 0
Every line of the fstab file contains information about the device specified. The first piece of information is the device name ( /dev/hda2, /dev/hdv1 ..). The second part of every line is the mount point of that device, which is followed by the type of the filesystem. After the type of the filesystem come the mount options ( defaults, noauto..) and then dump options and filesystem check options.
As you can see, every device specified here, has a coordinated mount point. So, when you mount some device using the mount command, which is configured in the fstab file, it is not necessary to specify a mount point. For example, to mount the CD-ROM in this case, the following would suffice:
As configured, you know that the cdrom will be mounted to its mount point, the /media/cdrom directory.
There are a lot of filesystem types and one of the most common are:
The mount options show how and by who the devices can be mounted. There are many mount options available and here is the explanation of some of them:
Dump is a back up utility. The dump option is a number which is in the fifth column of the fstab file. If the dump option is set to 0, then no backup of the filesystem will take place. The filesystem check option is in the sixth column of the fstab file. It is used by the fsck utility, of course, a filesystem check utility. This option gives the order in which the filesystems should be checked. Again, if fsck option is set to 0, the filesystem will never be checked.
Unmounting is the opposite process of mounting. When a certain device is unmounted, that means it can’t be accessed or modified anymore. In other words, the unmounting process is one way of preserving the device contents.
All removable storage devices, like CD-ROMs and floppies, should be unmounted before removed. That ensures that all changes are properly and successfully made. But, if you remove the media before unmounting it, then the media can easily become corrupted.
Unmounting is done by the umount command.
For example, if you unmount by the mount point:
This will unmount the floppy device, which mount point is set to /mnt/floppy. Or, you can unmount by the device name/file:
Unmounting is not possible, if you do it to an active filesystem. For example, if some of the files of the filesystem are opened and in use, then the unmounting of that filesystem is impossible.
Unmounting the filesystem which contains your current working directory is also a common problem. So, make sure that you relocate to other filesystem before unmounting the current one.