Making A Linux File Server That Interacts With OS X Mavericks.
This is a non-development tutorial, but with Mavericks being really new there are no tutorials to make your file server interact with the OS smoothly. Because of this, I’m writing this small tutorial to setup your server to share files with OS X Mavericks. This may or may not work with OS X Lion and OS X Mountain Lion, but you lose nothing trying, right?
Last weekend I decided to ditch my Windows Desktop altogether and to make my beautiful 27” Inch iMac my main computer. The reason I stuck with Windows for so long is that I just cannot stash thousands of Gigabytes in my iMac. In other words, storage was the only reason I was using Windows. But then I thought, wouldn’t it be great to kill my Windows setup altogether, and convert all this hardware into a file server? I said yes, and that’s exactly what I did.
I’m incredibly illiterate when it comes to Linux and file servers. This was my first time setting a file server, actually. I was going to use FreeNAS. I looked at many OS alternatives for this, but I decided to stick with Ubuntu. If you’re in a similar situation, follow along this tutorial and hopefully by the end of it you will have a working Ubuntu file server that can communicate painlessly with your Mac.
1. Things to Consider: Your File Server Won’t use AFP.
If you don’t have much of a technical background and just want to have your file server up and running, feel free to skip this paragraph.
It will use SMB (yes, Windows’ – ironic in my case, isn’t it?). Why? Apple has the nasty habit of killing many of their technologies in the background with no formal announcement, but this was spotted in some technical documents. Basically, Apple will shift from AFP file sharing to SMB2 in OS X 10.9 Mavericks. It may come as a surprise to some but many people have had problems with AFP in Mountain Lion and below. Apple is dropping support for their own protocol in favor of Windows’ because it is more secure (or so they say).
There were many problems I had when I was first setting my file server up. I actually had no idea what this AFP protocol was, much less that it was being deprecated. When I first set the file server up, I used this tutorial to make Ubuntu announce and interact with OS X via AFP. I had no problems following that tutorial, but at the time of testing the problems were obvious. I was able to connect to my file server exactly once – then I restarted the server, and OS X Mavericks refused to connect anymore, burping this error message instead:
“The version of the server you’re trying to connect to is not supported. Please contact your system administrator to solve this problem.”
Googling tirelessly for hours I never found a solution to get that setup to work. I learned AFP was being dropped, and no one ever suggested a working around (there were a few workarounds, but none of them worked for me). So I just started over with a new Ubuntu Installation, and luckily, I succeeded putting my file server up.
Requirements for the File Server
I will not talk about the hardware requirements here. Personally I transformed an old computer into a file server. I assume you already have some old hardware lying around that you can use. But in case you’re curious, this is my server’s setup:
- 5 internal 1TB hard drives.
- 12 GBs RAM
- VGA 1680 x 1020 Monitor
You can probably tell I won’t guide you through installing SSH to remotely control the server, as personally I control the server physically since it is next to my main computer anyway.
As for the software requirements:
- Ubuntu Server. It probably works with the “normal” Ubuntu Desktop, but this is what I use. At the time of this writing, the latest version is Ubuntu Server 13.10, and you can get it here.
- Samba. We need this so our server can be talked to with SMB. I will guide you through this.
- Avahi (Optional). This isn’t needed but it does something really cool – announce the server via Bonjour. If you want to install this, I will guide you through.
1.1 So no Netatalk, then?
If you’re one of the poor souls who couldn’t get the Ubuntu File Server work properly with OS X Mavericks or (Mountain) Lion, you’re probably asking yourself why we aren’t using Netatalk.
Like I said at the beginning of this tutorial, we will be using SMB instead of AFP. Netatalk provided the required tools to talk to your server via AFP. Since Apple will most likely get rid of AFP completely at some time, we don’t need to use it at all.
2. Preparing the File Server
Installing and Configuring Ubuntu Server
How to install the server from scratch is out of this tutorial. I will focus mostly in Samba to make sure your Ubuntu can actually talk to your OS X. So go ahead and install it, as barebones as you can/want. I didn’t do any different than clicking “next” until the installation started.
Just make sure you use a different computer and account name. There seems to be some sort of conflict when OS X has the same account name as the file server.
Additionally, you will need to give Ubuntu an static IP address or use a .local name. Personally I gave the Ubuntu machine an static IP. Much easier to work with with my home network.
Installing and Configuring Samba: A Very Important Piece of the File Server
This is the most monotonous and longest part, but it isn’t so bad. Make sure you’re ready to spend 15 minutes of your time. To get this right I actually had to follow two different tutorials, and I have compiled them into one for you:
Step 1: Open Up The Terminal
I hate silly steps like this but let’s put them in for the sake of completeness. Open up a terminal window. We’re going to do everything as root to save ourselves the constant “sudo”. Type in:
sudo su
We’re going to be editing a few files later on. I like to use Linux’s included gedit to edit said files. Others may prefer, to use Nano, Vi, Vim, etc.. In case you’re like me and prefer a nice GUI, please install gksudo. This is irrelevant to the tutorial, but you shouldn’t execute GUI programs via the command line with sudo, even when you do need superuser permissions. Instead, to execute GUI programs via the command line with sudo permissions, execute them with gksu (or gksudo) instead. To install gksudo:
apt-get install gksu
To use it when you aren’t using the command line as root:
gksu gedit somefile
Or:
gksudo gedit somefile
When you want to share new directories via Samba later on, you will need to edit a file, and if you like gedit, you better use this to launch it instead of sudo from now on. So maybe it is a very little relevant after all!
Step 2: Install and Configure Samba for the File Server
With your shiny super user permissions, it’s time to install Samba:
apt-get install libcups2 samba samba-common
Once it’s done installing, we have to do a couple of configurations. We need to edit
/etc/samba/smb.conf
now:
gedit /etc/samba/smb.conf
This will launch gedit with Samba’s configuration file. Press Ctrl + F and type in “security =” so you’re taken to this area:
[...] # "security = user" is always a good idea. This will require a Unix account # in this server for every user accessing the server. See # /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html # in the samba-doc package for details. # security = user [...]
Remove the comment (the pound sign) from the last line, and add
username map = /etc/samba/smbusers
below it, so you have:
[...] # "security = user" is always a good idea. This will require a Unix account # in this server for every user accessing the server. See # /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/ServerType.html # in the samba-doc package for details. security = user username map = /etc/samba/smbusers [...]
Save (Ctrl + S) the file and quit gedit so you have control over the terminal window with su.
Restart Samba when done:
service smbd restart
Step 3: Creating Samba Users
Samba users are needed to interact with the file server.
The steps to create Samba users are simple as 1,2, which I will guide you through:
- Create a password for the user you want to create.
- Add that user to to the Samba users file.
To create the password for the Samba user:
smbpasswd -a <username>
Where username is the name of the new Samba account you want to create. For example:
smbpasswd -a Andy
Then open the
/etc/samba/smbusers
file:
gedit /etc/samba/smbusers
And add the username like this:
<username> = “<username>”
To the left you put the name of the Ubuntu account that will have to this Samba account, and to the right, the name of the Samba account it has access to.
So if my Ubuntu account is called “andyfileserver” and the Samba account is called Andy, it would be like this:
andyfileserver = "Andy"
Save the file and restart Samba once again.
service smbd restart
And that’s it! You can now connect to your file server with your OS X Mavericks by going to Finder > Go > Connect to Server…
Sharing Folders
This is really out of the scope of the tutorial. There are many configurations for shared folders, but to get you started, you add some entries to your
/etc/samba/smb.conf
file. Open it and add your entries at the end of the file, like this:
[theroot] comment = File Server path = /media/andy read only = no writable = yes [bluray] comment = Optical Drive path = /cdrom read only = yes writable = no
You essentially mount directories. What is in the first [] brackets is what your Mac will see as their name in the file server. I have “theroot” and “bluray”, so for me this looks like this:
Again, there are many configurations so you may want to look how to configure Samba share folders for your needs. you can even assign different permissions and everything.
3. (Optional) File Server Announcing to the Network
You have finished the most important part and basically you can use your file server now, but this little extra step is cool in my opinion. Instead of having to do Finder > Go > Connect to Server… Every time we want to connect to the server, why don’t we show up in Finder’s left bar?
To do that we need to install Avahi. Avahi is a simple file server daemon that announces to the network when it has connected, basically Bonjour. With this instead of telling OS X Mavericks to find the server, we can tell the server to tell everyone when it’s connected. In that way our server will appear as extractable media in the left bar of any finder Window, and it’s much easier and pleasant to interact with it using this method.
Luckily, installing and configuring Avahi is really fast and simple.
If you still have your su terminal window, type this in:
apt-get install avahi-daemon avahi-utils
Then open and edit the file
/etc/avahi/services/smb.service
(the file will be blank and that’s fine – you’re creating it from scratch):
gedit /etc/avahi/services/smb.service
And copy and paste this into it:
<?xml version="1.0" standalone='no'?> <!DOCTYPE service-group SYSTEM "avahi-service.dtd"> <service-group> <name replace-wildcards="yes">%h</name> <service> <type>_smb._tcp</type> <port>445</port> </service> <service> <type>_device-info._tcp</type> <port>0</port> <txt-record>model=RackMac</txt-record> </service> </service-group>
And that’s it! You don’t even need to restart Avahi. It will automatically announce to the network and your Mac will see your file server in Finder to the left.
And that’s it! I hope you find this tutorial useful, as personally I had a hard time configuring my file server to talk properly with OS X Mavericks.
Linklist:
These are the original tutorials I used:
http://www.howtoforge.com/ubuntu-13.04-samba-standalone-server-with-tdbsam-backend
http://www.howtogeek.com/howto/ubuntu/install-samba-server-on-ubuntu/
http://www.macdweller.org/2012/05/13/samba-bonjour-with-avahi/
Nice guide! Helped me a lot. But it’s writable and not writeable in your section of [theroot]
English fail from my part. Thank you for pointing it out! I have edited the article.
Great Guide! I have encountered a problem though…… Using the cmd+K method of talking to Ubuntu works great and after that I can also access my Ubuntu machine via the left column in finder, however, if I go straight to use the left hand column it complains when I double click the shared folder. The message I get is…
‘The opertation can’t be completed because the original item for “” can’t be found’
It would be nice to be able to use the left hand column without having to first connect using cmd+K. Is this possible?
Thank you.
It is entirely possible… That’s how it is supposed to work and how it works for me. I’ll try to think of things that may be causing this but that’s how it is supposed to be. What Ubuntu version are you running?
I got this error when I wasn’t authenticated. Once the password for the server was added to my keyring, the errors went away.
Thanks heaps for this. I have a little renderfarm (more of a render allotment really) which was working perfectly until yesterday using the same old AFP tutorial you referenced. Oddly it’s been working for the last few weeks since I upgraded to Mavericks but then then yesterday it just stopped working! I could see the ubuntu shared drives from my Mac and I could connect to my Mac from the ubuntu machines but I couldn’t get the mac to connect to them. Your tutorial above fixed it all again 🙂
Now I just have to get my screen sharing working again…
Hi thanks for this post, but I’m on Mavericks connecting to an Ubuntu server with Samba 3.6.3 (which I’m told supports SMB2). When I copy a 169mb file from my server to my Mac desktop (wired, Wi-Fi off) it takes 41 seconds on SMB but only 31 seconds on AFP.
I hope Apple stick with AFP!
Because smb2 is still considered ‘experimental’, you’ll need this in the global section of the smb.conf:
max protocol = SMB2
This improved my performance almost to the speed of NFS.
SMB2 still don’t working properly on mavericks and ubuntu samba.
The best choice for this moment is Netatalk 3 from http://netatalk.sourceforge.net/. Great tutorial you get on this site http://asaplol.wordpress.com/2013/11/27/upgrading-netatalk-on-your-diy-time-capsule-and-adding-better-support-for-mavericks/
i’m spend many days to configuring i testing my ubuntu server. I have 2.5 TB of files, and samba only make me sick.
On afp protocol i have transfer up to 100 MB/s. On SMB only 50 MB/s. Searching not working properly, and lags many many lags and many many bed words 😉
Try, this is only 5 min to install netatalk
Good luck
MAX
It looks like the upload issue can be solved as per Tom’s comment above.
It still does not work for me. I have a transfer speed of only 54 MB/s (on AFP its over 110 MB/s) Tags appear and disappear. Finder hangs. After entering a few folders I have to wait even a few minutes. Searching not working at all. Big crap 😉
Must be an specific problem on your side. I have done this setup 3 times already and never had an issue personally.
Tested with a 4.5GB file over GB ethernet:
NFS
real 1m15.509s
user 0m0.007s
sys 0m18.276s
SMB
real 1m10.303s
user 0m0.008s
sys 0m4.441s
So it’s actually a bit faster than NFS…
Thank you so much! You got me up and running so I could share some old files on my Linux box with my roommate (who used to share my machine but is now on his own Mac Mini). I am a long-time Linux user/admin, but I didn’t know the status of stuff these days with Mac. I’m really glad you showed up high on Google’s results (I searched for “serve files out to my mac from linux”). I have set up Samba before, and it has taken hours. This is awesome. My roommate is over across the room looking at his old pictures and saying, “Oh, Yeah! That was fun, that party!” .. and I don’t have to search for the files he wanted, anymore. He will have to search for them, himself, via his SMB2 connection! Hah!
(And thanks also to Tom for the max protocol = SMB2 tip!)
Mavericks can still use AFP if you issue the following command in OSX:
defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1
With avahi-daemon also installed, running, and configured with default options:
I was able to simply modify the “Home Directory” line in the /etc/netatalk/AppleVolumes.default, simply adding “options:tm”, restarting netatalk, then use my server home directory for time machine, in addition to mounting it via finder.
I tested the theory that it won’t work after reboot. I rebooted my mac. If I go to finder, hit command-k, hit browse, browse to my server, mount my home directory, the directory appears again in time machine and will do a backup. However, time machine will not mount the volume automatically.
In other words, i can still do a time machine backup using AFP over netatalk to a Linux machine, I just have to remember to mount it via finder for it to work.
-John
Hello, thanks for taking the time to write this tutorial. Will this allow me to backup my mac running Mavericks via time machine to my Ubuntu server? I’m confused as most sites say to use AFP for timemachine backups.
Personally I don’t use Time Machine as my backup mechanism, but according to a few sources it should be possible to use SMB instead.
Thanks for this, particularly liked the explanation of the avahi service.
Thanks for the instructions! I want to set up a ubuntu home server like this, but I’m stuck. I’ve opened the smb.conf file, but it doesn’t have the text you are showing regarding security = user. Should I add it? Why is there a difference?
I have no idea why it should have difference as I have never had that problem when setting this up. Try creating it and let me know how it goes so I can update the tutorial.
I was walking through this setup as well and during Step 2 there is no “security” entry in the smb.conf file. I went ahead and added the entries to test it out and restarted the service. The new folder that should have appeared in /etc/samba/smbusers did not and if you start to proceed with the account creation, it throws the error “WARNING: Ignoring invalid value ‘users’ for parameter ‘security’, and then gives you a prompt to type in the password for the new SMB user, however, if you type it in, obviously it fails as there is no user map. I am going to assume Sammy is running the most recent version of Ubuntu as well, I am on 14.04. Willing to do some testing for you to assist in keeping this tut up to date.
If you want to point out errors and help me tweak things in this tutorial you are more than welcome. I ditched my Linux server a while ago and haven’t set up a new one since then. If anybody wants to help me keep this tutorial updated, feel free to do so.
Thanks for this great tutorial. Everything looked like it was great. But then I bumped into this problem.
Scenario:
You have a folder with the name 1, in that folder you have the folders 11 and 12 and some files.
In folder 11 there is a file. If only one user is logged in and user 1 changes a name of a file in folder 11, if he then tries to move folder 11 into folder 12 … mac os x will tell him he has not permission and will ask for admin rights (which of course do not work, even if you would have it)
I know some say this has to do with file preview, but I have tried this… I can recreate this even with “show preview column” turned off.
You can also see that the files is locked by running: smbstatus -L
the only way to solve the problem is to disconnect the user and then reconnect.
oh and by the way, this is how a share is setup:
[smb_share]
comment = smb main share
path = /srv/smb_share
read only = no
writable = yes
valid users = +groupname
force security mode = 664
force directory security mode = 775
force group = groupname
Can you reproduce this?
I have experienced something similar but now that I have ditched my Ubuntu Fileserver I can’t try to do it again. I do remember it telling me that I needed admin rights when trying to move files sometimes for no reason, though, and I remember reconnecting did the trick.
Thanks for the reply. Yes, I think this is a bug on the os x side and will probably force me to go back to netatalk/afp. Why did you ditch the ubuntu fileserver… was it that bad 😉
Nah, it actually worked wonderfully for the most part. It talked well to my Mac (except for that one bug) and to Windows machines who connected to my Network, so it all worked nicely.
I ditched because it was running in old computer hardware (it was my old computer turned server, basically), but the motherboard died, and instead of making another fileserver I decided to get a NAS instead.
Ah… I see.
Yes…. but sadly right now that bug is very critical… especially if used in a production environment. But I just found a text about one of the Netatalk developers (Böhme) looking on how to port netatalk users to samba… so it looks like you where right when choosing samba. I will have to see if I can get hold of samba developers and see if they can do anything about it… but I am afraid this is a bug on apples side… and filing a bug to apple is not fun :/, at least not waiting for them to fix it 😉
I forgot to mention one annoying bug I had, but it was with Linux itself.
Apparently Linux (or just Ubuntu?) really suck at handling folders with many (3000+) files. It was hard to load the folders in both the fileserver itself and via my Mac. It looks like we cannot have a 100% reliable file server yet, but we are getting there.
I see… sounds weird. I have really big folders with lots of nested folders and files… and they work fine. Or do you mean a folder with 3000+ files in that one folder?
Might it have been the computer that was to old (I remember you said it was a old machine)?
Actually seems to be a problem with Nautilus itself.
Have you ever encountered this issue before: on MAC OS X 10.9 when i browse shared folders from my Ubuntu Samba file server, random folders will disappear after about 1 second. So when I open a folder that has multiple files/folders in it, i can see all files&folder and after less than a second some of the folders simply disappear. On my Windows machines connected to the same Smb file server, i can see & access all files/folders at all times.
Can’t say I have had that problem. Sorry.
I have!
Do you use any special characters like : or something like that?
All my folder names use Alphanumerical characters and underscores at most.
Andres, many thanks for your guide. Good job.
Hi, geat tut, but i ran into problems while adding new users. I try to add a second user, and when I write “smbpasswd -a ” i get “Failed to add entry for user ” If you have any idea on how to fix this, it would be greatly appreciated.
Yours was the only tutorial that got my smb.conf on my Debian server working with OS X Yosemite. Thanks!
Great article. Thanks to you my Yosemite/Linux puzzles are fixed. Thank You.
Your instructions worked perfectly on the current version of Debian (8.0 jessie). Thank you. Note that the Debian smb.conf does not include “security =” but that’s okay because the system default is “security = user”. I just added “username map = /etc/samba/smbusers” as the first entry under [global]. Also of note under Debian is that “server max protocol = SMB3”
By any chance, do you know a solution to make samba show only the shares enabled for the connecting user? I have multiple users on my NAS and – just like with afp shares – I wouldn’t want them to see each others’ volumes. I can control who has permission to mount what, but it still shows everything in the list, even the ones the user has no permission to mount.
Seems like I found a way. The shares should be set to “browseable = no”, “valid users = username” and (here comes the magic) “include = /etc/samba/%U.sharename.conf” . %U gets expanded to the name of the user’s home folder, so this way you can apply per user, per share based configurations. A username.sharename.conf file under /etc/samba , containing “browseable = yes” can determine if the volume should be visible for the connecting user or not. Finally everyone can only see and mount what they are permitted 🙂
Where does this sit now, given that the original article is a couple of years old now?
I have a media centre setup without a keyboard (only a basic remote control for the kids), but after sometime I can no longer access the shared folder.
Macmini running Yosemite, server running Ubuntu 14.04 LTS (at the time, but now 15.10). shared via Samba setup.
I came here as a result of searching for Netatalk (which is referenced in the article) and seems to be the opposite of what I’m finding elsewhere on the web today. This is the first page that suggests samba over netatalk, and when searching from samba dropouts, it seems I’m not alone, and the clear answer is netatalk.
So, back to my question, do the others that have posted here still believe samba is the NEW/right/better way, or have people moved on to netatalk or something entirely different?
I did try to run my ubuntu server for a office of about 20 users, but soon dropped that idea because of all the problems I was having. Especially speed was really bad. Now this is a long time ago and maybe I should try it again, but that was my experience at that time, Netatlak is still better. But then again, one of the developers of Netatalk has stated that they are moving towards SMB and will drop Netatalk, so I guess at one point you will have to do the move to SMB.
I drive my servers since a long time with netatalk without any problems. It runs very smooth without any glitches. Also a TimeMachine support is only realizable with AFP/ netatalk. The statement of this article regarding the end of AFP is near to 3 years old and more or less inaccurate – nothing is happen. Might be Apple will move one a day completely to SMB/CIFS but I guess this will not happen in a near future that Apple will removing the AFP protocol support completely.
Netatalk is beyond in development. The last version update was published at middle if December 2015
http://netatalk.sourceforge.net
It’s ok to use smb for a mixed OS environmentif there also Windows users which should access file shares … for a clean OS X / iOS environment I suggest strong o use AFP.
@rbn: Netatalk is a freely-available Open Source AFP fileserver. It isn’t AFP … so each statement of netatlk developers isn’t an statement of Apple regarding AFP.
Thanks for your excellent reply. I don’t have any Windows boxes and so am happy to go with netatalk, but if I do, are guest window systems able to access them at all?
By default Windows systems could not access AFP shares. There are some payable clients available but of course this isn’t an option for an quick access.
Since guests in the most cases shouldn’t have access to the “normal” infrastructure it could be an option to offer in addition a guest share via smb – or via WebDAV which is supported also by the new Windows versions. I solved such issues in another way as I drive also an owncloud-Server on which I could share some things for guests or far away remote users.
Dont know if I was unclear in my text, english is not my first language, but Fischmuetze is of course right, Netatalk is not Apple in any way. I was only referring to developers of Netatalk that have stated that they will not continue to develope Netatalk because Apple has stated they will move towards SMB.
But as you say, this has been stated by apple for a long time now, and they are not even close to going that way. So I would also choose Netatalk over SMB, and have also done so for several companies I do the support for.
What file system should one use for this? exFAT does not have the journaling that I need, and my external drives are too large for FAT32. As far as I can tell, linux does not support HFS+.
Use ext. It is Linux’s native filesystem, and it has good support. I’d use ext3 or ext4. I believe I was using ext3 when I wrote this.
Does OS X support these natively? My users aren’t going to want me installing a bunch of extra crap on their macs, and I would rather not have more software to worry about.
It’s your fileserver that is going to have the filesystem. It shouldn’t matter because OS X won’t be mounting these drives directly.
I have a working samba share (using local samab server IP) and a working ssh through my DDNS client (connecting to a terminal prompt from any internet connected computer. How can I configure the samba server connection on my mac to use the DDNS address to access my samba share instead of the local IP address. I am somewhat new to the whole SSH tunneling thing so details are appreciated.
I was able to setup the samba share successfully thanks for that. What would I need to do to access this share through a tunneled SSH connection. I have a duckdns setup on the server and can ssh to it, but I don’t know how to access the resources other than terminal. Thanks in advance.
Unfortunately I don’t know the answer to your specific question, but I’m approving your comments in hope someone else does so I can update this with that info.
I followed this tutorial and I notice you have a picture of a nas or mac next to the device. mine shows a windows computer, why isn’t mine showing a mac? did you do anything special?
There was a way to specify what icon you wanted for each device editing a plist… Unfortunately I can’t seem to remember or find how it was done.
Uhm, what? I run macOS Sierra and use AFP shares (netatalk), including Time Machine, on a daily basis.
Is anyone having an issue with Finder Tags and SMB share? I can tag a file with a colour. But when I go view in the tags it does not show for any SMB shared files? I have tried everything. Finder is creating s DS file. I have made opened up the permissions etc. Just refuses to show the coloured tags? Anyone know why? If this does work for you please could you share you config.