Connect Server Drives on Linux: Permanent Connections to Windows & MacOS
Imagine starting up your Linux computer and having connect Server Drives on Linux automatically! Is that cool?
No manual connecting, no complicated commands, just a seamless experience. In this blog post, I’ll show you exactly how to achieve this!
Video: Linux, Windows, MacOS, Server Drive, Permanent Connection, SMB, CIFS, Systemd, Automation, Debian, Ubuntu, Linux Mint, HowTo, Tutorial,
Language: 🇩🇪|🇬🇧
☝️ Use YouTube subtitles for all languages.
⭐ IMPORTANT NOTE: Multiple Servers with Different Accounts
You can easily connect to multiple different Windows and MacOS servers, each with its own login credentials. One credentials file per server – cleanly separated and easy to maintain!
Please also note this article:
📊 Why Permanent Connections Make Sense
| Advantage | Explanation |
|---|---|
| Always available | Files are immediately accessible |
| Transparent | Integrated into file managers |
| Automatic | No manual mounting needed |
| Stable | Survives network interruptions |
Tested and works on: Debian 12, Ubuntu 22.04/24.04, Linux Mint 21.x
🚀 Let’s Get Started: Basic Preparation
Step 1: Install CIFS-Utils
Same on all Debian-based systems:
bash
sudo apt update sudo apt install cifs-utils
Step 2: Secure Password Management
Never, really NEVER store passwords directly in fstab! Instead:
bash
sudo nano /etc/.smbcredentials
Content for Windows Server:
bash
username=YOUR_USER password=YOUR_PASSWORD # Optional for domains: # domain=MY_DOMAIN
Content for MacOS Server:
bash
username=YOUR_MAC_USER password=YOUR_PASSWORD
Correct Permissions (IMPORTANT!):
bash
# Root owner, but your group must be able to read sudo chown root:YOUR_GROUP /etc/.smbcredentials sudo chmod 640 /etc/.smbcredentials
💡 Tip: Find your group with id -gn. Often it’s your username or users.
Step 3: Create Mount Points
bash
# Create folders for server drives
sudo mkdir -p /server/{windows,macos,shared}
# Optional: Change owner for easier access
sudo chown $USER:$USER /server/*
🪟 Connect Windows Server Permanently
Preparation on Windows Side
- Share folder (Right-click → Properties → Sharing)
- Set user permissions
- Assign static IP for Windows server
- Note:
\\IP-ADDRESS\SHARENAME
The /etc/fstab Configuration:
bash
sudo nano /etc/fstab
Add this line:
bash
//192.168.1.20/Documents /server/windows/documents cifs credentials=/etc/.smbcredentials,uid=1000,gid=1000,file_mode=0644,dir_mode=0755,iocharset=utf8,nofail,x-systemd.automount 0 0
💡 Find your User-ID: id -u (usually 1000 for the first user)
🍏 Connect MacOS Server Permanently
Prepare MacOS (from Sonoma/Ventura)
- “System Settings” → “General” → “Sharing”
- Activate “File Sharing” (toggle switch)
- Click the Info icon “ⓘ” on the right
- “+” to add folders
- Leave SMB activated – standard on modern MacOS
IMPORTANT: Find Available Shares
Before configuring fstab, find the correct share name:
bash
smbclient -L //YOUR_MAC_IP -U YOUR_MAC_USER
Typical MacOS shares: username, Public, Macintosh HD, Backup
The /etc/fstab Configuration for MacOS:
bash
//192.168.1.30/username /server/macos/home cifs credentials=/etc/.smbcredentials,uid=1000,gid=1000,file_mode=0644,dir_mode=0755,noperm,nofail,x-systemd.automount 0 0
⚠️ IMPORTANT: No line breaks in fstab! Everything in one line!
🔧 Important Options Explained
| Option | What it does | Why important |
|---|---|---|
nofail | No boot error if server unavailable | ⭐ Prevents boot problems |
x-systemd.automount | Mounts only on access | Saves resources, automatic recovery |
uid=1000,gid=1000 | Files belong to your user | No permission problems |
iocharset=utf8 | Correct special characters | Important for Windows server |
noperm | Ignores permission checks | Often needed for MacOS server |
🧪 Test Configuration – Step by Step
Step 1: Manual Test
bash
# First test manually sudo mount -t cifs //192.168.1.30/username /server/macos/home -o credentials=/etc/.smbcredentials,uid=1000
Step 2: Check fstab Syntax
bash
# Test fstab (BUT BEFORE!) sudo systemctl daemon-reload # ⭐ IMPORTANT: Reload systemd! sudo mount -a
Step 3: Check Success
bash
# Check mount status mount | grep cifs # Show content ls -la /server/macos/home
🚨 Troubleshooting – Common Errors and Solutions
Error 1: “No such file or directory”
bash
# 1. Find available shares smbclient -L //SERVER_IP -U USER # 2. Test with different shares sudo mount -t cifs //SERVER_IP/SHARE /mnt/test -o credentials=...
Error 2: “NT_STATUS_LOGON_FAILURE”
bash
# Check credentials sudo cat /etc/.smbcredentials # Correct username/password
Error 3: “Unable to open credentials file”
bash
# Correct permissions sudo chown root:$(id -gn) /etc/.smbcredentials sudo chmod 640 /etc/.smbcredentials
Error 4: Systemd Warning After fstab Change
bash
# Always after fstab changes: sudo systemctl daemon-reload sudo mount -a
Error 5: MacOS FileVault Problem
If home directory doesn’t work:
- Use
Publicfolder instead of Home - Or create a separate share folder on MacOS
🔄 Understanding Systemd – The Key to Success
Modern Linux systems use Systemd for mounts. Therefore:
- Changes in /etc/fstab only become active after
systemctl daemon-reload - Automount (
x-systemd.automount) mounts only when needed - No manual mounting needed after each startup
Practical Alias:
bash
# Add to ~/.bashrc alias fstab-reload='sudo systemctl daemon-reload && sudo mount -a'
📋 Success Checklist
cifs-utilsinstalled/etc/.smbcredentialswith correct data (permissions 640!)- Mount folders created (
/server/...) - Static IPs used (not hostnames!)
/etc/fstabwithnofailandx-systemd.automount- After fstab changes:
sudo systemctl daemon-reload sudo mount -asuccessful- File access works
🎯 My Recommended fstab Entries
Windows Server (optimized):
bash
//192.168.1.20/Documents /server/windows/documents cifs credentials=/etc/.smbcredentials,uid=1000,gid=1000,iocharset=utf8,nofail,x-systemd.automount 0 0
MacOS Server (optimized):
bash
//192.168.1.30/username /server/macos/home cifs credentials=/etc/.smbcredentials,uid=1000,gid=1000,noperm,nofail,x-systemd.automount 0 0
For MacOS Problems:
bash
//192.168.1.30/Public /server/macos/public cifs credentials=/etc/.smbcredentials,uid=1000,gid=1000,noperm,nofail,x-systemd.automount 0 0
🏁 Conclusion: Set Up Once, Benefit Always
Advantages at a Glance:
- Time Saving: No more manual mounting
- Reliability: Automatic recovery from problems
- Integration: Seamless in file managers
- Stability: Survives reboots and network changes
Your Workflow After Setup:
- Start Linux
- Access
/server/windows/documentsor/server/macos/home - Work as if they were local folders
- Profit!
Whether Windows or MacOS – with this method you have permanently reliable server connections!
Do you have questions or your own experiences? Share them in the comments!

Support / Donation Link for the Channel
If my posts have been helpful or supported you in any way, I’d truly appreciate your support 🙏
#Linux #Windows #MacOS #ServerDrive #PermanentConnection #SMB #CIFS #Systemd #Automation #Debian #Ubuntu #LinuxMint #HowTo #Tutorial