My initial thought on this was to create an alias in my home directory, and then open it up for sharing. So to do this I created an alias of the drive in my home directory (right-click on the folder -> create alias of "FATMATT" -> drag the alias into my home directory) and then allow my home directory to be shared with samba (system preferences -> sharing -> windows sharing). This all seemed to work fine, except that linux (and windows for that matter) doesn't know what the alias is.
Well I have a solution for this I thought, I'll just soft link the directory into my home directory, certainly Ubuntu can understand that. So I opened up my trusty terminal window and went to work:
ln -s /Volumes/FATMATT /Users/matt
I go back to my Ubuntu box and it understands the soft link, and I can go into the folder and browse the contents. When I try to open anything in the samba share however, it won't do it. Well it turns out that since the actual files are ouside of the samba share, and also because OS X prevents sharing USB drives over samba shares, you're unable to open the files despite the fact that you can see what files are on the volume. Though I would recommend using soft links instead of aliases whenever possible, as through this process I discovered that a soft link is actually much faster in file browsing than an alias is (especially when using front row).
So I'm left with my final option, the one I didn't want to go with: configure an extra samba share for the USB drive. As OS X is nice enough to come with samba installed and configured for the home directories, I didn't have to install a samba server on the machine (a task that is quite daunting in Linux), all I had to do was reconfigure samba a bit.
In OS X samba's primary configuration is stored in the /etc folder as the file /etc/smb.conf, to add extra samba shares you need to configure this file by hand, so I went once again to my trusty terminal and opened the file with sudo and nano (that's right I use nano . . . just leave it), backing the file up first of course:
sudo cp /etc/smb.conf /etc/smb.conf.bak
sudo nano /etc/smb.conf
Samba's configuration is quite simple and easy to understand, it is comprised of sections denoted by starting tags of the form [start tag]. To define a share you just think of what you want the share to be called and then create a section with that name, for example my drive is called "FATTMATT" so I create the following section with the tag [FATMATT]:
[FATTMATT]
comment = FATMATT
path = /Volumes/FATMATT/
browsable = yes
read only = yes
The configuration options in the section tell samba the following:
comment = FATMATT
This option gives samba the name of the share as it will be displayed to the samba client.
browsable = yes
This value allows the samba client to browse the contents of the folder.
read only = yes
This disallows the ability to write to the share from the client, to allow the share to be written to from a client merely exchange that line with the following line:
read only = no
Once you've added your section you need to make sure of a few things. Check the ownership and permissions of the USB drive to make sure that the user you will be accessing the share as has read permission to the drive (for read only) or read/write permission on the drive (for not read only)
ls -l /Volumes/
Then finally you'll have to reload samba with the new configuration file
sudo killall -HUP smbd
Enjoy!
3 comments:
sorry to be dense, but can you describe how to create a "soft link" and how it differs from an "alias"?
certainly, to create a soft link you have to use the command line, which in OS X requires you to open a terminal window: Applications -> Utilities -> Terminal. To create a soft link you use the link program: ln, with the soft option: -s like so:
shell ~$ ln -s <real file> <path to link>
A soft link just adds a link file at the specified location in the file system that points to the real file that you linked to. The reason we use a soft link, as opposed to a hard link (which is just ln without the -s option) is that with the soft link we can link folders and everytime the contents are updated the changes are replicated in the link, as when you navigate inside the soft link it just points you to the real file.
An alias file (OS X specific) is more like a shortcut in windows, and it isn't recognized in anything but OS X. Whereas a soft link is recognized by all *nix flavors, and also (as i found out) results in a slight performance boost.
Hope that answers your question.
Thats a great tutorial, worked like a charm, thx!
Post a Comment