60

I want to understand what mounting is. It is used in different contexts and situations (directories, flash drives, network cards, etc) and I can't find resources which:

  1. Describe the mount concept;
  2. Explain the actions taken by the computer/OS/utility when a mount is performed;
  3. How and in which situations is mount used;
  4. Which features in the Linux mount command are of frequent use and some examples.
5
  • 3
    This is not a real question. I mean, it is so broad, to answer it one had to write an essay spanning several letter pages. Please try to state it in a way that a clear answer becomes possible.
    – fschmitt
    Oct 18, 2010 at 13:38
  • Well, you don't need to give a complete answer, maybe some pointers, insight, the common sense understanding etc, anything will do, for the clueless:)
    – Vass
    Oct 18, 2010 at 14:32
  • 1
    This is very similar to What is meant by mounting a device in Linux?, but I suppose it asks a bit more Oct 18, 2010 at 14:56
  • If we were to answer this question, would we be doing your homework for you?
    – Craig Turner
    Jan 14, 2011 at 20:56
  • no, its not for homework, I graduated a long time ago, look at my profile page and my webpage link to check that out.
    – Vass
    Jan 14, 2011 at 20:56

3 Answers 3

47

As fschnitt points out, a comprehensive answer to this would likely be a chapter in a systems administration manual, so I'll try just to sketch the basic concepts. Ask new questions if you need more detail on specific points.

In UNIX, all files in the system are organized into a single directory tree structure (as opposed to Windows, where you have a separate directory tree for each drive).

There is a "root" directory, which is denoted by /, which corresponds to the top directory on the main drive/partition (in the Windows world, this would be C:). Any other directory and file in the system can be reached from the root, by walking down sub-directories.

How can you make other drives/partitions visible to the system in such a unique tree structure? You mount them: mounting a drive/partition on a directory (e.g., /media/usb) means that the top directory on that drive/partition becomes visible as the directory being mounted. Example: if I insert a USB stick in Windows I get a new drive, e.g., F:; if in Linux I mount it on directory /media/usb, then the top directory on the USB stick (what I would see by opening the F: drive in Windows) will be visible in Linux as directory /media/usb. In this case, the /media/usb directory is called a "mount point".

Now, drives/partitions/etc. are traditionally called "(block) devices" in the UNIX world, so you always speak of mounting a device on a directory. By abuse of language, you can just say "mount this device" or "unmount that directory".

I think I've only covered your point 1., but this could get you started for more specific questions.

Check this for further reading.

8
  • so, when a flash drive is mounted into /media/usb, the OS maps commands like 'ls' from this directory to the flash drive to get the output?
    – Vass
    Oct 18, 2010 at 14:45
  • 1
    @Vass yes, that is precisely what happens. Oct 18, 2010 at 15:16
  • @RiccardoMurri, So basically, mount is a redundant word and concept. Just use the word "link". Link the drive, Unlink the drive, The linkpoint is x.
    – Pacerier
    Aug 16, 2017 at 1:03
  • @Pacerier Well, no: the term used everywhere in the Linux/UNIX world is "mount". The word "link" is used to refer to a different concept: see e.g. cyberciti.biz/tips/… Aug 16, 2017 at 13:01
  • So, Can I mount a drive/device that is not already formatted as a particular file system? I thought mount could only attach files systems into the virtual file namespace?
    – Don Slowik
    Jan 1, 2021 at 16:17
28

In Unix everything is a file.

These files are organized in a tree structure, beginning at the root /.

Your filesystem or filesystems will then be mounted at the appropriate places in your / according your /etc/fstab file. This file contains information about your filesystems, which device they belong to and to which point they will get mounted to - the mountpoint.

Thats the "mount concept".

It is not limited to disks and other blockdevices, here are some examples involving mount:

  • Mount a representation of your running kernel under /proc
  • Mount a special log partition (other device, "logfriendly" filesystem) under /var/log
  • Install different systems and mount just one home directory
  • Mount remote directories for example via NFS to your system
  • Mount a image of a cd to a specific directory
7
  • then in the directory you mounted something too, you can 'cd' into there and see all the files?
    – Vass
    Oct 18, 2010 at 14:43
  • Yes. You can "cd into" your mountpoint and see the files :-)
    – echox
    Oct 18, 2010 at 14:48
  • can you 'mount' a directory to another directory? can you mount an input stream into a directory? what are some things other than devices you can mount?
    – Vass
    Oct 18, 2010 at 17:19
  • you can't mount a directory into another, but there are hardlinks and symlinks for that. you can't mount an input stream directly, because theres no filesystem behind an input stream. you can mount it indirectly with an appropriate kernelmodule, see the last point I mentioned (cdimage). For the last point, see my examples and FuseFS.
    – echox
    Oct 18, 2010 at 19:35
  • Kernel ----> Filesystem Module ----> Device / Application / Whatever
    – echox
    Oct 18, 2010 at 19:36
7

I found this resource to be helpful:

Data on a computer, as you may know, is stored in binary as a series of 1s and 0s. The way these are stored on a device and their structure is called the "filesystem". In Linux devices are referenced in /dev. Data is not actually stored on a device so you cannot access this data by going into /dev, this is because it is stored inside the filesystem on the device so you need to access these filesystems somehow. Accessing such filesystems is called "mounting" them, and in Linux (like any UNIX system) you can mount filesystems into any directory, that is, make the files stored in that filesystem accessible when you go into a certain directory. These directories are called the "mount points" of a filesystem.

Not the answer you're looking for? Browse other questions tagged .