Sunday, September 03, 2006

Setting up External Hard Drive Samba Shares on OS X

I have a large USB 2.0 external hard drive (300GB) connected to my brand spanking new mac mini, loaded with files that I wanted to be able to access on my Ubuntu box, which is all the way on the other side of the room. Initially I was just unmounting the volume, unplugging it and carrying it all the way accross the room to my Ubuntu machine. Well after doing this once, my arms got tired, and I thought to myself there must be a better way.

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!

6 comments:

Keith Rodriguez said...

sorry to be dense, but can you describe how to create a "soft link" and how it differs from an "alias"?

Matthew Story said...

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.

MackH said...

Thats a great tutorial, worked like a charm, thx!

wow power leveling said...

You said you will love me the whole life, but you marry her. You said you will wow power leveling,come to marry me, but this will not be carried out forever.WoW Gold I am trying my best to forget you and do not love you anymore. wow leveling But I failed and I still love you. Maybe wow leveling she needs you more compared wow leveling with me. So I tell you that world of warcraft power leveling you should love world of warcraft power leveling her and take good world of warcraft leveling care of her. You said I was so kind.world of warcraft leveling Yes, because I love you,world of warcraft leveling I hope you will be happy forever.

nike said...

http://www.polosales.com/ : cheap polo shirts
http://www.polosales.com/ : polo shirt
http://www.polosales.com/ : lacoste polo shirts
http://www.polosales.com/ : ralph lauren polo shirts
http://www.polosales.com/ : wholesale polo shirts
http://www.superpolos.com/mens-lacoste-solid-classicfit-polo-shirt-light-yellow-p-146/ : Yellow Polo Shirt
http://www.superpolos.com/wholesale-mens-short-sleeve-lacoste-polo-shirts-p-132/ : Men's Polo Shirts
http://www.superpolos.com/wholesale-mens-short-sleeve-lacoste-polo-shirts-p-133/ : Wholesale Polo Shirts
http://www.superpolos.com/ : polo shirts
http://www.superpolos.com/ : Lacoste polo shirts
http://www.pumachaussure.com/ : chaussure puma
http://www.pumachaussure.com/ : chaussures puma
http://www.polocart.com/ : polo shirts

bing said...

http://www.chihairstraightener.us/ : chi hair straightener
http://www.chiflatiron.us/ : chi flat iron

http://www.polool.com/ : new polo shirts


http://www.pursecart.com/ : cheap handbags
http://www.pursecart.com/ : cheap bags
http://www.pumachaussures.com/ : puma chaussures
http://www.pumachaussures.com/ : chaussures puma
http://www.pumachaussure.com/ : chaussure puma

http://www.jacketsworld.com/ : Men's North Face
http://www.jacketscart.com/ : Women's North Face


http://www.myhairstraighteners.co.uk/ : hair straighteners
http://www.sexylingeriestore.us/ : sexy lingerie store
http://www.uggsoutlet.us/ : cheap ugg boots
http://www.12hot.com/ : tattoo wholesale
http://www.polooo.net/ : men's clothing
http://www.acrazystore.com/ : women's clothing




http://www.thehairstraighteners.com/ : cheap hair straighteners
http://www.polosales.com/ : cheap Lacoste polo shirts
http://www.superpolos.com/ : cheap Lacoste polo shirts
http://www.shoesbuying.com/ : 2009 nike shoes
http://www.shoesbuying.com/2009-nike-shoes-c-153.htm : new nike shoes
http://www.shoesbuying.com/air-max-classic-bw-c-185.htm : Women's max
http://www.shoesbuying.com/mens-max-93-c-188.htm : Men's max 93
http://www.shoesbuying.com/nike-shox-c-165.htm : nike shox
http://www.shoesbuying.com/nike-force-c-174.htm : Nike air force
http://www.shoesbuying.com/nike-2003-c-181.htm : Nike air max 2003
http://www.shoesbuying.com/nike-air-max-ltd-c-166.htm : nike air max ltd
http://www.shoesbuying.com/nike-air-max-tn-c-167.htm : nike air max tn
http://www.shoesbuying.com/nike-rift-shoes-c-162.htm : Nike air rift
http://www.shoesbuying.com/nike-yeezy-c-184.htm : Nike air Yeezy
http://www.shoesbuying.com/nike-airmax-c-154.htm : nike airmax
http://www.shoesbuying.com/nike-airmax-c-155.htm : Nike air max 90
http://www.shoesbuying.com/nike-airmax-c-157.htm : Nike air max 97
http://www.shoesbuying.com/nike-birds-nest-shoes-c-152.htm : nike birds nest shoes
http://www.shoesbuying.com/nike-dunk-high-c-177.htm : nike dunk
http://www.shoesbuying.com/nike-shoes-c-168.htm : nike RT1 shoes
http://www.shoesbuying.com/nike-sb-c-180.htm : nike SB
http://www.shoesbuying.com/nike-shox-shoes-c-156.htm : nike shox shoes
http://www.shoesbuying.com/nike-shox-shoes-c-158.htm : Nike shox OZ shoes
http://www.shoesbuying.com/nike-shox-shoes-c-159.htm : Nike shox R2 shoes
http://www.shoesbuying.com/nike-shox-shoes-c-160.htm : Nike shox R3 shoes
http://www.shoesbuying.com/nike-shox-shoes-c-163.htm : Nike shox R4 shoes
http://www.shoesbuying.com/nike-shox-shoes-c-164.htm : Nike shox R5 shoes
http://www.shoesbuying.com/nike-shox-c-171.htm : Nike shox TL3
http://www.shoesbuying.com/nike-trainers-lovers-c-118.htm : nike trainers lovers

http://www.racketsoffer.com/ : tennis rackets
http://www.racketsoffer.com/wilson-racquets-c-19/ : Wilson tennis rackets
http://www.racketsoffer.com/head-racquets-c-18/ : HEAD tennis rackets
http://www.racketsoffer.com/babolat-racquets-c-17/ : Babolat tennis rackets