DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Mounting A CIFS Share In Samba

12.08.2009
| 10641 views |
  • submit to reddit
        This works in /etc/fstab:

//HOSTNAME.DOMAIN_NAME\SHARE$   /mnt    cifs    defaults        credentials=/root/.smbpasswd    0 0

where /root/.smbpasswd has:

domain=DOMAIN_NAME
username=mylogin
password=secret

If you get the syntax for the slashes in the name wrong it will complain with 'mount error 6 = No such device or address'
but samba is quite flexible in what syntax it lets you use:

# mount /mnt/
retrying with upper case share name
mount error 6 = No such device or address
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

# mount -t cifs //10.11.12.13/SHARE /mnt --verbose -o "user=DOMAIN_NAME/mylogin"
parsing options: rw,user=DOMAIN_NAME/mylogin
Password:

mount.cifs kernel mount options unc=//10.11.12.13\SHARE,ip=10.11.12.13,domain=DOMAIN_NAME,pass=secret,ver=1,rw,user=mylogin,,,,,,,
retrying with upper case share name

mount.cifs kernel mount options unc=//10.11.12.13\SHARE,ip=10.11.12.13,pass=secret,ver=1,rw,user=mylogin,,,,,,,
mount error 6 = No such device or address
Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)

# mount -t cifs "//10.11.12.13/SHARE$" /mnt --verbose -o "user=DOMAIN_NAME/mylogin"
parsing options: rw,user=DOMAIN_NAME/mylogin
Password:

mount.cifs kernel mount options unc=//10.11.12.13\SHARE$,ip=10.11.12.13,domain=DOMAIN_NAME,pass=secret,ver=1,rw,user=mylogin,,,,,,,

# mount -t cifs //10.11.12.13/SHARE\$ /mnt --verbose -o "user=DOMAIN_NAME/mylogin"
parsing options: rw,user=DOMAIN_NAME/mylogin
Password:

mount.cifs kernel mount options unc=//10.11.12.13\SHARE$,ip=10.11.12.13,domain=DOMAIN_NAME,pass=secret,ver=1,rw,user=mylogin,,,,,,,

# mount -t cifs //10.11.12.13\\SHARE$ /mnt --verbose -o "user=DOMAIN_NAME/mylogin"
parsing options: rw,user=DOMAIN_NAME/mylogin
Password:

mount.cifs kernel mount options unc=//10.11.12.13\SHARE$,ip=10.11.12.13,domain=DOMAIN_NAME,pass=secret,ver=1,rw,user=mylogin,,,,,,,

# mount -t cifs \\\\10.11.12.13\\SHARE$ /mnt --verbose -o "user=DOMAIN_NAME/mylogin"
parsing options: rw,user=DOMAIN_NAME/mylogin
Password:

mount.cifs kernel mount options unc=//10.11.12.13\SHARE$,ip=10.11.12.13,domain=DOMAIN_NAME,pass=secret,ver=1,rw,user=mylogin,,,,,,,

# umount /mnt/

# mount -t cifs '\\10.11.12.13\SHARE$' /mnt --verbose -o "user=DOMAIN_NAME/mylogin"
parsing options: rw,user=DOMAIN_NAME/mylogin
Password:

mount.cifs kernel mount options unc=//10.11.12.13\SHARE$,ip=10.11.12.13,domain=DOMAIN_NAME,pass=secret,ver=1,rw,user=mylogin,,,,,,,

# mount -t cifs '\\10.11.12.13/SHARE$' /mnt --verbose -o "user=DOMAIN_NAME/mylogin"
parsing options: rw,user=DOMAIN_NAME/mylogin
Password:

mount.cifs kernel mount options unc=//10.11.12.13\SHARE$,ip=10.11.12.13,domain=DOMAIN_NAME,pass=secret,ver=1,rw,user=mylogin,,,,,,,