Mounting a device — role of /dev, /media and /mnt, and the mount command

There are a lot of questions here and I'll do my best to answer them. I'm certain that those more knowledgeable than I will be able to help you further. (I'd appreciate if those people could help me out too.)

In *nix, everything is a file. For example, your CD-ROM is a file.

  • /dev - Here you'll find physical devices as well as things you wouldn't normally think of as devices such as /dev/null.
  • /media & /mnt are directories where you may mount a physical device such as a CD-ROM, HDD partition, USB stick, etc.

The purpose of mount (and the opposite umount) is to allow dynamic mounting of devices. What I mean here is that perhaps you may want to only mount a device under certain circumstances, and at other times have it not readily accessible. You may wish to mount an entire file system at /mnt when repairing a system. You may wish to mount a disc image (e.g. foo.iso) from time to time. Etc.

You may choose to mount a device in /dev at either /media or /mnt. There are more or less correct ways of doing this. For example, from your question you say:

/media this is a mount point for removable devices

/mnt this is a temporary mount point

That's pretty much correct. Read here for how /media and /mnt should be used according to the Filesystem Hierarchy Standard. I do this pretty incorrectly, opting to use /media when in fact I should be using /mnt, most of the time. It's also worth noting that an internal HDD with associated partitions may be referred to, somewhat confusingly, removeable media.

I'm on OS X here so I can't check right now (BSD does things slightly differently regarding optical drives) but /dev/cdrom is a device file for your CD-ROM. As is /dev/cdrw. See the '->' in the ls -l output in your question? That's indicating that both /dev/cdrom and /dev/cdrw are symbolically linked to /dev/sr0. 'sr' is the device driver name; 'sr0' is the device file name.

/media/Ubuntu 11.04 i386 is simply an .iso image that has been auto-mounted at /media.

I hope that helps a bit.


The answer from boehj explains the basics pieces in play here. The one thing I would add is about the difference between a device and a mounted file system. The fact of the matter is that you can access a device node directly. For example you could use dd if=/dev/sda of=/dev/sdb to make your second ATA device an exact copy of the first one, or you can cat /dev/sr0 > mycd.iso to rip a CD and make an iso image of it.

The difference is that when you mount a device to a location, you create a path in your directory structure that accesses the device using a file system driver. The file system driver handles things all the special things that need to happen like caching, indexing, seeking, etc in order for your raw drive device to appear to you with all the conveniences of a file system.


Building on boehj's answer, mount is used behind the scenes at boot time to check in /etc/fstab to see where each existing partition that it's supposed to know about should be mounted into the actual filesystem.

Unlike with - for instance - Windows, where you don't get much of a choice beyond what drive letter a partition gets, this allows any device or partition to be mounted anywhere in the filesystem tree if you so wish -- for example, university network computers would typically only have /bin/ and /lib and a few temporary partitions mounted locally, while /usr/ (containing almost all of the software that isn't required during the boot phase) and /home/ (containing all users' home directories) would be mounted from a centrally accessible NFS server.

It's also responsible for quietly mounting various temporary and virtual filesystems such as /dev/shm/, /sys/, /dev/pts/, and on more modern systems /run/. Chances are you'll rarely if ever do anything directly with these, but a lot of software relies on these to exist behind the scenes. Take a look at the output of the bare mount command, or in /etc/fstab -- you might learn something interesting.