31

Via Gnome Nautilus I can easily mount Samba shares from my Ubuntu Server. However, these "mounts" are kinda of fake. Many applications I run do not recognize that Gnome has mounted these server folders and therefore cannot open files off my server.

In the past I created an /etc/fstab entry and mounted them globally, the /mnt folder, but this isn't going to work as other people share my Ubuntu laptop.

What's the easiest way to create a "real" samba mount in my (and other people's) home directory? It's fine if its a command or a GUI application that can run when I log in. These server folders don't have to be mounted all the time.

Peachy
  • 7,235
  • 10
  • 40
  • 47
Dave
  • 3,647

4 Answers4

28

Suppose you have a directory called mounts in your home directory in which you want various Samba shares to be mounted. Suppose further that you are specifically interested in mounting a share called sharename from a remote machine called hostname (this could also be an IP address), and on that remote machine your username is username. First, create the mount point:

mkdir ~/mounts/sharename

Then mount the share:

sudo mount.cifs //hostname/sharename ~/mounts/sharename -o user=username

In Ubuntu 12.04 LTS and earlier, if you don't have the mount.cifs command, you can either install the cifs-utils Install cifs-utils package, or use smbmount instead (which is, in turn, provided by the smbfs Install smbfs package).

sudo smbmount //hostname/sharename ~/mounts/sharename -o user=username

(smbmount is not available in Ubuntu 12.10 or higher, at least so far, but you can use mount.cifs instead. Thanks to HDave for pointing this out.)

You may be prompted for your password on the local machine, to run the command as root. Then you'll be prompted for your password on the remote machine, to log in so you can mount the share.

Eliah Kagan
  • 119,640
4
  1. Open your file manager, i.e. click the icon for Home Folder.
  2. Observe up at the top of the screen is the Menu for the File Manager (as opposed to at the top of its window).
  3. Click FileConnect to Server...; a window should open titled Connect to Server.
  4. Click into its drop-down box titled Type; choose Windows share (i.e. change from the default of Public FTP).
  5. Enter the Server (the name if it can be resolved by DNS or its IP address.
  6. Enter the Share (i.e the items you'd otherwise see in a windows share as the Share component of '\\Server\Share').
  7. Enter into Folder the name of any particular directory on the share that you'd like the mount to position at.
  8. Enter any/optional User Details.
  9. The Share should Mount and appear in the File Manager window on the left list under Network.
Pablo Bianchi
  • 17,371
Steve
  • 41
3

Not sure if you are still looking for something easy, I just found it:

All the shares you have opened are mounted automatically in your home folder under /home/.gvfs.

Any application can recognize and access the shares as if they were normal folders, as long as you point the application to the files or folders you want in /home/.gvfs

Peachy
  • 7,235
  • 10
  • 40
  • 47
2

Why would you want to use Samba to access files on your Linux server? Samba is meant for accessing Windows network shares and services.

Use sshfs instead, there is no setup necessary at all and you get "proper" mount points that are recognized by any application:

sudo apt-get install sshfs

Mount the remote filesystem with

sshfs user@host:/path /local/mount/point

and unmount with

fusermount -u /local/mount/point
kynan
  • 2,235