Symlink does not work for shared folder between Mac and Linux

Hello,

I created a shared folder on my MacOS Mojave. Then I mounted it on my Linux machine (CentOS 7) with


sudo mount -t cifs //mymacbook/mysharedfolder /home/jczhang/mysharedfolder -o noauto,user,username=jczhang,password="XXXXXX",noperm,mfsymlinks,uid=jczhang,gid=jczhang


On the Linux side, I found the symlinks were wrong. A symlink created by Mac turned into something like this in Linux:

-?????????? ? ? ? ? ? configure.log

(Please note the link does not point to out side of the shared folder)


I can create new symbol links in the shared folder in Linux, e.g.,

lrwxrwxrwx. 1 jczhang jczhang 9 Jun 27 10:48 hello.sl -> hello.txt

-rwxr-xr-x. 1 jczhang jczhang 0 Jun 26 13:04 hello.txt


However, in Macbook, the symlink is wrong,

-rw------- 1 jczhang jczhang 1067 Jun 27 10:48 hello.sl

-rw------- 1 jczhang jczhang 0 Jun 26 13:04 hello.txt


How to fix this? Thank you!

MacBook Pro 15", macOS 10.14

Posted on Jun 27, 2019 9:12 AM

Reply

Similar questions

16 replies

Jun 28, 2019 8:24 PM in response to jczhang

FYI, the Linux mount command still references "cifs", but should be able to connect to current SMB version shares. Check out the man pages for "mount.cifs" which mentions being able to connect using a specific version of SMB.


From Debian 9 Stretch man mount.cifs:

vers=
           SMB protocol version. Allowed values are:

           ·   1.0 - The classic CIFS/SMBv1 protocol. This is the default.

           ·   2.0 - The SMBv2.002 protocol. This was initially introduced in Windows Vista Service Pack 1, and
               Windows Server 2008. Note that the initial release version of Windows Vista spoke a slightly different
               dialect (2.000) that is not supported.

           ·   2.1 - The SMBv2.1 protocol that was introduced in Microsoft Windows 7 and Windows Server 2008R2.

           ·   3.0 - The SMBv3.0 protocol that was introduced in Microsoft Windows 8 and Windows Server 2012.

           Note too that while this option governs the protocol version used, not all features of each version are
           available.



I know years ago I had trouble even connecting to an SMB share created on a Mac (from both Linux and even a newer version OSX). It definitely does not surprise me that a Mojave share could be problematic. If Apple implements something differently in their version of SMB, then Linux won't know how to handle it (or the other way around). Perhaps there is something in the way APFS handles things that isn't translating properly with the SMB share.

Jun 28, 2019 11:31 AM in response to etresoft

My MacOS is latest and my Ubuntu is also new. Since CIFS claims it is the successor to SMB, I don't think it is because I used out-of-date stuff.

I created shared folder on Mac through its Sharing>File Sharing. Mac has nice hints in the Sharing window saying other users can access shared folders by afp://xxx or smb://xxx. No wonder it has severe flaws.


My temp solution is to use SSHFS, which is very easy to use and the speed is ok.

Jun 27, 2019 1:47 PM in response to jczhang

I do not think CIFS (and maybe not SMB) know what a symlink is, and thus do not have a file sharing network protocol for presenting that information on the client system.


But since CIFS is an older file sharing protocol, you should at least try specifying mount -t smb ...


You might try NFS. If the Linux system has the file system (or at least the directory tree) exported, from your Mac you could try

/net/linux.system.network.name/path/to/symlink/file


I have not played with NFS exporting anything from macOS, so your mileage may vary, but it may be possible. MrHoffman would have a better clue if you can catch his attention, or try Google.

Jun 28, 2019 3:24 PM in response to jczhang

What was once called SMB was briefly called CIF a dozen-or-so years back, and is now called SMB again.

If whatever you're using calls itself CIFS, it's ancient. It's also badly insecure, if it's really CIFS (or SMB1).

Or somebody hasn't been keeping up on the shifts in terminology. Which is quite possible.

The SMB2 protocol supports symbolic links with NTFS, though whether any other implementations also do?

