Unix fundamentals - mount points

Today, I'm going to introduce the concept of mount points. Mount points are, in essence, folders in which external filesystems are mounted (their contents are dropped into that folder). We'll be going into that in a bit more detail in just a second. First of all, the obligatory Wikipedia definition:

A mount point is a term used to describe where the computer puts the files in a file system on Unix-like systems. For example, many modern Linux distributions automatically mount the CD drive as /mnt/cdrom, so the contents of the CD drive will appear in the /mnt/cdrom directory. A device can be mounted anywhere on the directory structure. Normally only the root user can mount a new file system but systems are often configured so that users may mount pre-set devices. A file system can be mounted by running the mount utility.

Windows, OS/2 and other operating systems that have their heritage in DOS and the old days of the IBM PC, use a drive letter structure to access different devices on the system. I'm sure you're aware of the idea of the C drive under Windows.

Well, Unix-like operating systems don't work anything like that, I'm afraid.

Let's have a quick example. I've got a 512 MB USB stick and I plug it into my PC running Linux. Behind the scenes, the operating system does the following:

  • Creates a folder called /media/PETER512 (PETER512 is the volume name of my USB stick).
  • Mounts the USB stick's contents inside this new folder

Fairly simple. So what does it actually do when it mounts the contents? Think of it as taking the contents of the device and dropping them into that folder. Now, if you browse to that folder, you can read and write the contents of the actual device, just as if it was a normal folder on your hard drive.

The folder (which is the mount point - the point where that device is mounted) can be anywhere, but it's a convention that you use /media or /mnt. Equally, it doesn't have to be a USB stick. CDs, DVDs, network drives, removable hard drives, even .iso image files, can be mounted so you can access them and interact with them.

And finally, a quick command line practical exercise. You will need to know the device string of whatever you want to mount, which unfortunately makes this process a bit geeky and difficult. In this example, I'm using /dev/sda1 (which is what most USB devices are if you have IDE hard drive).

In most cases, you also need administrator/root privileges to mount and unmount.

# mkdir /mnt/mymountpoint
# mount /dev/sda1 /mnt/mymountpoint

When you're done, you can unmount the device with umount (optionally, you could also rmdir the folder if you don't need it).

# umount /mnt/mymountpoint

Avatar for peter Peter Upfold - http://peter.upfold.org.uk/

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Unix fundamentals - mount points

  1. Alex (guest)

    # Posted on 13 April 2007 at 04:22 PM

    Actually, in Win2k and further there exist mountpoints. You may mount some NTFS volume inside another one.



  2. Peter (guest)

    # Posted on 14 April 2007 at 01:30 PM

    Ah, thanks for that clarification, Alex. I wasn't aware of that functionality.



  3. Lee (guest)

    # Posted on 18 April 2007 at 10:24 AM

    Thanks for this, just saved me when I'd reinstalled ubuntu, although I had to use mount -t ext3 is this just because it didn't know the filesystem or something?



  4. Peter (guest)

    # Posted on 18 April 2007 at 11:36 AM

    Hi Lee,

    Usually mount auto-detects the filesystem, especially with things like ext3 that are standard to Linux. Sometimes, though, you do have to give it a push and tell it what it's mounting. No idea why you had to in this case...

    And if you are reading this, what do you think of an idea for a post on how to make mount points permanent and stick on reboot? Would this be helpful at all?



  5. Lee (guest)

    # Posted on 18 April 2007 at 02:06 PM

    I certainly think it would be helpful, i managed to do it earlier but before I've not managed to get anything to stick, and it certainly isn't the most logical of tasks to do.



  6. Peter (guest)

    # Posted on 19 April 2007 at 11:03 AM

    OK, the remount on reboot post is in the pipeline. Expect in the next few days!



  7. # Posted on 20 April 2007 at 09:30 AM

    [...] I took a quick look at the Unix concept of mount points. Performing the mount command is a nice easy way to get access to something on a [...]



  8. Spuffler (guest)

    # Posted on 25 November 2009 at 01:41 AM

    These commands tend to be intended for system rescue, or a non GUI administration method.

    I say this because I'm posting in November 2009, some 2 years after this article; some Linux distros are using mount tools (hald, and so forth) where meddling like this is either potentially harmful, possibly totally ignored or even prohibited by permissions. Example: as a KDE user, I insert a flash drive into a USB port, 5 seconds or so later, I get a dialog asking what to do with the device (ala Windows XP). After I mount it using the hald method, I cannot simply drop to a command prompt and umount it.



Home » Articles » Unix fundamentals - mount points