When using the mount utility, if you specify a directory that does not exist, that is considered an error. Is there any option I can use so that mount points get automatically created if they don't already exist?

  • 14
    Strange that the mount utility doesn't do this by default. I'm sick of typing: mkdir /media/USB, mount /dev/sdb1 /media/USB; umount /dev/sdb1, rmdir /media/USB.
    – Zaz
    Sep 14, 2014 at 21:29
  • Yep, I too wish this was a feature. Jan 8, 2017 at 4:33
  • Yeah, I understand it not doing it by default, similar to "mkdir /one/two/three" won't get created if "/one/two" doesn't exist, but shouldn't there at least be an option to force it with mount? Mar 30, 2017 at 14:59
  • 1
    HERE IS THE ANSWER: askubuntu.com/questions/88523/… - instructions for installing pmount to prevent this from happening.
    – SDsolar
    Nov 16, 2017 at 22:25
  • I tried pmount, doesn't seem to work without manually running the command with the device. found this, seems to work great (16.04, headless) serverfault.com/a/767079/453980 mounts on boot, and handles hot(un/)plugging
    – travis h.
    Jan 27, 2018 at 18:07

3 Answers 3


try this:

if you want to create a Mount Point called DISK1, then type the following command in the terminal :

sudo mkdir /media/DISK1
  • 1
    Yeah, I was hoping for an option to mount, but this is fine, I guess.
    – Paul
    Dec 17, 2011 at 21:20
  • Pulling out the drive then reinserting it will create /media/DISK2 unless you install pmount.
    – SDsolar
    Nov 16, 2017 at 22:22

No, the bare mount utility do not offer such an option.

It is done when mounting from a file manager like Nautilus, though.

  • 2
    how can Nautilus do it then? May 4, 2013 at 7:58
  • 2
    @AndreaBorga it checks if the directory exists before mounting. If the mountpoint doesn't exist as a directory, creates it and then mounts. Apr 2, 2015 at 10:41

Install the pmount utility and let it handle /media/user/ mount points automatically. No more worries about how and where /media/user/ devices mount and by which names.

sudo apt-get update
sudo apt-get install pmount

Then whenever you insert a removable device, it will automatically be mounted under /media/username/, by name.

For example: My USB stick is named "SYSBKP" so it automatically mounts as /media/pi/SYSBKP

It also handles unexpected ejects. And remounts. Silently.

  • Generally, it will pop up file manager to show you what you just mounted.

Behind the scenes it makes sure the buffers are always flushed just in case the USB is pulled without warning. No more need for sync;sync;sync like the old days.

FYI, I installed from a 14.04 LTS disk and let it upgrade me to 16.04 LTS when it offered. On a fresh SSD drive - I let it take the entire space.

In any case, pmount is a very important piece of software to have if you use /media/username/ for removable devices.

If you don't use it, the default action is to create new mount points for each insertion, with a digit appended to the name for each one. Even normal ejects cause this behavior. You end up with mount points like /media/username/SYSBKP, /media/username/SYSBKP1, /media/username/SYSBKP2, etc.- and you don't know which one is the active one.

This means you can't write scripts that assume the mount point name (unless you include all the mount commands in the script). Should you choose the wrong one it is treated as a local directory.

pmount makes sure your USB drive it has its own assigned mount point under /media/username/. In this case, it is always /media/pi/SYSBKP

It also works when you put in another USB flash drive with the same name. So it is not going by UUID.

I not only use this for flash drives, but also for fulll-size powered backup drives, for rsync backups, and have full confidence that the scripts will work without modification.

It is a simple, reliable solution to creating mount points.

Note that I have personally tested it with NTFS, FAT32 and the various EXT formatted drives. If the drive contains multiple partitions it will mount regular file systems individually by name, avoiding the swap partition. This is all visible in nautilus, and is alluded to in more detail in this Q&A:


I see in comments there is an issue with the NFS+ Time Machine drives.
It may or may not work automatically

How to access Time Machine Drives in Linux (macworld.com)


It turns out Apple does a couple slick things with the file system to make incremental backups work, including hard linking to directories, which isn't allowed in Linux. So for anyone that needs to access their Time Machine from something other than its associated Mac, here's how you do it... (see linked article for the rest)

  • 1
    "This is built into Ubuntu 16.04 LTS" It is? It's not in my 16.04 VM. packages.ubuntu.com/search?keywords=pmount says its in universe, and packages in universe are not part of the default install.
    – muru
    Aug 1, 2017 at 3:00
  • I added install instructions now, muru. TNX
    – SDsolar
    Nov 16, 2017 at 22:23
  • somehow even after installing pmount when i insert a time machine backup on a drive, it doesn't mount automatically. I've seen many posts reporting that normally it auto mounts.
    – gideon
    Apr 15, 2018 at 13:42
  • The issue with Time Machine is that it is HFS+ file system. pmount will work with NTFS, FAT32, EXT2-4 for sure. Here are instructions for using the regular mount command for Time Machine: hints.macworld.com/article.php?story=20080623213342356
    – SDsolar
    Apr 15, 2018 at 17:33
  • btw, uninstalling pmount will not solve the "sometimes it will, but sometimes it won't" problem with Time Machine drives. I've edited the answer to include info on this issue.. Thank you, gideon, for bringing this up.
    – SDsolar
    Apr 15, 2018 at 17:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .