Skip to content

Mounting NAS shares on a desktop

My Linux desktop (KDE Plasma) mounts the NAS's two Samba shares, shared and media, as ordinary folders at /mnt/shared and /mnt/media. Every program sees them as normal paths, and Dolphin shows them in its sidebar. The server side of these shares is on the Samba page.


Kernel mount vs Dolphin's smb://

Dolphin can open smb://<NAS_HOSTNAME>/shared by itself without any setup. That's KDE's KIO layer talking SMB in user space, and it's fine for browsing. It's a poor fit for daily use:

Dolphin smb:// (KIO) Kernel CIFS mount (/mnt/shared)
Who can use it KDE apps. Other apps get a temporary local copy, or nothing Every program: terminal, scripts, slicers, media players, Syncthing, backup tools
Paths smb://... URLs Real paths like /mnt/media/movies/..., the same in every app and in config files
When it connects When you open it, per app At boot (or on first access with automount)
Credentials Stored in KWallet, per user One root-only credentials file

A real mount is better for apps because they open a normal file path. A KIO URL only works in programs that understand KIO, and non-KDE programs either can't use it or work on a temporary copy that has to be uploaded again. So I use a kernel mount and let Dolphin show it.


1. Install the CIFS tools

sudo apt install cifs-utils        # Debian/Ubuntu
# sudo pacman -S cifs-utils        # Arch
# sudo dnf install cifs-utils      # Fedora

2. Credentials file

Keep the Samba password out of /etc/fstab (which is world-readable):

sudo install -m 600 -o root -g root /dev/null /etc/samba/credentials
sudo nano /etc/samba/credentials
/etc/samba/credentials
username=<YOUR_USER>
password=<your samba password>
ls -l /etc/samba/credentials   # -rw------- 1 root root ... : only root can read it

3. Mount points and fstab

sudo mkdir -p /mnt/shared /mnt/media

These are the two lines my desktop runs:

/etc/fstab
//<NAS_HOSTNAME>/shared /mnt/shared cifs credentials=/etc/samba/credentials,uid=<PUID>,gid=<PGID>,iocharset=utf8,_netdev 0 0
//<NAS_HOSTNAME>/media  /mnt/media  cifs credentials=/etc/samba/credentials,uid=<PUID>,gid=<PGID>,iocharset=utf8,_netdev 0 0
Option Why
credentials= Reads username= / password= from the 0600 file above
uid= / gid= Samba doesn't send Unix ownership here, so without these every file shows as owned by root and your desktop apps can't write. Use your own user's ids (id -u, id -g; usually 1000)
iocharset=utf8 File names with accents, emoji or non-Latin scripts come through correctly
_netdev It's a network filesystem: mount it after the network is up, unmount it before the network goes down at shutdown

The SMB version is negotiated automatically (SMB 3.x against a current Samba), so there's no vers= option.

sudo systemctl daemon-reload
sudo mount -a
findmnt -t cifs           # both shares listed
df -h /mnt/shared /mnt/media
touch /mnt/shared/test && rm /mnt/shared/test   # write test as your user

4. In Dolphin

  • Devices. Dolphin's Places panel lists network shares from /etc/fstab by itself (KDE's Solid reads fstab), under Devices, with a network-drive icon. Click one to open it; mounted shares show an eject button. On my desktop that's all I use.
  • A named bookmark (optional). Open /mnt/media, then right-click it in the location bar or drag the folder onto the Places panel, and choose Add to Places. You can rename it ("Media") and pick an icon. Bookmarks are stored per user in ~/.local/share/user-places.xbel.
  • File dialogs in KDE and GTK apps show the same Places, so "Save to NAS" is one click from any app.

Same files, two entries

If Dolphin also shows the NAS under Network (Samba discovery), that entry is the KIO smb:// view of the same files. Use the /mnt/... entries so the paths you copy into apps are real paths.


5. Make it robust

The plain lines above mount at boot and are fine on a desktop that's always on the same LAN as the NAS. These options help when that isn't true:

Option What it does When to add it
nofail A share that can't mount doesn't fail the boot Always worth it
x-systemd.automount Mounts the share on first access instead of at boot; boot never waits on the NAS Laptops, a NAS that boots slower than the desktop, or one that's sometimes off
x-systemd.idle-timeout=600 Unmounts an automounted share after 10 idle minutes With automount, so a NAS reboot doesn't leave a stale mount
x-systemd.mount-timeout=30 Caps how long an access waits for the server With automount
soft A dead server returns I/O errors instead of hanging the program. This is already the CIFS default; just never add hard on a desktop Leave as is

A robust version of the same line:

/etc/fstab
//<NAS_HOSTNAME>/media /mnt/media cifs credentials=/etc/samba/credentials,uid=<PUID>,gid=<PGID>,iocharset=utf8,_netdev,nofail,x-systemd.automount,x-systemd.idle-timeout=600,x-systemd.mount-timeout=30 0 0
sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target
ls /mnt/media        # triggers the mount
findmnt /mnt/media   # autofs + cifs

More on this in Network mounts that fail at boot.

Desktop VPNs and network mounts

A VPN client on the desktop can route your NAS's subnet into the tunnel. The mounts then hang, and Dolphin and every file dialog that touches them freeze with them. Add a route for your home address range on the LAN connection, as described in Desktop VPN tunnelling your LAN.


Troubleshooting

journalctl -b | grep -i cifs          # mount errors at boot
sudo mount -v /mnt/media              # mount one share by hand, verbose
smbclient -L //<NAS_HOSTNAME> -U <YOUR_USER>   # can you see the shares at all?
Error Usual cause
mount error(13): Permission denied Wrong password in the credentials file, or the user isn't in valid users / has no smbpasswd entry on the NAS
mount error(2): No such file or directory Share name typo (it's the [name] in smb.conf, not the path)
mount error(112): Host is down Name doesn't resolve or the NAS isn't reachable: check ping <NAS_HOSTNAME>, firewall (TCP 445), VPN
Files owned by root, can't write Missing or wrong uid= / gid=

Sources & further reading