# Automount samba

## d4h0od

How do i get my Gentoo to mount a samba share ( with passwd ) everytime i boot Gentoo ?

----------

## radfaraf

edit your /etc/fstab and add a line simillar to this

//mp3box/root /mnt/mp3box      smbfs username=secret,password=secret        0 0

//mp3box/root is the samba share /mnt/mp3box is the mount point

----------

## utabintarbo

How do we ensure samba is started before fstab is processed?

I tried similar and got nasty error re: samba not started (something like that).  :Confused: 

Bob

----------

## turbonium

I'd use autofs to mount your samba share when needed.

I dunno if these instructions are right. . .but try this out.  I'm not sure about the wording of step 3.

1.  emerge autofs

2.  rc-update add autofs default

3.  create a auto.smb file in /etc/autofs

not sure how this should be worded, but maybe like

/mp3dir    smbfs username=secret,password=secret  //mp3server/share

4.  modify /etc/autofs/auto.master and add the auto.smb entry

/mp3dir    /etc/autofs/auto.smb

----------

## Chris W

Try it first and see if samba starts before netmount in the default runlevel.   If not, then I think that modifying the netmount depend() function to include samba on the use line should work (run depscan.sh afterward) i.e.

```
depend() {

        need net

        use portmap samba

}
```

----------

## Ozymandias

well, you don't need samba to be started if you want to mount a smb (cifs) share. I use automounter quite extensively, because it is soo usefull. This is how you do it:

emerge autofs

rc-update add autofs default

and edit the files in /etc/autofs/

auto.master:

```

/mnt/auto /etc/autofs/auto.mnt

```

auto.mnt:

```

boot            -fstype=ext2            :/dev/hda1

cdrom           -fstype=iso9660,ro      :/dev/cdroms/cdrom0

floppy          -fstype=auto            :/dev/fd0

win             -fstype=ntfs,umask=000  :/dev/hda2

webdev          -fstype=smbfs           ://ozymandias/webdev

shares          -fstype=smbfs           ://ozymandias/shares

backup          -fstype=smbfs           ://ozymandias/backup

campusnet       -fstype=smbfs           ://ozymandias/campusnet

```

and make a dir structure under /mnt like this:

/mnt/auto

/mnt/win->/mnt/auto/win (as a link, use 'ln /mnt/auto/win /mnt/win -s')

/mnt/webdev->/mnt/auto/webdev (link)

/mnt/cdrom->/mnt/auto/cdrom (link)

etc.

now all you have to do is put in a cdrom and go to /mnt/cdrom and you are reading it. To eject the cdrom when you are finished, wait 1 minute, or type 'umount /mnt/cdrom' as root in a console.

never have to type in a single mount command anymore  :Smile: 

suc6 greetz Ozy

----------

