Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.
  1. I am mounting an image, and just realized that I have to create the directory for mounting point first. The command mount won't mount to a non-existing directory.

    But I seem to remember in some cases, when I insert some external device, such as external HDD and CD, I don't have to create mounting point myself. So I wonder when mounting points are required to be created by myself and when not?

  2. Is it correct that mounting point directories can be created anywhere?

    Then what is the purposes of the directories /mnt and /media? Aren't they for hosting mounting points of devices?

PS: I am under Ubuntu 12.04.

Thanks!

share|improve this question

3 Answers 3

up vote 7 down vote accepted

You can indeed create a mount point directory anywhere. /mnt and /media are conventions, not technical requirements, just like e.g., /home.

/media is used in particular for auto-mounting. Some part of your desktop environment (possibly udisks) auto-mounts removable media when its connected. It does so by creating a directory under /media, and running mount (just like you would by hand). An image isn't "connected" (unlike a USB thumb drive, for example), so the desktop environment isn't noticing it and auto-mounting it.

/mnt is often used for remote file servers. Unlike /media, your desktop environment won't automatically mount stuff there. If you're not using /mnt for remote file servers, its a perfectly good place for your temporary mount.

You can see descriptions of the conventions for these directories in the Filesystem Hierarchy Standard.

share|improve this answer
    
+1, Very exact explanation –  rkosegi Sep 13 '12 at 16:45

You always need to create the mount point if you're going to be the one running mount; it won't do it for you. In the case of external devices, some distros will detect when they're plugged in, automatically make the mount point, and then mount the device there (udev is common for this), but they're still making the directory first if it doesn't exist

As for where the mount point should be, /mnt and /media are just conventions; they can appear anywhere. I commonly mount things at /tmp/whatever if I'm only going to need them for a minute

share|improve this answer

Mount points can be created anywhere. In fact, inspect your system with mount (with no arguments) or cat /proc/mounts. On a typical Linux system, you will see many “technical” filesystems mounted at various locations: /dev, /dev/shm, /lib/init/rw, /proc, /run, /sys, etc. You might also find GVFS (the Gnome virtual filesystem wrapper) mounted at ~/.gvfs (with Samba, SSHfs and other mounts below it), AVFS at ~/.avfs and so on.

The Linux convention defined in the filesystem hierarchy standard is to have two system directories: /mnt left to the discretion of the system administrator, and /media containing one subdirectory per mounted or potentially-mountable filesystem. /media was conceived because there were two opposing traditions for /mnt: either as a temporary mount point, or as a directory containing mount points.

On some systems, you'll see directories such as /home that are mount points (if home directories are on a central server). You might see a mount point at /boot on systems where the bootloader can't access the OS root directory. It's rare nowadays, but a separate, read-only /usr used to be more common.

The mount command requires an existing directory for a mount point. The directory should be empty; this is not required, but mounting hides any data that was in that directory.

Other commands and system components (pmount, udev, …) create the requisite directory automatically and typically remove it when done. Since they do the mounting, they might as well create the directory while they're at it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.