0

I know there are many threads about it on the internet, I tried many of them, but I swear, none solved my problem :(

I work on a Ubuntu 14.04 LTS, and we have a Windows server where there is a shared folder which we use as a server for development.

I researched a lot and got the following configuration to mount the shared folder:

/etc/fstab

//ip/shared_folder ubuntu_folder cifs credentials=/home/ubuntu_user/.smbcredentials,uid=windows_user,domain=workgroup,iocharset=utf8,_netdev,sec=ntlm 0 0

.smbcredentials

username=windows_user
password=windows_pass
domain=workgroup

If I type

sudo mount -a

all works fine, and I have my mounted windows shared folders.

My problem is that every time I reboot, I need to do sudo mount -a.

I've tried several different ways to do this, but none worked. I need these folders to be mounted before any user logs in.

What am I doing wrong?

To summarise this question: is there any way to mount without being in the sudoers?

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
Cleiton Souza
  • 811
  • 1
  • 10
  • 21
  • Comment 1: The `ubuntu_folder` in `/etc/fstab` looks like a relative path...did you try to use an absolute path (probably `/home/ubuntu_user/ubuntu_folder`)? – vlp Nov 15 '15 at 19:42
  • Comment 2: After fixing the path the command `mount /home/ubuntu_user/ubuntu_folder` should work from `/etc/rc.local` as @DiegoSchellFernandes suggests (it is probably better to mount only this specific share). – vlp Nov 15 '15 at 19:44
  • Comment 3: It might be a good idea to add the `noauto` option in `/etc/fstab` (if this approach works for you). Good luck! – vlp Nov 15 '15 at 19:45
  • @vlp - I assume you meant `auto`, not `noauto` above. The latter is to *prevent* init mounting the filesystem at startup. – Toby Speight Nov 16 '15 at 11:52
  • 1
    @TobySpeight I meant `noauto` as the filesystem would be mounted explicitly in `rc.local`, not by `mount*` scripts. There is still a chance this won't work (e.g. when the server is available only via a wifi interface which is brought up later than the init scripts `mountall.sh`/`mountnfs.sh`/`rc.local` run). My bet is that the main problem is the relative path...we will see – vlp Nov 16 '15 at 14:31

3 Answers3

1

Open /etc/rc.local with vim, add the command sudo mount -a at the end of the file, reboot the computer, done.

0

It's hard to diagnose, but I'm guessing ubuntu_folder is a subdirectory of another mount point (perhaps /home?). That might be a problem if the mount point isn't available when init runs mount -a (although mount -a should be smart enough to figure that out).

Another likely (and related) problem is that perhaps the credentials file is on a filesystem that isn't mounted before the CIFS mount is attempted. This is something that mount -a can't be expected to handle automatically. Try moving the file to somewhere that is mounted earlier in the boot sequence, perhaps /etc/ (keep the correct permissions on it, of course).

Something else you could do is add explicit auto to the mount flags (definitely remove noauto if you find it there; the fact that you can manually run mount -a suggests it isn't).

Toby Speight
  • 27,591
  • 48
  • 66
  • 103
0

I finally found the solution:

I created a task in the session applications

bash /home/MYUSER/montar.sh

And in my montar.sh file, I added the lines

echo "MYPASS" | sudo -S sleep 10 && sudo mount -a -S

Probably not the best solution or the most correct, but it worked.

Sorry for English

Cleiton Souza
  • 811
  • 1
  • 10
  • 21