How-To: Mounting a Samba Share as a Drive in Ubuntu

NSLU2 + Drive Toaster = Want.This is just a quick guide I collected together from bits and pieces I found across the Internet. It lets you take a shared folder and add it

Basic Mounting

Giving your server a static IP makes things easier. Better still is using an network DNS system like that on the WRT-54G.

Using fstab, you want a line looking something like this:

“//server_ip/sub_folder  /media/mount_point  cifs  credentials=/etc/samba/user,noexec  0 0 ”

Note:If your samba shared folder has spaces in it, replace them with “\040″, same applies with the place you’re mounting it to.

The noexec prevents things being executed (not sure if that’s just at mount or for everything).

The “0″ and “0″ at the end, for those of you not familiar with fstab, are to do with backup and checking integrity respectively, setting them both to zero will tell your computer not to do anything with them (They will probably be checked at the server end anyway.).

You also need to edit your /etc/samba/user file. It should look something like this:
username=your_username
password=your_password

Edit: Make sure to change the permission of the “/etc/samba/user” file to 600 to prevent others reading the passwords. To do this “chmod 600 /etc/samba/user”.
Thanks to Scruss for that tip.

Preventing shutdown errors

That should work if you restart or run “sudo mount -a”. You will, however, stall your shutdown, if you’re using a wireless network (Even if you’re using a wired network, it’s still a good idea to do the following anyway.). This can be fixed by going to your /etc/rc6.d folder and finding two files using the “ls” command:

“S<n>wpa-ifupdown”, where <n> is usually 15
“S<n>umountnfs.sh”, where <n> is usually greater than 15. This is the problem.

Explanation: What this is doing is shutting down your wireless before it unmounts the network share. This causes the unmount to wait a long time for confirmation, which isn’t going to come.

Solution: What you want to do is put the “S<n>umountnfs.sh” somewhere before “S15wpa-ifupdown” (14 is a good idea) like so:

sudo mv /etc/rc6.d/S<n>umountnfs.sh /etc/rc6.d/S14umountnfs.sh

Underpants, ????, Profit! You should now have your network folder acting just like another drive.

This entry was written by Fred , posted on Saturday March 14 2009at 03:03 pm , filed under Uncategorized . Bookmark the permalink . Post a comment below or leave a trackback: Trackback URL.

One Response to “How-To: Mounting a Samba Share as a Drive in Ubuntu”

  1. You should probably set the permissions on your /etc/samba/user to 600, otherwise anyone can read your smb passwords.

Leave a Reply