You are currently viewing Connect Server Drives on Linux: Permanent Connections to Windows & MacOS

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

AdvantageExplanation
Always availableFiles are immediately accessible
TransparentIntegrated into file managers
AutomaticNo manual mounting needed
StableSurvives 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

  1. Share folder (Right-click → Properties → Sharing)
  2. Set user permissions
  3. Assign static IP for Windows server
  4. 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)

  1. “System Settings” → “General” → “Sharing”
  2. Activate “File Sharing” (toggle switch)
  3. Click the Info icon “ⓘ” on the right
  4. “+” to add folders
  5. 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: usernamePublicMacintosh HDBackup

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

OptionWhat it doesWhy important
nofailNo boot error if server unavailable⭐ Prevents boot problems
x-systemd.automountMounts only on accessSaves resources, automatic recovery
uid=1000,gid=1000Files belong to your userNo permission problems
iocharset=utf8Correct special charactersImportant for Windows server
nopermIgnores permission checksOften 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 Public folder 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:

  1. Changes in /etc/fstab only become active after systemctl daemon-reload
  2. Automount (x-systemd.automount) mounts only when needed
  3. 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-utils installed
  • /etc/.smbcredentials with correct data (permissions 640!)
  • Mount folders created (/server/...)
  • Static IPs used (not hostnames!)
  • /etc/fstab with nofail and x-systemd.automount
  • After fstab changes: sudo systemctl daemon-reload
  • sudo mount -a successful
  • 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:

  1. Time Saving: No more manual mounting
  2. Reliability: Automatic recovery from problems
  3. Integration: Seamless in file managers
  4. Stability: Survives reboots and network changes

Your Workflow After Setup:

  1. Start Linux
  2. Access /server/windows/documents or /server/macos/home
  3. Work as if they were local folders
  4. 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!



Donate Bild

Support / Donation Link for the Channel
If my posts have been helpful or supported you in any way, I’d truly appreciate your support 🙏

PayPal Link
Bank transfer, Bitcoin and Lightning


#Linux #Windows #MacOS #ServerDrive #PermanentConnection #SMB #CIFS #Systemd #Automation #Debian #Ubuntu #LinuxMint #HowTo #Tutorial

Leave a Reply