A Linux host can stall during boot when a network SMB/CIFS share is configured as a normal /etc/fstab mount and the file server is slow or offline. A systemd automount entry keeps the mount point present and delays the actual CIFS connection until a process opens that path.
With x-systemd.automount, systemd-fstab-generator creates an .automount unit and a matching .mount unit from the fstab line. The automount unit waits on the local directory, and the mount unit runs mount.cifs only when the directory is accessed.
Keep the SMB password in a root-owned credentials file instead of placing it in /etc/fstab. The SMB server still enforces access through the account in that file, while uid, gid, file_mode, and dir_mode control how files appear on the Linux client when the server does not provide Unix ownership.
$ mount.cifs -V mount.cifs version: 7.4
Install the cifs-utils package first when this command is missing. On Debian and Ubuntu clients, use sudo apt install cifs-utils.
$ sudo install -d -m 0750 /etc/samba/credentials
$ sudo vi /etc/samba/credentials/team-share
username=files-team password=replace-with-share-password domain=WORKGROUP
Omit domain= when the account is local to the SMB server. Keep the file format as key=value lines without spaces around the equals sign.
$ sudo chown root:root /etc/samba/credentials/team-share
$ sudo chmod 600 /etc/samba/credentials/team-share
$ stat -c '%a %U %G %n' /etc/samba/credentials/team-share 600 root root /etc/samba/credentials/team-share
$ sudo mkdir -p /mnt/team
$ id appuser uid=1001(appuser) gid=1001(appuser) groups=1001(appuser)
The uid and gid options affect ownership as shown on the Linux client. They do not replace the SMB account used to authenticate to the server.
$ sudo vi /etc/fstab
//files.example.net/team /mnt/team cifs credentials=/etc/samba/credentials/team-share,uid=1001,gid=1001,file_mode=0660,dir_mode=0770,iocharset=utf8,nofail,_netdev,x-systemd.automount,x-systemd.idle-timeout=10min,x-systemd.mount-timeout=30s 0 0
x-systemd.automount creates the on-demand automount unit. nofail lets boot continue if the mount cannot be completed, _netdev marks the entry as network-backed, and x-systemd.mount-timeout=30s limits each mount attempt.
A malformed /etc/fstab entry can delay boot or leave the share unmounted. Test the entry during the current session before relying on the next reboot.
$ sudo systemctl daemon-reload
$ systemd-escape --path --suffix=automount /mnt/team mnt-team.automount
$ sudo systemctl start mnt-team.automount
$ systemctl status mnt-team.automount --no-pager
● mnt-team.automount
Loaded: loaded (/etc/fstab; generated)
Active: active (waiting) since Tue 2026-06-16 10:30:24 +08; 5s ago
Triggers: ● mnt-team.mount
Where: /mnt/team
The matching .mount unit starts when a process opens /mnt/team. After a reboot, systemd regenerates the same automount unit from /etc/fstab.
$ ls /mnt/team quarterly-plan.txt
$ findmnt --target /mnt/team --output TARGET,SOURCE,FSTYPE TARGET SOURCE FSTYPE /mnt/team //files.example.net/team cifs
$ touch /mnt/team/automount-check.txt
Use a read-only check such as ls /mnt/team instead when the share is intentionally mounted read-only.
$ ls -l /mnt/team/automount-check.txt -rw-rw---- 1 appuser appuser 0 Jun 16 10:31 /mnt/team/automount-check.txt
$ rm /mnt/team/automount-check.txt