18

I configured a remote folder in nautilus. I always need this remote folder, so I created a symbolic link to it in my home folder: ln -s ~/.gvfs/remote_folder ~/remote_folder.

Though, when I first boot the computer this folder is not mounted, and I have to access it through nautilus in order to have it available in ~/remote_folder.

What should I do to have this folder mounted on log on?

16

Shell

You could use the mount command in a start up script and put that in the Startup Application Preferences. mount is perfectly capable of mounting remote file systems (if you provided it with the right options and all necessary packages installed).

An alternative to mount in your startup script is gvfs-mount Install gvfs-bin. You can mount nautilus-type URIs with that - just like nautilus does. It is installed by default on most Ubuntu systems.
Example usage:

gvfs-mount 'ftp://user@www.your-server.com/folder'

Adding the -u option unmounts the argument, -l lists all mounted file systems, --help gives you more options.

Finally the file /etc/fstab is usually used to mount file systems statically. If your remote server is reliable you might want to take a look at fstab. It will slow down your boot time drastically if the server is slow or offline, but it has the advantage of making the file system available quite soon (before gnome or X are even loaded, e.g. for use in scripts). For more information you can type man fstab.

GUI way

Check out Gigolo Install gigolo. It has the capability of auto-mounting a bookmark, whenever the bookmarked filesystem is present.

sudo apt-get install gigolo   # or use the install link above

Run gigolo. There is an option in the preferences that puts it into autostart and another to activate the tray icon. Check both. Then add your bookmark.

Gigolo used to automount

  • Thanks for the answer. I was exactly looking forward to find this last more user-friendly and resource-consuming solution. Though, I advise the other people that eventualy have this question to read all the answers and ponder well on which suits their needs better. – pedrorolo Aug 9 '11 at 13:08
  • small typo: /etc/fsatab should be /etc/fstab – djb Aug 9 '12 at 20:11
4

First install gvfs-bin package:

sudo apt-get install gvfs-bin

then mount URI you need. For example:

gvfs-mount 'archive://file%253A%252F%252F%252Ftmp%252Ftest.tar/'

to test it:

ls -la ~/.gvfs/test.tar/

to unmount it, just call:

gvfs-mount -u 'archive://file%253A%252F%252F%252Ftmp%252Ftest.tar/'

Note, that there is no man pages. for this package. To learn more, list available binaries via:

dpkg -L gvfs-bin

and then use --help option, for example:

gvfs-mount --help
2

If you do not want to use /etc/fstab (e.g. bad on multi-user PCs, no root access) or don't want to save your user password to a text file in your home folder (e.g. no encrypted file system) using gvfs-mount smb://$SERVERIP/$SHARE < ~/.smbcredentials_gvfs,

run this shell script on startup (or whenever you want):

#!/bin/bash
USERID=`id -u $USER`; # Needed in 14.04
SHARE=exampleshare # Example
SERVERIP=192.168.2.101 # Example
nautilus smb://$SERVERIP/$SHARE & # Mount the share using nautilus. You need to have your password saved permanently
rm ~/network_$SHARE # prepare symbolic link (Example)
ln -sf /run/user/$USERID/gvfs/smb-share\:server\=$SERVERIP\,share\=$SHARE ~/network_$SHARE # Directory in Ubuntu 14.04
sleep 2 # Nautilus needs some time to mount. Killing nautilus without waiting time does not mount the share
pkill nautilus

This mounts the shares you want and uses the nautilus (or Ubuntu) password saving mechanism (does not work in SSH though).

  • Of all the answers this is the only one actually addressing the question. – Luís de Sousa Feb 4 at 8:20
2

I usually do permanent mounts through fstab. You have to enter something like

//servername/folder HOME/remote_server cifs username=XXXX,password=YYYY 0 0

in your /etc/fstab. Since you haven't said anything about what kind of remote partition I gave an example of samba share

See:

The second option may be using autofs, see the Ubuntu help wiki page for help.

EDIT: Thank you @con-f-use for reminding me this one. You can add bookmarks from nautilus only. Go to File > Connect to Server... on nautilus and you will be presented with dialogue window where you have the option to add a bookmark of desired name. Just check the add bookmark option and enter the bookmark name. But I think it starts the mounting only after you click the bookmark unlike gigolo.

enter image description here

  • 1
    That has the disadvantage of delaying your systems boot, when the remote server is not reachable (internet down, sever maintainace etc.) – con-f-use Aug 9 '11 at 11:15
  • 1
    You can put the credentials in a separate file that only root can read (often non root users can read /etc/fstab and thus see userid/passwords stored there). Use credentials=/root/remove_server.credentials where that file has two lines in it, username=userid password=userids-password – djb Aug 9 '12 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.