Ubuntu: What is “mount” [duplicate]


This question already has an answer here:

what is "mount"? I have a gut feeling it means "make data storage accessible", but what does it really mean? Please specify the cases when "disk is accessible" and "disk is mounted" are different".


Well, let's get back to the basics:

  • When you plug in a memory device, such as a flash drive, the Linux kernel creates a special file for it inside the /dev directory. All your devices are represented by one of those files.

  • When this device is not mounted you cannot access/read/write from it. It's just like a "stand-by" mode, it's ready to be used, but not being used yet.

  • When you mount the device you have to specify a mountpoint. This is a very confusing concept for users coming from Windows. In Windows, every memory device has its own root. In Linux, they are always mounted inside of one single root.

  • Mounting a memory device is basically "turning it on" from the "stand-by" mode. It is accessible through the specified mountpoint.

  • The /mnt directory exists so you can mount things in it. In some distributions (like Ubuntu) there is also a /media directory, for the same purpose.


For simplicity, I'll limit this answer to usual storage devices like disks and flash drives.

When you plug in your device, its driver makes it accessible as a device node, which to user programs looks like a file: e.g. /dev/sda. Now the disk is already accessible. You can read and write it. Here's an example of how you could look at its MBR (first 512 bytes) in hexadecimal+ASCII form:

sudo head -c 512 /dev/sda | xxd -g1  

But if you have some files on that device and you want to access them, this low-level look isn't quite satisfactory. You want to involve a file system driver. For this you mount the device, using mount utility. To make it more obvious, I'll specify the file system explicitly in the following command (assuming I've made the correct choice of ext4; if not, mount will tell you):

sudo mount /dev/sda1 /mnt/ -t ext4  

After this, your device will be exposed in /mnt/ in the format user programs expect it: files and directories â€" instead of just plain sectors.

You may wonder why I used sda1 instead of sda in the command above. It's because between filesystem level and plain sectors level there's a small layer of partitioning, and here sda1 denotes the first partition on device sda.


When you 'mount' something you are placing access to the file system contained within onto your root file system structure. Effectively giving the files a location. This is similar to the C:/D: drive labels in windows.

Mounting /dev/sdb1 to /mnt/disk1 places all the files and folders contained within the device standard disk B partition 1 into the directory /mnt/disk1 where you can access them.

Modern systems have ways to auto-mount drives just as windows auto-mounts drives to drive letters, but the location mounting system in Unix is much more flexible. And unmounting is obviously the removal of the access to those files/folders from that location. You can find out what file systems are mounted by running the command:


Involved parts : mount, umount, fstab (for fixed mounts), udev, gvfs (for automatic mounting)


How familiar are you with Windows (or â€" ugh! â€" DOS)?  If you have gotten beyond absolute newbie status on either of them, you know that your main system secondary storage device (hard disk or SSD) is called C:.  (For simplicity, I will assume that the computer has only one secondary storage device, and that it has only one partition.)  The root directory is C:\, and it contains other directories like C:\Intel, C:\Program Files, C:\Users, and C:\Windows.  These can contain yet another layer of directories; e.g., C:\Program Files\Oracle, C:\Users\your_name, and so on.

  • But if you insert an optical disc (CD or DVD) into the appropriate drive, it becomes D:.  And it also has a root directory, D:\, and typically subordinate directories like D:\Install.
  • And if you remember diskettes (“floppy disks”), you’ll recall that they were disk A: (and, in the really old days, you could have a second one, which, naturally, was called B:).  And the same pattern applies: the root directory A:\ could contain folders like A:\GAMES and A:\WORK.
  • Other removable drives (e.g., USB drives) have drive letters beyond D (perhaps F), and the root directory F:\ could contain folders like F:\Project1.
  • And if you have network drives, they might have drive letters near the end of the alphabet (perhaps Z), and the root directory Z:\ could contain folders like Z:\Project2.

So your whole computer’s directory layout looked something like this:

     A:\                          C:\                             D:\        F:\        Z:\      ⋰ ⋱                     ⋰  ⋰  ⋱  ⋱                       ⋰         ⋰          ⋰     ⋰   ⋱               ⋰     ⋰      ⋱     ⋱                 ⋰         ⋰          ⋰    ⋰     ⋱         ⋰        ⋰          ⋱        ⋱           ⋰         ⋰          ⋰  GAMES   WORK    Intel   Program Files   Users    Windows    Install    Project1    Project2                               ⋰          ⋰                             ⋰          ⋰                           ⋰          ⋰                       Oracle     user480468  

So you could have, in principle, up to 26 independent filesystem directory trees, each with its own root directory.  And I suppose that works well enough, especially now that Windows ties them all together in the Computer (previously known as My Computer) superfolder.  (But then again, look at how hard it is to install programs on a disk other than C:, or to move your user directory off C:.)  And note that Computer is a pseudo-folder â€" you can’t create files or directories in Computer.

Unix has a philosophy that includes the concept Do One Thing and Do It Well.  (Even the name “Unix” is derived from the prefix “un-” or “uni-”, meaning “one”.)  So it’s not surprising that the designers of Unix chose to have a single filesystem directory tree; you’re probably familiar with it:

                                        /                                 ⋰ ⋰ ⋰  ⋮  ⋱ ⋱ ⋱                           ⋰   ⋰   ⋰    ⋮    ⋱   ⋱   ⋱                     ⋰     ⋰     ⋰      ⋮      ⋱     ⋱     ⋱               ⋰       ⋰       ⋰        ⋮        ⋱       ⋱       ⋱         ⋰         ⋰         ⋰          ⋮          ⋱         ⋱         ⋱   ⋰           ⋰           ⋰            ⋮            ⋱            ⋱            ⋱  bin         dev          etc           home           mnt          tmp          usr    …                                         ⋰                                       ⋰⋱                                       ⋰                                       ⋰    ⋱                                     ⋰                                       ⋰        ⋱                                user48046                                   bin         lib  

The beauty of this is that you (in your role of system administrator) can put everything in one partition, or put /home in one partition and /usr in another, and you (in your role of user) can forget about it.  You don’t need to know what disk (partition) /usr is on; it appears under the one-and-only filesystem root (/) regardless.  The mild drawback is that you (in your role of power user) must maintain this unified filesystem directory tree when you add (and remove) storage components.  When you insert a CD or a flash drive, it’s just an entry under /dev, which you probably shouldn’t mess with too much.  You can do some things with the device node, like run fsck or fdisk; or possibly configure it as a dedicated database storage device (e.g., for Oracle) â€" because the disk is accessible.  But you can’t access the files (and directories) on it, because they aren’t in the filesystem yet â€" because the disk is not mounted.


And this is where mount comes in.  mount is the command that attaches a filesystem (e.g., on a removable device) to the filesystem (the one starting at /).1  You’ll notice that there is a /mnt directory under the / directory.  Conventionally, transient (removable) filesystem storage devices are mounted onto directories under /mnt; i.e., they are attached to the filesystem there.  And on some systems, some devices are automatically mounted when they are detected.  But, in theory, you can mount a filesystem anywhere in the filesystem.
1 Splitting hairs, mount is a program that calls the mount() system call, which attaches a filesystem to the filesystem.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »