Mounting Samba (CIFS) shares: Difference between revisions

From Leo's Notes
This page was last edited on 18 February 2020, at 19:18.
added troubleshooting
mNo edit summary
Line 1: Line 1:
== Linux ==
=== Mounting ===
Ensure you have samba-utils installed, then run:
{{highlight|lang=terminal|code=
# mount -t cifs -o username=leo,password=53cr3T$ //10.1.1.123/share /mnt/share
}}
You can also have the secrets placed in a separate file rather than have it in line with the mount command. To do so, create a separate credentials file with the following contents:
{{highlight|lang=terminal|code=
# cat /etc/cifs_passwd  # can be placed anywhere. Ensure it's not world readable.
username=leo
password=53cr3T$
}}
Then to mount, use {{code|1=-o credentials=/etc/cifs_passwd}} like:
{{highlight|lang=terminal|code=
# mount -t cifs -o credentials=/etc/cifs_passwd //10.1.1.123/share /mnt/share
}}
==== /etc/fstab ====
If you plan on mounting it in {{code|/etc/fstab}}, append:
{{highlight|lang=terminal|code=
# //10.1.1.123/share /mnt/share cifs credentials=/etc/cifs_passwd 0 0
}}
==== Default User / Group ====
To set the default user/group ID, define the {{code|uid}} and {{code|gid}} value as part of the options. eg:
{{highlight|lang=terminal|code=
# mount -t cifs -o uid=1024,gid=512,credentials=/etc/cifs_passwd //10.1.1.123/share /mnt/share
}}
=== Unmounting ===
Unmount as usual:
{{highlight|lang=terminal|code=
# umount /mnt/share
}}
=== Troubleshooting ===
The first time I ran {{code|mount -a}}, I got the following error:
{{highlight|lang=terminal|code=
root@server:~# mount -a
mount: wrong fs type, bad option, bad superblock on //box/Volume_1,
missing codepage or other error
In some cases useful info is found in syslog - try
dmesg {{!}} tail or so
}}
with {{code|dmesg}} showing:
{{highlight|lang=text|code=
CIFS VFS: No username specified
CIFS VFS: cifs_mount failed w/return code = -22
}}
Error -22 means the executable doesn't exist. To resolve this, install {{code|cifs-utils}}
{{highlight|lang=terminal|code=
# yum -y install cifs-utils
}}
== FreeBSD ==
== FreeBSD ==
=== Mounting ===
=== Mounting ===
Line 71: Line 7:
where -I takes the remote host's IP address. Your username @ the NetBIOS name / path to your share comes next. The mount path follows after that.
where -I takes the remote host's IP address. Your username @ the NetBIOS name / path to your share comes next. The mount path follows after that.


 
== Linux ==
{{Navbox Linux}}[[Category:Linux]]
See [[Mount Tips & Tricks]]

Revision as of 19:18, 18 February 2020

FreeBSD

Mounting

# mount_smbfs -I 10.1.1.4 //leo@remote_host/share /mnt/share

where -I takes the remote host's IP address. Your username @ the NetBIOS name / path to your share comes next. The mount path follows after that.

Linux

See Mount Tips & Tricks