Mounting Samba (CIFS) shares

From Leo's Notes
This page was last edited on 30 November 2021, at 03:57.

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

Ensure you have samba-utils installed.

To mount a samba share, use mount.cifs. Credentials can be passed in as mount options.

# mount -t cifs -o username=leo,domain=uc,vers=2.1 //10.1.1.123/share /mnt/share

You can also have the credentials placed in a separate file rather than passing it directly as mount options. Create a file with the username, password, and optionally domain defined and then mount using the credentials=filename option. For example:

## Create a file. Ensure it's not world readable.
# cat /etc/cifs_passwd
username=leo
password=53cr3T$
domain=uc

# mount -t cifs -o credentials=/etc/cifs_passwd,vers=2.1 //10.1.1.123/share /mnt/share

Default user/group ID

To set the default user/group ID, define the uid and gid value as part of the mount options. For example:

# mount -t cifs -o uid=1024,gid=512,credentials=/etc/cifs_passwd //10.1.1.123/share /mnt/share