Search code examples
macosterminalosx-elcapitan

Where does this extra folder with \ 1/ came from


so I have external hdd hooked up with 2015 early mac book pro, usually when I want to access it I just type in cd /volumes/MAC -ls, will show all the files and folder in it.

Due to not ejecting properly, now I can't access that folder. Rather I see a new folder with same name like - cd /Volumes/MAC\ 1/. And I see all my files and folder in this folder.

Can anybody shed some light on it. Thanks


Solution

  • This is probably happening due to a quirk of the way unix (and hence macOS) mounts volumes. They don't actually mount as folders, instead they mount over top of existing folders. Thus, when macOS detects that you've plugged in an external drive, it normally does something like this:

    1. Figure out what the volume's "name" is
    2. Create an empty folder named /Volumes/[volumename]
    3. Mount the volume on that folder

    When you unmount the volume, it does the reverse: it does the actual unmount, then deletes the folder it was mounted on. But if something goes wrong, and that folder doesn't get deleted, the leftover folder can cause this to happen when you attach the drive:

    1. Figure out what the volume's "name" is
    2. Try to create an empty folder named /Volumes/[volumename]... Oops, that already exists, better try something else.
    3. Try to create an empty folder named /Volumes/[volumename 1]... Whew, that worked; we'll use that
    4. Mount the volume on the /Volumes/[volumename 1] folder

    Fortunately, the solution is pretty simple: check the leftover /volumes/MAC folder (or whatever it is using that name), make sure it doesn't contain anything important, delete it (or at least rename it), then cleanly unmount & remount your volume -- with the correct name available in /Volumes, it should mount without the " 1" suffix.