Need newbie explanation on /mnt versus /media

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
Kurt3162
Level 4
Level 4
Posts: 214
Joined: Wed Apr 02, 2014 2:05 pm

Need newbie explanation on /mnt versus /media

Post by Kurt3162 » Sun Jan 21, 2018 10:32 pm

Things mounted through the GUI seem to land in /media/{user}.
Partitions I automount through fstab at startup live, as expected, in /mnt.

- So what is the difference between /mnt and /media (except that the latter is user-specific)?
- Assuming there is no difference except the user-specificity, how does one auto-mount to /media at startup? Not in /etc/fstab I guess?



I'm asking partly because I have a strange case where one (single!) Wine program doesn't like discs in /mnt while it doesn't mind anything in /media... No, all the other programs running through Wine don't make that difference, so it can't be a Wine misconfiguration. It seems there must be some functional difference between those two ways to mount a partition, and this specific program (a dictionary, of all things...) is badly written enough to trip over it. Unless the cause is a difference between NTFS and ext4 partitions - the partition in /mnt is ext4, the ones in /media are mostly NTFS... And I can find myself juggling with up to 28 different partitions at the same time (not counting thumb drives) - I bring a whole new meaning to the term "disc jockey"...

User avatar
catweazel
Level 16
Level 16
Posts: 6331
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Need newbie explanation on /mnt versus /media

Post by catweazel » Mon Jan 22, 2018 12:55 am

Technically, there is no functional difference whatsoever between the two. /mnt is a standard directory, as is /media/...

The difference is in what they should be used for, emphasis on should. /media is supposed to be the mount point for removable media while /mnt is for temporary mounts initiated by the user.
There are no silly questions, but there are silly answers.

User avatar
Schultz
Level 6
Level 6
Posts: 1225
Joined: Thu Feb 25, 2016 8:57 pm

Re: Need newbie explanation on /mnt versus /media

Post by Schultz » Mon Jan 22, 2018 1:11 am

