How-to-simply...

Mount Windows Share on Linux/RHEL

  • 1 dnf install samba-client cifs-utils
    # samba (server) is not needed if you only mount SMB shares
  • 2 One-Liner:
    sudo mount -t cifs -o username=<WinUser>,domain=<GRP>,uid=1000,gid=1000,dir_mode=0755,file_mode=644,iocharset=utf8,serverino,noatime //1.2.3.4/devshare /mnt/devshare
  • 3 Permanent mount in /etc/fstab:
    //1.2.3.4/devshare /mnt/devshare cifs credentials=/etc/samba/creds/devshare-rw.cred,uid=1000,gid=1000,dir_mode=0755,file_mode=0644,iocharset=utf8,_netdev,x-systemd.automount,serverino,noatime,nofail 0 0
    Credentials file:
    vim /etc/samba/creds/devshare-rw.cred
    username=DevShareWriter
    password=1234
    domain=DOMAIN # optional
    chmod 700 /etc/samba/creds
    chmod 600 /etc/samba/creds/devshare-rw.cred
  • 4 reboot
    ls -la /run/systemd/generator/mnt-*
    ls /mnt/devshare # Automounts
    systemctl status mnt-devshare.mount
  • N _netdev waits for network
    x-systemd.automount converts the mount into on-demand automount unit
    serverino stable inodes for git, rsync
    noatime no file access time
    More info: man mount.cifs

References