Mount Windows Share in Ubuntu - Permanent Setup
Connect to a Windows shared folder from Ubuntu once, the manual way, and it vanishes at the next reboot. This setup mounts the share permanently with cifs-utils and an fstab entry — with the Windows password kept in a protected credentials file, _netdev and nofail so boot never hangs, and uid/gid so the files belong to you.
📑Chapters
- The problem — a share you open by hand disappears after every reboot
- Quick test — open the share once from the Files app
- Install the cifs-utils package
- Create the mount point at /mnt/SharedDocs
- Save the Windows login in a protected credentials file
- Add the permanent entry to /etc/fstab, with _netdev and nofail
- Mount it now, verify it, then do the reboot test
📋 Overview & Step-by-Step Guide
Test the Share First from the Files App
Before making anything permanent, prove the basics once: the Windows PC is sharing the folder, the network path works, and your Windows username and password are accepted. Open the Files app, press Ctrl + L to open the location bar, and type the share address — in the video it is the SharedDocs folder on the PC named OFFICE-PC:
smb://OFFICE-PC/SharedDocs
Enter the Windows username and password when asked. If the folder opens and you can see its files, the share name, the PC name and the login are all correct — write them down exactly, because the permanent setup uses the same three things. Replace OFFICE-PC and SharedDocs with your own PC name and share name throughout this guide.
smb://192.168.1.10/SharedDocs. Give the Windows PC a fixed or reserved IP address — a permanent mount is only as reliable as the address it points to.Install cifs-utils
A permanent mount needs the CIFS tools — the mount.cifs helper that lets Ubuntu attach an SMB (Windows) share as a normal folder. Open a terminal and install the package:
sudo apt update
sudo apt install cifs-utils
Without this package, the fstab entry in Step 5 has nothing to work with and the mount fails — this small install is what separates a one-time browse from a real, boot-time mount.
Create the Mount Point
A mount point is simply an empty folder where the share's contents will appear. Create one under /mnt, named after the share:
sudo mkdir -p /mnt/SharedDocs
Leave this folder empty. When the share is mounted, everything inside /mnt/SharedDocs is really the files on the Windows PC — and when it is not mounted, the folder is just empty, which is also a useful way to tell at a glance whether the mount is live.
Store the Login in a Protected Credentials File
The mount needs your Windows password at every boot, but that password must never sit inside /etc/fstab itself — fstab can be read by every user account on the machine. Instead, keep the login in its own small file that only root can read. Create it:
sudo nano /root/.smbcredentials
Type exactly two lines, with your own Windows username and password, then save with Ctrl + O and exit with Ctrl + X:
username=YourWindowsUser
password=YourWindowsPassword
Now lock the file down so only root can read it:
sudo chmod 600 /root/.smbcredentials
chmod 600 is the whole point of this step, not an optional extra. Without it, the credentials file is just your Windows password written in plain text where other accounts on the PC can read it. And remember for later: if you ever change the Windows password, update this file too — a stale password here is the most common reason a working mount suddenly stops.Add the Permanent fstab Entry
Now tell Ubuntu to mount the share at every boot. First keep a backup copy of the original fstab — one wrong line in this file can affect booting, and the backup is your way back. Then open the file:
sudo nano /etc/fstab
Add this single line at the very end of the file:
//OFFICE-PC/SharedDocs /mnt/SharedDocs cifs credentials=/root/.smbcredentials,iocharset=utf8,_netdev,nofail,uid=1000,gid=1000 0 0
What each part does: //OFFICE-PC/SharedDocs is the share, /mnt/SharedDocs is where it appears, and cifs is the filesystem type. credentials= points to the protected file from Step 4, so no password appears in fstab. iocharset=utf8 keeps file names with special characters correct. _netdev tells the system this mount needs the network, so it waits for the network instead of failing too early. nofail means that if the Windows PC is switched off, Ubuntu still boots normally instead of hanging or dropping to an emergency prompt. uid=1000,gid=1000 makes the mounted files owned by your Ubuntu user, so your apps can save into the share without sudo — 1000 is the first user account's usual ID; check your own with the id command and adjust if yours differs.
Mount Now and Verify Before You Reboot
Do not reboot yet. Test the fstab entry right now, while you can still see any error it produces:
sudo mount -a
mount -a mounts everything listed in fstab. If it finishes silently, the entry is good — open /mnt/SharedDocs and you should see the Windows share's files, and a quick df -h shows the share listed as a mounted filesystem. Create a small test file inside it to prove you can write, not just read. Only after this test passes, reboot the Ubuntu machine once: the share should be back in place on its own, with no manual connection — that reboot is the real proof the permanent setup works.
mount -a reports an error, fix it now rather than after a reboot — read the message, because it usually names the problem directly: a wrong share name or PC address, wrong contents in the credentials file, or "permission denied" from the Windows side, where the user needs permission on both the Sharing tab and the Security tab of the folder. A mount rarely breaks on its own later; when one does, something changed on one side — the Windows password, the PC's address, or the permissions.🏷️Topic Search Variables & Keywords
🎙️ Full Transcript — tap to expand
Step-by-Step Troubleshooting Guide & Solutions - Mount Windows Share Permanently in Ubuntu | No More Disconnects. On-screen demonstration by Technical Anshu.
Mount a Windows shared folder in Ubuntu so it returns after every reboot. The complete cifs-utils and fstab setup with a protected credentials file, _netdev and nofail safety, and uid gid ownership done right.
(transcript ends here on the source page)
❓ Frequently Asked Questions
Is this tutorial 100% free to follow?
Yes! All guides and methods demonstrated by Technical Anshu use free, legal, and educational resources.
Can beginners follow this guide?
Absolutely! Every step is demonstrated on-screen with detailed instructions so anyone can follow along easily.
Where can I ask questions if I get stuck?
Leave a comment directly on the YouTube video, and our community and Technical Anshu will help you out.
🚀 Watch the Full Tutorial on YouTube
🚀 Watch the full step-by-step video tutorial on YouTube: https://www.youtube.com/watch?v=fwYObXTidis
Subscribe to Technical Anshu for IT support, Windows troubleshooting, and server management.
▶️ Watch Full Video