catweazel wrote:
/mnt is for temporary mounts initiated by the user.
I have a second internal hard drive in my computer that I permanently mounted in /mnt. Should it have been put somewhere else? (I know it really doesn't matter.)

User avatar
smurphos
Level 6
Level 6
Posts: 1178
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Need newbie explanation on /mnt versus /media

Post by smurphos » Mon Jan 22, 2018 1:16 am

Look here - https://www.tldp.org/LDP/Linux-Filesyst ... l/c23.html & https://askubuntu.com/questions/22215/w ... -and-media

Run man hier in your terminal.

I think the main functional difference is that removable drives mounted in /media have more limited permissions that drives mounted in /mnt using fstab.
Having said that I don't think there is anything stopping you specifying /media as a mount point in /etc/fstab

User avatar
catweazel
Level 16
Level 16
Posts: 6331
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Need newbie explanation on /mnt versus /media

Post by catweazel » Mon Jan 22, 2018 1:28 am

Schultz wrote:
catweazel wrote:
/mnt is for temporary mounts initiated by the user.
I have a second internal hard drive in my computer that I permanently mounted in /mnt. Should it have been put somewhere else? (I know it really doesn't matter.)
Of course it doesn't matter. That's why I wrote "the difference is in what they should be used for, emphasis on should". It's mere convention.
There are no silly questions, but there are silly answers.

User avatar
catweazel
Level 16
Level 16
Posts: 6331
Joined: Fri Oct 12, 2012 9:44 pm
Location: Australian Antarctic Territory

Re: Need newbie explanation on /mnt versus /media

Post by catweazel » Mon Jan 22, 2018 1:29 am

smurphos wrote:I think the main functional difference is that removable drives mounted in /media have more limited permissions that drives mounted in /mnt using fstab.
Nonsense.
There are no silly questions, but there are silly answers.

Cosmo.
Level 23
Level 23
Posts: 17830
Joined: Sat Dec 06, 2014 7:34 am

Re: Need newbie explanation on /mnt versus /media

Post by Cosmo. » Mon Jan 22, 2018 5:39 am

As catweazel says, technically no difference.

But there is one difference, which might be of interest: Mounts in /media do appear on the desktop, in /mnt they do not. If you want the desktop icons is a personal preference.

altair4
Level 19
Level 19
Posts: 9156
Joined: Tue Feb 03, 2009 10:27 am

Re: Need newbie explanation on /mnt versus /media

Post by altair4 » Mon Jan 22, 2018 8:02 am

Once upon a time many many moons ago external storage devices would automatically mount to /media/$LABEL.

You were warned not to mount any internal partition under /media directly because that is where the system mounts these external storage devices and if they both had the same LABEL ....

That specific warning no longer applies because external devices now mount to /media/$USER/$LABEL so mounting something directly under /media does not pose the same problem - with the knowledge that it will produce a mount icon on some desktops as previously mentioned.

There is however a new warning which is a modification of the original: Avoid mounting anything under /media/$USER and this time for two reasons:

[1] Same as the original - that is where the system automounts temporary external devices.

[2] The Access Control List that the system imposes of /media/$USER will prevent access to everyone other than $USER.

EDIT: In some branches of Linux the default auto-mount point is located at /run/media/$USER/$LABEL which means you can mount something anywhere you want to mount it since I doubt the average user would ever think to look under /run/media ...
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

Kurt3162
Level 4
Level 4
Posts: 214
Joined: Wed Apr 02, 2014 2:05 pm

Re: Need newbie explanation on /mnt versus /media

Post by Kurt3162 » Mon Jan 22, 2018 9:07 am

Thanks guys. Seems I was not the only one wondering.

Let me try to summarize to see if I got it right:
Apparently the difference is that /mnt is where the system auto-mounts stuff, /media where it puts manually mounted stuff.
And in the second case the mounted partition is tied to the specific user, inheriting the user's permissions (what permissions do /mnt-mounted partitions inherit? Root?).
Is that right?


BTW - The "hier" manpage displays a confusing choice of words: it states "/media : This directory contains mount points for removable media such as CD and DVD disks or USB sticks." (emphasis mine).
Which is somewhat misleading since the partitions I mount inside /media aren't removable, they are all fixed, internal discs. The difference isn't on the type of disc, but apparently on how you mount it (manual GUI click vs. auto-mount in fstab).

altair4
Level 19
Level 19
Posts: 9156
Joined: Tue Feb 03, 2009 10:27 am

Re: Need newbie explanation on /mnt versus /media

Post by altair4 » Mon Jan 22, 2018 9:22 am

Kurt3162 wrote:Let me try to summarize to see if I got it right:
Apparently the difference is that /mnt is where the system auto-mounts stuff, /media where it puts manually mounted stuff.
Nope. It's the opposite. The system will automount things under /media - specifically under /media/$USER.
And in the second case the mounted partition is tied to the specific user, inheriting the user's permissions (what permissions do /mnt-mounted partitions inherit? Root?).
Nope. There is no inheritance of permissions. Access to a given file must follow a path. If you put up a road block anywhere along that path to a specific user or group of users then you prevent them from accessing that file. That is what /media/$USER does.

/media/altair/GoodStuff may have permissions of 777 allowing everyone and my Aunt Tilly access but /media/altair will only allow me to get to the GoodStuff folder.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

User avatar
Termy
Level 5
Level 5
Posts: 762
Joined: Mon Sep 04, 2017 8:49 pm
Location: UK
Contact:

Re: Need newbie explanation on /mnt versus /media

Post by Termy » Mon Jan 22, 2018 10:37 am

/media is typically used as a mount point for GUIs, such as your GUI file manager, whereas /mnt is like an all-purpose place to mount file systems. /media is also used for user-specific mounts, whereas /mnt, again, is all-purpose. /mnt is also ideal for temporary mounts. As explained previously though, just about any directory can be used as a mountpoint for a file system, so there's nothing stopping you from creating a directory in / called Bob, then mounting, say, your /home/user_name to it; why you'd want to, however, is beyond me. lol
Here to help.

I'm LearnLinux (LL) on YouTube: https://www.youtube.com/channel/UCfp-lN ... naEE6NtDSg
I'm also terminalforlife (TFL) on GitHub: https://github.com/terminalforlife

Kurt3162
Level 4
Level 4
Posts: 214
Joined: Wed Apr 02, 2014 2:05 pm

Re: Need newbie explanation on /mnt versus /media

Post by Kurt3162 » Mon Jan 22, 2018 11:39 pm

altair4 wrote:Nope. It's the opposite. The system will automount things under /media - specifically under /media/$USER.
Yes, okay, there is a confusion on terminology: By "automount" I meant things mounted in fstab, and by "manually" I mean mounting them using the File Explorer (Nemo in this case)... :mrgreen:

altair4 wrote:There is no inheritance of permissions. Access to a given file must follow a path.
Same here: What I meant is that permissions default to the user. Of course you can chmod them to anything you want.

Thanks, it confirms what I thought.

Kurt3162
Level 4
Level 4
Posts: 214
Joined: Wed Apr 02, 2014 2:05 pm

Re: Need newbie explanation on /mnt versus /media

Post by Kurt3162 » Mon Jan 22, 2018 11:45 pm

Termy wrote:/media is typically used as a mount point for GUIs, such as your GUI file manager, whereas /mnt is like an all-purpose place to mount file systems.
That sounds like a better explanation than the one in the "hier" manpage. (IMHO, YMMV etc.)

Termy wrote:there's nothing stopping you from creating a directory in / called Bob, then mounting, say, your /home/user_name to it; why you'd want to, however, is beyond me. lol
Beyond me too... :roll:
Yes, I do know Linux is the realm of unlimited possibilities, but I'm pretty happy using the defaults; I'm using the computer to get work done, so if the OS gets out of my way it can have his.

altair4
Level 19
Level 19
Posts: 9156
Joined: Tue Feb 03, 2009 10:27 am

Re: Need newbie explanation on /mnt versus /media

Post by altair4 » Tue Jan 23, 2018 8:09 am

Kurt3162 wrote:
altair4 wrote:Nope. It's the opposite. The system will automount things under /media - specifically under /media/$USER.
Yes, okay, there is a confusion on terminology: By "automount" I meant things mounted in fstab, and by "manually" I mean mounting them using the File Explorer (Nemo in this case)... :mrgreen:
Things in fstab will mount where you tell it to mount so there is no "default" location. I have from time to time assisted folks out of the mess created by the Disks utility which seems to want to mount things under /mnt but that is a peculiarity of Disks not Linux.
altair4 wrote:There is no inheritance of permissions. Access to a given file must follow a path.
Same here: What I meant is that permissions default to the user. Of course you can chmod them to anything you want.
Permissions do not default to the user at the mount point level unless you are talking about a non-linux filesystem such as NTFS and that only happens because NTFS has no Linux permissions. Instead, Ubuntu creates a "view" of that partition giving it a set of predetermined permissions that look like Linux permissions but are immutable throughout the mounted partition.

Thanks, it confirms what I thought.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

Kurt3162
Level 4
Level 4
Posts: 214
Joined: Wed Apr 02, 2014 2:05 pm

Re: Need newbie explanation on /mnt versus /media

Post by Kurt3162 » Tue Jan 23, 2018 10:29 am

I see, thanks.

Post Reply

Return to “Newbie Questions”