Automatically Mounting Per-User Drives in Linux: A Tech Support Guide

Abstract: Automatically mounts SMB shares for individual users on Arch Linux via systemd user services without root privileges.

Created: 2026-09-14 by
Automatically mounting SMB shares for individual users on EndeavourOS or Arch Linux requires creating a dedicated systemd user service. This approach ensures that network drives are mounted only when the specific user logs in, handling credentials securely and managing dependencies like network connectivity without requiring root privileges or global automounts.

Prerequisites and Package Installation

Before configuring the mount point, you must ensure the necessary utilities are installed on your system. For EndeavourOS and Arch-based distributions, the cifs-utils package provides the tools required to mount CIFS/SMB filesystems. Install this package using the Pacman package manager:
sudo pacman -S cifs-utils
You also need a method to store your SMB credentials securely. Storing passwords in plain text within mount options is insecure. Instead, create a credentials file in your home directory with restricted permissions. Create a file named .smbcredentials in your home directory:
nano ~/.smbcredentials
Add the following lines, replacing the placeholders with your actual username and password:
username=your_smb_username
password=your_smb_password
Set strict permissions on this file so that only you can read it. This prevents other users on the system from accessing your network credentials:
chmod 600 ~/.smbcredentials

Creating the Mount Point

Systemd user services operate within the context of the logged-in user. Therefore, the mount point directory should reside within your home directory structure. Choose a location that fits your workflow, such as ~/network/drive. Create this directory using the mkdir command:
mkdir -p ~/network/drive
This directory will serve as the local access point for the remote SMB share. Ensure that the ownership of this directory matches your user ID to avoid permission issues when accessing files later.

Configuring the Systemd User Service

The core of this solution is a systemd user unit file. Unlike system-wide services, user units run under your UID and do not require root access. Create a new service file in the .config/systemd/user directory within your home folder:
mkdir -p ~/.config/systemd/user
Create a file named smb-mount.service in this directory:
nano ~/.config/systemd/user/smb-mount.service
Populate the file with the following configuration. This setup ensures the service waits for network availability and mounts the share using your stored credentials:
[Unit]
Description=Mount SMB Share for User
After=network-online.target
Wants=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/mount -t cifs //server/share /home/youruser/network/drive \
    -o credentials=/home/youruser/.smbcredentials,nofail,uid=%i,gid=%i,vers=3.0
ExecStop=/usr/bin/umount /home/youruser/network/drive

[Install]
WantedBy=default.target
Several key directives are critical here. The After=network-online.target line ensures the service does not attempt to mount before the network is fully established. The Type=oneshot combined with RemainAfterExit=yes tells systemd that the service is considered "active" even after the mount command finishes, allowing it to be stopped cleanly upon logout. The uid=%i and gid=%i parameters automatically substitute the current user's ID and group ID, ensuring file ownership is correct regardless of which user enables the service. Replace //server/share with your actual UNC path and adjust the mount path if you chose a different directory.

Enabling and Starting the Service

Once the service file is saved, you need to reload the systemd user daemon to recognize the new unit. Use the --user flag to interact with the user-level instance:
systemctl --user daemon-reload
Enable the service so it starts automatically when you log in. The default.target defined in the [Install] section typically corresponds to the graphical session login:
systemctl --user enable smb-mount.service
To test the configuration immediately without waiting for a reboot or logout, start the service manually:
systemctl --user start smb-mount.service
Check the status to verify it is active and running:
systemctl --user status smb-mount.service
If successful, you should see the drive accessible at ~/network/drive. If the service fails, check the journal logs for detailed error messages using journalctl --user -u smb-mount.service. Common issues include incorrect network paths, invalid credentials, or network interfaces not being ready fast enough. For more complex dependency chains, consider reviewing how to handle service failures or restart policies, as outlined in our guide on Systemd Service Failures.

Troubleshooting and Maintenance

Network mounts can sometimes become stale if the connection drops. The nofail option in the mount options prevents boot errors if the share is unavailable, but it may leave the mount point empty. To refresh the connection, you can stop and restart the service:
systemctl --user restart smb-mount.service
If you need to modify the mount options or credentials, edit the respective files and reload the daemon again. Remember that changing the credentials file requires restarting the service for the changes to take effect. For deeper insights into variable expansion within these service files, refer to our article on Expanding the Use of Variables in a systemd Service File.

Frequently Asked Questions

Why use a user service instead of fstab?

Using a systemd user service allows per-user credentials and mount points without requiring root access. It integrates better with the login session and handles network dependencies more dynamically than static fstab entries.

What happens if the network disconnects?

With the nofail option, the system will not halt during boot if the share is unreachable. However, the mount point may appear empty until the service is restarted or the network stabilizes.

How do I update my SMB password?

Edit the .smbcredentials file in your home directory to change the password. After saving, restart the systemd user service to apply the new credentials using systemctl --user restart smb-mount.service.

Can I mount multiple shares?

Yes, you can create separate service files for each share, such as share2.mount.service. Each service should have a unique description and target a different mount directory to avoid conflicts.

Is this method secure?

It is reasonably secure because the credentials file has restricted permissions (600) and is owned by the user. However, storing plaintext passwords always carries some risk; consider using stronger authentication methods if available on your SMB server.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More