Skip to content

Instantly share code, notes, and snippets.

@natritmeyer
Created September 19, 2013 09:40
Show Gist options
  • Save natritmeyer/6621231 to your computer and use it in GitHub Desktop.
Save natritmeyer/6621231 to your computer and use it in GitHub Desktop.
How to mount and unmount a SMB share on Mac OS X (using mount_smbfs)
#Mounting the share is a 2 stage process:
# 1. Create a directory that will be the mount point
# 2. Mount the share to that directory
#Create the mount point:
mkdir share_name
#Mount the share:
mount_smbfs //username:[email protected]/share_name share_name/
#Unmount the share:
umount share_name
@kfix
Copy link

kfix commented Sep 25, 2022

If you're wondering why this won't work for connecting with a very old share (Win98!) in monterey and you see:

joey@ghostbook mnt % mount_smbfs //tinyking98/c tinyking
mount_smbfs: server connection failed: Unknown error: -5996

this shows up in Console.app:
smb1_smb_negotiate: Support for the server TINYKING98 has been deprecated (PreXP), disconnecting

adding this to /etc/nsmb.conf doesn't help:

[default]
# allow SMB 1+2+3
protocol_versmap=7

edit:
It turns out this notice is present in older versions too; google shows a complaint on El Capitan, I got it in Catalina.
you can find the source of the error log here:
https://github.com/apple-opensource-mirror/smb/blob/98c9fff3ade4b449013c0d106c45b6ffb35cf609/kernel/netsmb/smb_smb.c#L421

else where in that codebase, we see that
#define SMB_ENETFSNOPROTOVERSSUPP -5996
😭

it only seems to show when using the mount_smbfs tool and not via the Finder.

I have an old PPC eMac running 10.5.8 (Leopard) and the mount succeeds on there!

@bilogic
Copy link

bilogic commented Jun 22, 2023

Can update the gist for Monterey which requires adding WORKGROUP?

mount_smbfs //'WORKGROUP;username':password@remote-host/shared local-mount-point/

@arisolt
Copy link

arisolt commented Jun 22, 2023

mount_smbfs: mount error: /Users/machenchi/shareDev: No such file or directory
But I have made a dir with mkdir /Users/machenchi/shareDev

@vaxilicaihouxian @mwmcode I had the same issue. I fixed it by putting the last argument (i.e the mounting point) in quotes. So, the original command becomes:

mount_smbfs //username:[email protected]/share_name "share_name/"

@mbyrne00
Copy link

mbyrne00 commented Aug 16, 2024

For those who keep getting File exists without sudo it may be that you already have that drive mounted in Finder. In my case I was exploring the drive in finder. When I unmounted that it worked a charm.

Details and an automation script available: https://stackoverflow.com/a/78877529/945789

@eshenxd
Copy link

eshenxd commented Jan 4, 2025

For those who keep getting File exists without sudo it may be that you already have that drive mounted in Finder. In my case I was exploring the drive in finder. When I unmounted that it worked a charm.

Details and an automation script available: https://stackoverflow.com/a/78877529/945789

so it is!

@omf-its
Copy link

omf-its commented Mar 25, 2025

Just tested and confirmed this also works:

mount -t smbfs //username:[email protected]/sharename mountfolder

You can leave the password off and be prompted for it.
You can leave the username off if it matches your current username.

mount -t smbfs //server.name/sharename mountfolder

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment