Creating mounting point
Solution 1
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.
Solution 2
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
Solution 3
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.
Related videos on Youtube
Tim
Elitists are oppressive, anti-intellectual, ultra-conservative, and cancerous to the society, environment, and humanity. Please help make Stack Exchange a better place. Expose elite supremacy, elitist brutality, and moderation injustice to https://stackoverflow.com/contact (complicit community managers), in comments, to meta, outside Stack Exchange, and by legal actions. Push back and don't let them normalize their behaviors. Changes always happen from the bottom up. Thank you very much! Just a curious self learner. Almost always upvote replies. Thanks for enlightenment! Meanwhile, Corruption and abuses have been rampantly coming from elitists. Supportive comments have been removed and attacks are kept to control the direction of discourse. Outright vicious comments have been removed only to conceal atrocities. Systematic discrimination has been made into policies. Countless users have been harassed, persecuted, and suffocated. Q&A sites are for everyone to learn and grow, not for elitists to indulge abusive oppression, and cover up for each other. https://softwareengineering.stackexchange.com/posts/419086/revisions https://math.meta.stackexchange.com/q/32539/ (https://i.stack.imgur.com/4knYh.png) and https://math.meta.stackexchange.com/q/32548/ (https://i.stack.imgur.com/9gaZ2.png) https://meta.stackexchange.com/posts/353417/timeline (The moderators defended continuous harassment comments showing no reading and understanding of my post) https://cs.stackexchange.com/posts/125651/timeline (a PLT academic had trouble with the books I am reading and disparaged my self learning posts, and a moderator with long abusive history added more insults.) https://stackoverflow.com/posts/61679659/revisions (homework libels) Much more that have happened.
Updated on September 18, 2022Comments
-
Tim over 1 year
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?
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!
-
eternaltyro almost 5 yearsWhat's a good mount point for a persistent mount? The FHS doesn't specify where additional disks (as seen on cloud platforms) should be mounted?
-
derobert almost 5 years@eternaltyro The Unix tradition would be to mount it wherever it belongs in the filesystem tree (e.g., if you want to put /srv on it, you'd mount it at /srv). You can mount it wherever you want, really, if nothing else makes sense you can always make yourself a new root-level directory (e.g.,
/disks
) and mount them all there. Or you could use/mnt
or/media
, since your cloud server probably doesn't have e.g., udisks and a desktop environment fighting for those spots.