Samba usage

From wikinotes

Windows

You have a couple of options for windows, depending on if you only want to remember the network credentials, or if you want to map the network mount to a drive:

store credentials

cmdkey /add hostname /user:hostname\\user  /pass:password
subst x: \\hostname\share

symlink on HDD (personal preference)

mklink /d C:\mnt\movies \\hostname\movies

map share to drive-letter

NET USE x:  \\hostname\share /USER:<user>  <password>  /PERSISTENT YES

Unix

mount from commandline

sudo mount //1.1.1.1/videos /mnt/usb \
    -o username=LOGIN_USER,password=LOGIN_PASS,workgroup=WORKGROUP,vers=3.0

unmount all samba

umount -af -t cifs  # unmount all cifs (also consider -l, which detaches and leaves cleanup for later)

automated mounts (fstab)


on a linux systemd system:

# normal fstab (ext4, etc)
//192.168.1.220/movies /mnt/movies cifs     
    auto,                  # mounts when (-a) flag is used
    _netdev,               # mount resides on network, requires network up
    users,                 # allow any user to mount/unmount filesystem
    username=XXX,          # smb credentials: user
    password=YYY,          # smb credentials: pass
    workgroup=WORKGROUP, 
    dir_mode=0777,file_mode=0644,gid=smbuser,   # file permissions for mount
    x-systemd.automount,                        # mount automatically on boot
    vers=3.0,                                   # force samba protocol 3+. (fixes some network hangs)
    uid=you,gid=you                             # chown files

    0 0

Wait until after ZFS is mounted (systemd)

//192.168.1.220/movies /mnt/movies cifs \
    # ..options... \
    x-systemd.requires=zfs-mount.service \
    0 0

list shares (smbclient)

sudo smbclient \
     -L //192.168.1.220 \
     -U login-user \
     --list