# autofs and smb mounts

## tcalbrecht

I'm having trouble getting autofs to automount my smb shares at boot time.  

I've configured the autofs files, done rc-update, and I see the message at boot time that autofs has successfully executed.

When I try to access one of the smb shares via 'ls /mnt/serverd' it tells me not accessible.  In order to get it to work I have to su as root, then stop and start autofs.  After that everything is fine.

Here are my files:

auto.master

```

# $Id: auto.master,v 1.3 2004/12/09 08:25:48 robbat2 Exp $

# Sample auto.master file

# Format of this file:

# mountpoint map options

# For details of the format look at autofs(8).

#/net   /etc/autofs/auto.net

#/misc  /etc/autofs/auto.misc

#/home  /etc/autofs/auto.home

/mnt/auto       /etc/autofs/auto.auto   --timeout 5 --ghost -v

```

auto.auto

```

serverd -fstype=smbfs,guest,uid=tom,gid=users,fmask=0775,dmask=0775     ://WinServer/D

servere -fstype=smbfs,guest,uid=tom,gid=users,fmask=0775,dmask=0775     ://WinServer/E

```

auto.misc

```

# $Id: auto.misc,v 1.2 2002/10/27 05:21:15 bcowan Exp $

# This is an automounter map and it has the following format

# key [ -mount-options-separated-by-comma ] location

# Details may be found in the autofs(5) manpage

#boot           -fstype=ext2            :/dev/hda1

#cd             -fstype=iso9660,ro      :/dev/cdrom

#floppy         -fstype=auto            :/dev/fd0

```

gentoo kernel 2.6.12-r10

autofs 4.1.3-r4

samba 3.0.14a-r2

Why isn't this working at boot time?

----------

## Kingmilo

I haven't messed around with autofs before but I get the idea.

It's sounds like a script one better than the /etc/fstab right? Because I know fstab can automount you smb shares.

One thing I did think of though is rc-update .

The reason I think that it is not working at boot time is because it is relying on another service to start prior to autofs so that

it can mount. Cant think of what this service is right now, but maybe you can try adding autofs as the last service to start in

init.d ?

Im assuming you did 

```
rc-update add autofs default
```

 and not 

```
rc-update add autofs boot
```

 right?

hope this helps !

----------

## AliBaba40

Exactly same problem here. 

I've already tried to configure a static ip, but nothing changed.

Added:

```
/etc/init.d/autofs restart
```

into /etc/conf.d/local.start. This restarts the automounter as supposed, but the problem is still present.

The only solution i have is to do it like tcalbrecht or use a icon on desktop for a script like:

```

#! /bin/bash

sudo /etc/init.d/autofs restart

```

Any help would be nice.

----------

## Kingmilo

Guys why dont you just use /etc/fstab to mount you SMB share or HD ?

```

192.168.0.1:/Winserver/D     /mnt/auto/serverd     smbfs     rw,uid=tom,gid=users,fmask=0775     0 0

192.168.0.2:/Winserver/E     /mnt/auto/servere      smbfs    rw,uid=tom,gid=users,fmask=0775      0 0

```

Replce the IP address of the Server with the hardrive you want to mount, or if the hardrives are local then /dev/hdx .

I used this for nfs shares not Samba in the past, but I am sure it will work the same, just fiddle with it.

It's just an alternative to the autofs which i really think is a gentoo boot priority thing. It's waiting on some other event

before it initiates. Maybe set some sort of time delay within a script to do it auto?

Cheers  :Wink: 

----------

## AliBaba40

Not sure about it, but isn't there a problem if the share don't exist at boot time and/or if if switch the server on (or off and on) after my gentoo box has booted?

----------

## Kingmilo

If the share isint available at boot time it's not going to mount it anyway?

Why would you want to mount something that isint there?

If it is available at boot time and you mount it, and then later on you switch the server off, it

wont lose the mounting, but obviously when you try and access the /mount it wont be availabel.

As soon as you turn the server back on you will be able to access the /mount without having to

remount the share as far as I know  :Wink: 

----------

## tcalbrecht

 *Kingmilo wrote:*   

> If the share isint available at boot time it's not going to mount it anyway?
> 
> Why would you want to mount something that isint there?
> 
> If it is available at boot time and you mount it, and then later on you switch the server off, it
> ...

 

The purpose of the  automounter is to manage resources that come and go unpredictably, like SMB shares on servers that can be rebooted, or CDs and thumb drives that get inserted and removed.

It provides much more functionality that just sticking the mount points in /etc/fstab.

----------

## Kingmilo

Thanks for the clarification, makes a lot more sense, although I have no more suggestions for your problem  :Neutral: 

Good Luck

----------

## AliBaba40

I've finally got a workaround. In this example my username is alex and I'm using Kde 3.5.

1) Create an executable file with this content:

```
#!/bin/sh

sudo /etc/init.d/autofs restart

```

for me it goes like this:

```

#vi /home/alex/bin/restart_autofs

#chmod 700 /home/alex/bin/restart_autofs

```

2) Set up kde to load it at start up:

```

#cd /home/alex/.kde/Autostart/

#ln -s ../../bin/restart_autofs

```

in Gnome it can to be done with the session dialog i think.

3) Set permission to execute "/etc/init.d/autofs restart" by alex as root w/o password:

Login as root, execute "visudo" and add this line:

```

alex    ALL=(ALL) NOPASSWD: /etc/init.d/autofs restart

```

Now after kde login the automounter recognizes the windows shares.

Another useful tool i've found is smb4k. It can mount shares by right mouse klick, into you homedir, w/o any fstab editing.

Hope this will help.

----------

## sasquatch

I think the problem is to do with trying to mount a guest share. Try changing

 *Quote:*   

> servere -fstype=smbfs,guest,uid=tom,gid=users,fmask=0775,dmask=0775     ://WinServer/E 

 

to

 *Quote:*   

> servere -fstype=smbfs,guest,username=guest,uid=tom,gid=users,fmask=0775,dmask=0775     ://WinServer/E 

 

This also fixes the problem I was having with mounting samba shares at boot from the fstab.

It's a rather weird problem because as tcalbrecht says the problem goes away after restarting the autofs service. The smbmount man page says:

 *Quote:*   

> 
> 
> username=<arg> specifies  the  username  to connect as. If this is not given, then the environment variable  USER is used. This option can also take the form "user%password" or "user/workgroup"  or  "user/workgroup%password"  to  allow  the password and workgroup to be specified as part of the username.
> 
> 

 

Maybe the value of USER is different for the autofs service before and after restarting ? (i.e not root !?) I'm not exactly sure how to check that. 

Also, according to the manual the "guest" mount option only serves to suppress the password prompt. So presumably doesn't send any special instruction to the server.

----------

