Auto Mount Windows Shared Folder on Linux Using CIFS – Complete Step-by-Step Guide
Auto Mount Windows Shared Folder on Linux Using CIFS – Complete Step-by-Step Guide
📅 Last Updated: August 2026
This guide has been fully updated for Oracle Linux, Red Hat Enterprise Linux (RHEL), Rocky Linux, AlmaLinux, CentOS, Ubuntu, Debian, and other modern Linux distributions. It covers SMB/CIFS file sharing, automatic mounting using /etc/fstab, secure credential management, systemd integration, production troubleshooting, and Linux administration best practices.
Automatically mounting Windows shared folders on Linux is a common requirement in enterprise environments where Linux servers need continuous access to files stored on Microsoft Windows file servers, NAS devices, or Active Directory environments.
Without automatic mounting, administrators must manually mount the shared folder after every server reboot. This can interrupt backup jobs, Oracle RMAN backups, application integrations, scheduled scripts, ETL processes, and other business-critical services.
By configuring Linux to automatically mount Windows shared folders during system startup, administrators can ensure that applications always have access to the required network storage without manual intervention.
Install the cifs-utils package, create a local mount point, verify that the Windows share can be mounted manually, securely store credentials in a protected credentials file, configure the share in /etc/fstab, test the configuration using mount -a, and verify that the share mounts automatically after reboot.
What is SMB/CIFS?
SMB (Server Message Block) is a network file-sharing protocol developed for sharing files, printers, and other network resources between computers.
CIFS (Common Internet File System) is an implementation of the SMB protocol commonly used by Microsoft Windows systems. Modern Linux systems use the CIFS filesystem driver to access Windows shared folders.
Today, most Windows servers use SMB version 2 or SMB version 3, while Linux accesses these shares through the CIFS client provided by the cifs-utils package.
Windows Share Architecture
Windows File Server
│
▼
SMB / CIFS Protocol
│
▼
Network
│
▼
Linux Server
│
▼
CIFS Client (cifs-utils)
│
▼
Local Mount Point
│
▼
Applications
Once mounted, the Windows shared folder behaves like a local Linux directory, allowing applications to read and write files transparently, subject to the permissions granted by the Windows server.
Why Automatically Mount Windows Shares?
Automatic mounting ensures that shared storage is available immediately after the Linux server starts, eliminating the need for manual intervention.
Common use cases include:- Oracle RMAN backup destinations.
- Application document repositories.
- Shared upload directories.
- Data warehouse imports and exports.
- ETL processes.
- Enterprise reporting.
- Shared software repositories.
- Log archival.
Benefits of Automatic Mounting
- No manual mounting after reboot.
- Improved application availability.
- Reliable scheduled jobs.
- Simplified administration.
- Centralized storage management.
- Consistent backup locations.
- Reduced operational errors.
- Improved disaster recovery readiness.
Typical Symptoms
Administrators usually encounter one or more of the following problems:- Windows share disappears after reboot.
- Backup jobs fail because the mount is missing.
- "No such file or directory" errors.
- "Permission denied" while accessing the share.
- Applications cannot locate required files.
- Mount command works manually but not during startup.
- System boot delays while waiting for the network share.
Business Impact
If Windows shares are not mounted automatically, organizations may experience:- Failed Oracle backups.
- Application downtime.
- Interrupted batch processing.
- Missing reports.
- Lost file transfers.
- Delayed business operations.
- Manual administrator intervention after every reboot.
Common Root Causes
- cifs-utils package not installed.
- Incorrect Windows username or password.
- Incorrect share path.
- Network unavailable during boot.
- Incorrect
/etc/fstabentry. - Unsupported SMB protocol version.
- Firewall blocking SMB ports.
- DNS or hostname resolution problems.
- Incorrect Linux file permissions.
- Authentication failures.
- Windows server unavailable.
Before You Begin
Verify the following information before configuring automatic mounting:- Windows server hostname or IP address.
- Shared folder name.
- Windows username.
- Windows password.
- Network connectivity.
- Administrative privileges on the Linux server.
- Correct SMB version if required by your environment.
Avoid placing Windows usernames and passwords directly inside /etc/fstab. Store credentials in a dedicated file with restricted permissions (for example, readable only by the root user) and reference that file from the mount configuration. This approach is more secure and easier to maintain.
Prerequisites
Before proceeding, ensure:- The Windows shared folder is accessible from the Linux server.
- The Linux server can reach the Windows host over the network.
- The SMB service is running on the Windows server.
- The required firewall ports are open.
- The Windows account has permission to access the shared folder.
- The Linux server has internet or repository access to install required packages if necessary.
Always verify that the Windows share can be mounted manually before configuring automatic mounting. Confirm network connectivity, authentication, and permissions first. Once manual mounting succeeds, automate the process using a secure credentials file and a carefully tested /etc/fstab entry.
Step-by-Step Configuration
The following procedure demonstrates how to securely configure a Windows shared folder so that it mounts automatically every time the Linux server boots.
Step 1 – Install cifs-utils
The cifs-utils package provides the Linux CIFS client required to mount Windows SMB shares.
Oracle Linux, RHEL, Rocky Linux, AlmaLinux, CentOS
sudo dnf install cifs-utils # Older systems sudo yum install cifs-utils
Ubuntu / Debian
sudo apt update sudo apt install cifs-utilsVerify installation:
mount.cifs -V
Step 2 – Create a Local Mount Point
Choose the directory where the Windows share will appear. Example:sudo mkdir -p /mnt/windows_shareVerify:
ls -ld /mnt/windows_share
Step 3 – Test Manual Mount
Before configuring automatic mounting, verify that the share can be mounted successfully. Example:sudo mount -t cifs //SERVER/SHARE /mnt/windows_share \ -o username=USERNAMEThe system will normally prompt for the password. Verify the mount:
df -h mount | grep cifsIf manual mounting fails, resolve authentication, network, or permission issues before proceeding.
Step 4 – Create a Secure Credentials File (Recommended)
Instead of placing the Windows password directly in/etc/fstab, create a dedicated credentials file.
Example:
sudo vi /etc/cifs-credentialsContents:
username=USERNAME password=PASSWORDIf your environment requires a Windows domain:
domain=MYDOMAINProtect the file:
sudo chmod 600 /etc/cifs-credentials sudo chown root:root /etc/cifs-credentials
Step 5 – Configure /etc/fstab
Open:sudo vi /etc/fstabExample entry:
//SERVER/SHARE /mnt/windows_share cifs credentials=/etc/cifs-credentials,_netdev,nofail,vers=3.0,file_mode=0644,dir_mode=0755 0 0This configuration allows the share to mount automatically during boot while keeping credentials outside of
/etc/fstab.
Understanding Common Mount Options
| Option | Description |
|---|---|
| credentials= | Reads username and password from a protected credentials file. |
| _netdev | Delays mounting until the network is available. |
| nofail | Allows the system to continue booting even if the share is unavailable. |
| vers=3.0 | Requests SMB version 3.0. Adjust if your server requires another supported version. |
| file_mode=0644 | Default permissions for files. |
| dir_mode=0755 | Default permissions for directories. |
| uid= | Assigns ownership of mounted files to a Linux user. |
| gid= | Assigns group ownership. |
Step 6 – Test the Configuration
Do not reboot immediately. Instead, test the new/etc/fstab entry.
sudo mount -aIf no errors are displayed, verify:
mount | grep cifs df -hThe Windows share should now appear as a mounted filesystem.
Step 7 – Verify After Reboot
Restart the Linux server.sudo rebootAfter startup:
df -h mount | grep cifsConfirm:
- The Windows share mounted automatically.
- Applications can access the files.
- No boot delays occurred.
Common Mount Errors
| Error | Likely Cause | Recommended Action |
|---|---|---|
| Permission denied | Incorrect username, password, or share permissions. | Verify credentials and Windows share permissions. |
| No route to host | Network connectivity issue. | Verify network connectivity and routing. |
| Host is down | Windows server unavailable. | Confirm the server is powered on and reachable. |
| mount error(95) | Unsupported SMB protocol version. | Specify a compatible vers= option. |
| Mount fails during boot | Network not yet available. | Use _netdev and verify boot order. |
Production Case Study
An Oracle Linux server stored Oracle RMAN backup pieces on a Windows file server. After a planned operating system reboot, scheduled backup jobs failed because the Windows share had not been mounted automatically.
Investigation showed that the existing /etc/fstab entry lacked the _netdev option, causing the system to attempt the mount before network services were fully available.
The Linux administrator updated the configuration to use a protected credentials file together with _netdev and nofail, tested the configuration using mount -a, and confirmed that the share mounted successfully after reboot. Oracle backup jobs resumed without further manual intervention.
Linux Administrator Checklist
| Verification | Status |
|---|---|
| cifs-utils Installed | ☐ |
| Mount Point Created | ☐ |
| Manual Mount Successful | ☐ |
| Credentials File Created | ☐ |
| Credentials File Protected | ☐ |
| /etc/fstab Updated | ☐ |
| mount -a Successful | ☐ |
| Automatic Mount Verified After Reboot | ☐ |
Using systemd Automount (Modern Linux)
Modern Linux distributions use systemd to manage services and mounted filesystems. In many enterprise environments, administrators use systemd automount functionality together with /etc/fstab to improve boot reliability and reduce startup delays when network shares are temporarily unavailable.
One commonly used option is:
x-systemd.automount
Example /etc/fstab entry:
//SERVER/SHARE /mnt/windows_share cifs credentials=/etc/cifs-credentials,_netdev,nofail,x-systemd.automount,vers=3.0,file_mode=0644,dir_mode=0755 0 0
With this configuration, the share is mounted automatically the first time it is accessed rather than during the initial boot process. This can improve startup performance on systems that depend on remote storage.
SMB Protocol Version Recommendations
Modern Windows servers typically use SMB version 3.x. Linux administrators should specify a supported SMB version when required by their environment.
| SMB Version | Typical Usage |
|---|---|
| SMB 1.0 | Legacy environments only. Generally avoid due to security concerns. |
| SMB 2.x | Supported by many Windows Server versions. |
| SMB 3.x | Recommended for modern Windows environments. |
If a mount fails with protocol-related errors, verify the SMB version supported by both the Linux client and the Windows server.
Security Best Practices
- Store credentials in a protected credentials file instead of directly in
/etc/fstab. - Restrict credentials file permissions to the root user.
- Use SMB 3.x whenever supported.
- Avoid enabling legacy SMB protocols unless required for compatibility.
- Grant only the minimum Windows share permissions required.
- Regularly rotate passwords used for automated mounts.
- Review firewall rules and network access.
- Monitor mount status after operating system updates.
- Document all production mount configurations.
- Test automatic mounting after every planned maintenance window.
Common Linux Administrator Mistakes
- Saving passwords directly inside
/etc/fstab. - Using incorrect Windows usernames or passwords.
- Forgetting to install
cifs-utils. - Using an unsupported SMB protocol version.
- Omitting the
_netdevoption. - Ignoring DNS or hostname resolution issues.
- Creating mount points with incorrect permissions.
- Not testing the configuration using
mount -a. - Rebooting before verifying the configuration.
- Ignoring Windows share permissions.
Useful Linux Commands
Verify Installed CIFS Utilities
mount.cifs -V
Display Mounted Filesystems
mount df -h
Test Network Connectivity
ping SERVER_NAME
Test Configuration Without Reboot
sudo mount -a
View systemd Mount Status
systemctl status remote-fs.target
Troubleshooting Flowchart
Windows Share
│
▼
Network Reachable?
│
├────────────► No
│ │
│ ▼
│ Resolve Network Issue
│
▼
Manual Mount Works?
│
├────────────► No
│ │
│ ▼
│ Verify Credentials & Permissions
│
▼
Configure /etc/fstab
│
▼
Run mount -a
│
├────────────► Errors
│ │
│ ▼
│ Correct Configuration
│
▼
Reboot
│
▼
Share Mounted Automatically
│
▼
Applications Access Files
Frequently Asked Questions (FAQ)
Why does the share mount manually but not after reboot?
This usually indicates that the network was not fully available during boot, the /etc/fstab entry is incorrect, or required mount options such as _netdev are missing.
Should I store the Windows password in /etc/fstab?
No. A protected credentials file is more secure and easier to maintain than embedding credentials directly in the /etc/fstab entry.
Which SMB version should I use?
Use the newest SMB version supported by both the Linux client and the Windows server. Modern environments commonly use SMB 3.x.
How can I verify my configuration without rebooting?
Run sudo mount -a. If the command completes without errors and the share appears in mount or df -h, the configuration is likely correct.
Can I use Windows hostnames instead of IP addresses?
Yes, provided DNS or another supported name resolution service can successfully resolve the Windows server name.
Related Linux Articles
- How to Recover /etc/fstab in Linux
- Unable to Mount NTFS File System in Linux
- SQL*Plus Error While Loading Shared Libraries
- About the Author
About the Author
Rana Abdul Wahid is an Oracle Database Consultant with more than 15 years of experience in Oracle Database Administration, Oracle E-Business Suite Application DBA, Oracle Cloud Infrastructure (OCI), Linux/Unix Administration, Oracle RAC, Oracle Data Guard, RMAN Backup & Recovery, MySQL, Microsoft SQL Server, PostgreSQL, and enterprise infrastructure management.
He has implemented Linux file sharing, Oracle backup storage, enterprise NAS integration, and automated filesystem mounting across numerous production environments. His technical articles are based on practical system administration experience and are intended to help administrators deploy secure and reliable enterprise Linux solutions.
Conclusion
Automatically mounting Windows shared folders on Linux improves system reliability, reduces administrative effort, and ensures that business applications always have access to required network storage. Proper configuration of cifs-utils, a secure credentials file, and a well-tested /etc/fstab entry provides a stable and maintainable solution for enterprise environments.
By following Linux administration best practices, verifying manual connectivity before automation, and testing configurations after maintenance or operating system upgrades, administrators can avoid common mount failures and ensure dependable access to shared Windows resources.
After configuring automatic mounts, always test the configuration using mount -a before rebooting. Following any operating system updates, network changes, or Windows server upgrades, verify that the share mounts correctly and that applications retain the required access permissions.
Found this guide helpful? Visit the Oracle Error Codes Guide and Linux administration articles on this blog for more production-tested Oracle Database, Linux, Oracle E-Business Suite, and enterprise troubleshooting solutions.
Comments
Post a Comment