The Mount Command
The mount command handles the attaching the partition or device to the file system hierarchy. In other words, it makes a disk device or partition accessible to the user. It has the format:
mount type device dir
The options with the mount command allow you to specify whether you want to mount the device as “read only” (-r) or “read write” (-w). The default access method for the mount command is read/write in order to allow the file system to be accessed and changed. When accessing read only drives, such as cd- and dvd-roms, you must specify in the mount command that they are read only by using the “-r” option.
mount /dev/hdc -t iso9660 -r /cdrom
Most Linux distributions contain an automount utility that will automatically mount the cd-rom for you. Unless there is a problem with the the automounter, or if you manually unmount the cd-rom, you will not have to manually mount the cd-rom.
Flash drives also do not need to be manually mounted in most distributions. They also do not show up in the /etc/fstab file (discussed below), either. Instead, they are handled by the HAL (hardware abstraction layer). The HAL creates a disk device, and the automounter mounts the device. Again, the only time you would need to manually mount the flash drive is if the automounter does not see it for some reason.
Once in awhile, you will issue the mount command with the default options to find that you cannot write to a disk. The first thing to do is wait a minute or two, as the drive may not be ready for writing. This is not supposed to be the case in the latest kernel, but it can still happen. If you wait a couple of minutes and you still cannot write to your disk, you will want to check that the device is not set as “read only” in the /etc/fstab file.
The /etc/fstab file
The /etc/fstab file is another place where you can specify what access you want to give a particular drive. The fstab file lists all of the partitions and disks available to a file system along with information on how and when they will be mounted. A typical entry in the /etc/fstab file looks like:
Label=/ / ext3 realtime,errors=remount-ro 0 1
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
The above entries are for the root (/) filesystem and a cd-rom drive.
Again, the default is to mount the each device as “read/write” unless otherwise specified. In the above example, the root partition will be mounted as read only (“ro”) if there are any errors during the boot process (“errors=remount-ro”).
The fstab also determines when a device is mounted. For example, the root file system is mounted at boot, but the cdrom needs to be manually mounted by the user.
If there is an entry in the fstab file for the device you are manually attempting to mount, you do not need to specify where to mount the device. Instead, you would use the mount point. For example, you would mount the cd-rom above with the command:
Any time you use the mount command, it reads the /etc/fstab file and sets the access permissions as defined in that file. That is why, if you have a partition called “Windows” in the fstab file that is set to read only, using the command “mount /Windows” will only give you read only access.
Both the mount command and the /etc/fstab mount a device as read/write unless specified as read only. Therefore, if you are having trouble reading and writing to a mounted device, you will want to check you fstab file to ensure that you have the correct permissions specified.