This article will describe installing cifs-utils for SMB client.
Table of Contents
1 Install cifs-utils
Install cifs-utils package.
$ sudo apt install -y cifs-utils
2 Mount SMB with mount
Mount SMB with mount to /mnt directory.
$ SMB_USERNAME=guest $ SMB_PASSWORD=guest $ SMB_SERVER="//smb-server.hiroom2.com/share" $ sudo mount -t cifs \ -o username=${SMB_USERNAME},password=${SMB_PASSWORD} \ "${SMB_SERVER}" /mnt
3 Manage username and password with credentials option
The credentials option authentication via file.
$ cat <<EOF | sudo tee /etc/samba/credentials > /dev/null username=${SMB_USERNAME} password=${SMB_PASSWORD} EOF $ sudo chmod 600 /etc/samba/credentials $ sudo mount -t cifs -o credentials=/etc/samba/credentials \ "${SMB_SERVER}" /mnt
4 Mount SMB on boot
Add mount entry to /etc/fstab. For avoiding mounting SMB before network initialization, you need to add _netdev option. For making x-systemd.automount to mount SMB, you need to add x-systemd.automount to option.
$ OPT="credentials=/etc/samba/credentials,_netdev,x-systemd.automount" $ echo "${SMB_SERVER} /mnt cifs ${OPT} 0 0" | \ sudo tee -a /etc/fstab