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

Step 1: Open your /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.

Step 2: Locate the line that mounts your CIFS share. It may look like this:

//server/share /mnt/share cifs credentials=/path/to/creds,uid=1000,gid=1000,x-systemd.automount,noauto 0 0

Step 3: Remove the 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

Step 4: Save the file and reload systemd’s mount units with the following command:

sudo systemctl daemon-reload

Step 5: Mount the share manually or trigger an automount by accessing the mount point. Verify the ownership with:

ls -l /mnt/share

If you see the correct user and group ownership, the issue is resolved.


Method 2: Use systemd Mount Units Directly

Step 1: Create a dedicated systemd mount unit instead of relying on /etc/fstab. This method provides greater control over mount options and behavior.

Step 2: Create a new file in /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

Step 3: Add the following content, adjusting the share path, credentials, and desired uid/gid values:

[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

Step 4: Reload systemd and enable the mount unit:

sudo systemctl daemon-reload
sudo systemctl enable --now mnt-share.mount

Step 5: Check the mount and ownership as before. This method ensures systemd uses the correct options and respects user and group IDs.


Method 3: Specify uid/gid in the Credentials File

Step 1: If your credentials file is already used for storing username and password, you can also specify uid and gid values in it. Edit your credentials file (e.g., /path/to/creds):

username=yourusername
password=yourpassword
uid=1000
gid=1000

Step 2: In your /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

Step 3: Save changes and remount the share. This approach can sometimes ensure the correct user and group IDs are applied, depending on your system’s mount helper behavior.


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.