Mounting network shares using CIFS on Linux systems with x-systemd.automount and noauto options can sometimes result in the share being mounted as the root user, ignoring specified uid and gid values. This issue leads to incorrect file ownership and access problems for non-root users. The following steps outline how to address and resolve this behavior by adjusting mount options and system configurations.
Method 1: Adjust Mount Options in /etc/fstab
/etc/fstab file in a text editor with root privileges. This file controls how drives and network shares are mounted at boot or on-demand.//server/share /mnt/share cifs credentials=/path/to/creds,uid=1000,gid=1000,x-systemd.automount,noauto 0 0
noauto option if present. The noauto option prevents systemd from automatically mounting the share at boot or when accessed, which can cause systemd to ignore uid and gid parameters and default to mounting as root. Your updated line should look like://server/share /mnt/share cifs credentials=/path/to/creds,uid=1000,gid=1000,x-systemd.automount 0 0
sudo systemctl daemon-reload
ls -l /mnt/share
If you see the correct user and group ownership, the issue is resolved.
Join readers who trust AllThings.How
Add us as a preferred source on Google so our practical guides show up first next time you search.
Add to Google Preferences →Method 2: Use systemd Mount Units Directly
/etc/fstab. This method provides greater control over mount options and behavior./etc/systemd/system/ named after your mount point, replacing slashes with dashes and appending .mount. For example, for /mnt/share:/etc/systemd/system/mnt-share.mount
[Unit]
Description=Mount CIFS Share
[Mount]
What=//server/share
Where=/mnt/share
Type=cifs
Options=credentials=/path/to/creds,uid=1000,gid=1000
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable --now mnt-share.mount
Method 3: Specify uid/gid in the Credentials File
uid and gid values in it. Edit your credentials file (e.g., /path/to/creds):username=yourusername
password=yourpassword
uid=1000
gid=1000
/etc/fstab or systemd unit, reference only the credentials file without repeating uid or gid in the options.//server/share /mnt/share cifs credentials=/path/to/creds,x-systemd.automount 0 0
Resolving CIFS mount ownership problems caused by x-systemd.automount and noauto options streamlines user access and prevents root-only mounts. After making these changes, verify permissions and consider reviewing system logs for persistent issues.






