Using Linux Mount Command

Learn how to use Linux mount and umount commands

Linux mount command
Aping Vision/STS/Photodisc/Getty Images

The Linux Mount command is used to mount USBs, DVDs, SD cards, and other types of storage devices on a computer running the Linux operating system. Linux uses a directory tree structure. Unless the storage device is mounted to the tree structure, the user can't open any of the files on the computer.

How to Use the Mount and Umount Commands in Linux

External storage media devices are usually mounted in subdirectories of the "/mnt" directory, but they can be mounted by default in any other directory created by the user. The following example illustrates the typical use of the Mount command for attaching the file directory of a device to the file directory tree of the Linux system. In this example, a CD has been inserted into the computer's CD drive. To see the files on the CD, open a terminal window in Linux and enter:

mount /dev/cdrom /mnt/cdrom

This command connects the device /dev/cdrom (the CD ROM drive) to the directory /mnt/cdrom so you can access the files and directories on the CD ROM disk under the /mnt/cdrom directory, which is called the mount point. It must already exist when the command is executed. The mount point becomes the root directory of the device's file system.

To unmount the same CD ROM drive, enter this command:

umount /mnt/cdrom

After the unmount command is executed, the files and directories on the CD ROM are longer accessible from the directory tree of the Linux system.

This command has the same effect:

umount /dev/cdrom

It unmounts the CD ROM.

Each type of device has a different mount point. In these examples, the mount point is the /mnt/cdrom directory. The default mount points for the various devices are defined in the file /etc/fstab

Some Linux distributions use a program called automount, which automatically mounts all the partitions and devices listed in /etc/fstab.

How to Make a Mount Point

If the device you are trying to access doesn't have a default mount point listed in /etc/fstab, you have to make a mount point. For example, if you want to access an SD card from a camera, but the SD card isn't listed in /etc/fstab, you can do it from the terminal window:

Insert the SD card into the SD reader, either built-in or external.

Type this command to list the devices that are accessible on the computer:

/fdisk -l

Write down the device name assigned to the SD card. It will be in a format similar to /dev/sdc1 and appear at the beginning of one of the lines. 

Using the mkdir command, type:

mkdir /mnt/SD

This command makes a new mount point for the camera's SD card. Now you can use /mnt/SD in the mount command along with the device name you wrote down to mount the SD card. 

mount /dev/sdc1 /mnt/SD