There are folks that have gotten this to work, and some a long time ago.


Jun 29, 2019 6:22 AM in response to jczhang

I just did some experiments with my Synology (a Linux based NAS)


Finder -> Go -> Connect to server -> smb://synology.local


Synology

drwxr-xr-x  1 raharris users     0 Jun 29 09:01 tmp.dir.real
lrwxrwxrwx  1 raharris users    12 Jun 29 09:01 tmp.dir.symlink -> tmp.dir.real
-rw-r--r--  1 raharris users    29 Jun 29 09:02 tmp.file.real
lrwxrwxrwx  1 raharris users    13 Jun 29 09:02 tmp.file.symlink -> tmp.file.real


macOS Mojave

drwx------  1 raharris  staff  16384 Jun 29 09:01 tmp.dir.real
drwx------  1 raharris  staff  16384 Jun 29 09:01 tmp.dir.symlink
-rwx------  1 raharris  staff     29 Jun 29 09:02 tmp.file.real
-rwx------  1 raharris  staff     29 Jun 29 09:02 tmp.file.symlink


I do not know if the Synology smb server (most likely running Samba) decided to just say it was a regular directory and a regular file, or if macOS's home grown SMB client decided to make the symlinks look like regular dir and file.


I then did this between 2 Macs, and in this case symlink information was transferred. Of course as this was Mac to Mac both using Apple's home grown SMB server and client, we do not know if Apple slipped some additional protocol messages into the mix so that macOS specific features could be transferred.


Finder -> Go -> Connect to server -> smb://El_Capitan_Mac.local


macOS El Capitan (HFS+ file system)

drwxr-xr-x  2 raharris  staff   68 Jun 29 09:12 tmp.dir.real/
lrwxr-xr-x  1 raharris  staff   12 Jun 29 09:12 tmp.dir.symlink@ -> tmp.dir.real
-rw-r--r--  1 raharris  staff   29 Jun 29 09:12 tmp.file.real
lrwxr-xr-x  1 raharris  staff   13 Jun 29 09:12 tmp.file.symlink@ -> tmp.file.real


macOS Mojave (APFS)

drwxr-xr-x 1 raharris staff 16384 Jun 29 09:12 tmp.dir.real/
lrwxr-xr-x 1 raharris staff    12 Jun 29 09:12 tmp.dir.symlink -> tmp.dir.real
-rw-r--r-- 1 raharris staff    29 Jun 29 09:12 tmp.file.real
lrwxr-xr-x 1 raharris staff    13 Jun 29 09:12 tmp.file.symlink -> tmp.file.real


Jun 27, 2019 2:16 PM in response to BobHarris

mount -t smb ... gave me "unknown filesystem type 'smb'."

From this post,

"smbmount has been deprecated in favor of mount.cifs".

man mount.cifs also shows,

"The CIFS protocol is the successor to the SMB protocol and is supported by most Windows servers and many other commercial servers and Network Attached Storage appliances as well as by the popular Open Source server Samba."


I only want to connect to Mac shared folder from Linux, but not the opposite, since I do daily development work on Mac and I want the folder to be local and fast. Only when I need to test code on Linux, I access the shared folder from Linux.


Thanks.

Jun 29, 2019 6:39 AM in response to HWTech

Thanks for the info. I tried vers=1.0, 2.0, 2.1, 3.0, 3.1.1 (or 3.11) on the Linux side. 1.0 did not work at all. Regular files got wrong. 2.0, 2.1, 3.0 only got regular files correct. Symlinks were still wrong. 3.11 was rejected. From man mount.cifs, it is said the version (if not specified) is automatically negotiated between the server and the client.

On the Mac side, the shared folder was created by File Sharing. It is not clear which protocol Apple uses.

Jun 29, 2019 6:48 AM in response to etresoft

Tried using the vers= option of mount.cifs on the Linux side to selected smb from 1.0 up to 3.0, to match MacOS (which I don't what it uses). Nothing worked.

The source code of our library uses symlinks a lot. I think it is quite common to other source codes. If symlinks do not work, shared folders become useless. That is why I said it was a severe flaw.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Symlink does not work for shared folder between Mac and Linux

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.