Introduction to mounting filesystems in LinuxBy DarkRaika on November 8, 2005 | Last Updated: March 27, 2014 | Read 102,216 times.
Table of Contents
A filesystem is a way that an operating system organizes files on a disk. These filesystems come in many different flavors depending on your specific needs. For Windows, you have the NTFS, FAT, FAT16, or FAT32 filesystems. For Macintosh, you have the HFS filesystem and for Linux you have more filesystems than we can list in this tutorial. One of the great things about Linux is that you have the ability to access data stored on many different file systems, even if these filesystems are from other operating systems.
In order to access a filesystem in Linux you first need to mount it. Mounting a filesystem simply means making the particular filesystem accessible at a certain point in the Linux directory tree. When mounting a filesystem it does not matter if the filesystem is a hard disk partition, CD-ROM, floppy, or USB storage device. You simply need to know the device name associated with the particular storage device and a directory you would like to mount it to. Having the ability to mount a new storage device at any point in the directory is very advantageous. For example, lets say that you have a web site stored in /usr/local/website. The web site has become very popular and you are running out of space on your 36 GB hard drive. You can simply go out and purchase a new 73 GB hard drive, install it in the computer, and then mount that entire drive as /usr/local/. Now your /usr/local mount point has a total hard drive space of 73 GB, and you can free up the old hard drive by copying everything from the old /usr/local to the new one. As you can see, adding more hard drive space to a computer, while still keeping the same exact directory structure, is now very easy.
In order to determine what filesystems are currently being used type the command:
When you type this at a command prompt, this command will display all the mounted devices, the filesystem type it is mounted as, and the mount point. The mount point being local directory that is assigned to a filesystem during the process of mounting.
Before you can mount a filesystem to a directory, you must be logged in as root (some filesystems can be mountable by a standard user) and the directory you want to mount the filesystem to must first exist. Also in some situations, you must be logged in as the root user in order to make the particular mount directory. If the directory exists, and any user can mount that particular device, then it is not necessary to be logged in as root. When mounting a particular filesystem or device you need to know the special device file associated with it. A device file is a special file in Unix/Linux operating systems that are used to allow programs and the user to communicate directly with the various partitions and devices on your computer. These device files are found in the /dev folder.
As our first example, lets use a real world example of accessing your Windows files from a floppy in Linux.
In order to mount a device to a particular folder, that folder must exist. Many Linux distributions will contain a /mnt folder, or even a /mnt/floppy folder, that is used to mount various devices. If the folder that you would like to mount the device to exists, then you are all set. If not you need to create it like this:
This command will have now created a directory called /mnt/floppy. The next step would be to mount the filesystem to that folder or mount point.
You have now mounted an msdos filesystem, which is indicated by the -t (type) option. The device is recognized by the /mnt/floppy point. Now you can access MS-DOS formatted disks as you would any other directory.
Again this is a similar method as above to mount the CD-ROM.
Different filesystems can also be mounted in a similar manner:
Any filesystems that are not mounted can be seen via the df command. So using that command you know what you got to work with.
Note: The -t option should be used so that the operating system knows the specific filesystem type that you would like to mount the device as. If you leave the -t option out of the command, mount it will attempt to determine the correct filesystem type it should mount the device with.
When unmounting a filesystem you simply type umount followed by the mount point. For example:
Now that you know how to mount and unmount filesystems, even those from other operating systems, in Linux, using Linux should now be even more attractive and a much more powerful tool. For more information about the mount and umount commands you can view their man page (help files) by typing the following commands:
For more information about how to automatically mount certain filesystems when the operating system starts, you can view the following man page:
As always, if you have any questions please feel free to ask them in the Linux Forum.
Comments:blog comments powered by Disqus
|Tech Support Forums | The Computer Glossary | RSS Feeds | Startups | The File Database | Virus Removal Guides | Downloads|