How to remove duplicate "ghost" network drive on OS X?

Mac OS X mounts drives by default by creating a folder with the name of the drive in /Volumes and then mounting it at that point (so a drive is normally accessible via /Volumes/NAME_OF_DRIVE). Mac OS X will append a -# after the name of a hard drive if multiple drives of that name are mounted. (eg. /Volumes/NAME_OF_DRIVE-1 and /Volumes/NAME_OF_DRIVE-2, etc.) This will also occur if a folder exists in /Volumes/ by that same name. Even though the mount point has a different name the name of the drive will show correctly in the Finder.

An example of what can cause an erroneous folder:

A script or application that writes a file to /Volumes/ExternalDrive/somefile.txt or even an application that when checking if a file exists (eg. open last saved document) creates a new document at that location when the hard drive/network share/USB key/etc. is not mounted. The file will exists at /Volumes/ExternalDrive/somefile.txt meaning the folder /Volumes/ExternalDrive will exist when you next mount.

Fixing this:

  • Ensure all drives have been unmounted - use Disk Utility or diskutil list to be sure
  • Check to see what can be seen in /Volumes/ - recommended to use the Terminal and use ls -laF /Volumes. There should only be one folder (NAME_OF_STARTUP_DRIVE -> /)
  • Delete the remaining folders. (I'd recommend checking the contents first)

Ok, so I first turned off my drive to make sure nothing was deleted.

Then in terminal I typed:

sudo rm -rf Lacie-1

Great news, this works. I turned my drive back on and everything was fine.

I did find the cause however when I tried to do my time machine backup. Time Machine is actually creating this ghost drive for backups. I don't know why.