Viewing files on a network drive

Here the dilemma. I have a network setup as follows:

  1. Monterey OS installed on 2014 Mac Mini and file sharing enabled
  2. Laptop running windows 11
  3. Laptop running latest Manjaro Gnome
  4. Macbook M1 Air running Monterey OS
    When I connect to my Mac Mini over smb and select say a text file or graphic in either Windows or on the Macbook I can view the file without having to download it first with no problems. In Manjaro if I try to do that I get Unexpected Error: broken pipe. Any ideas on a fix for this? Oh, and it seems to happen on any distro, not just Manjaro. Any ideas are very much appreciated. I want to be able to access my network files as if they are located on a local drive?

Check this

The broken pipe might be related to the way you connect as you might need the username and ip for the smb …
Example:
smb://user@192.168.1.1:139

thanks @bogdancovaciu as I usually just use smb://192.168.0.22 so I might do as you suggest and see if that makes a difference or not.

nope. Tried that and it doesn’t work :pensive:

In Xfce at least, there is a setting for the file manager to show previews always or only for local files and the default is only for local files.
There was even a setting some time ago where one could set a size limit up to which a preview would be done - it may have been in Gnome or in Xfce quite some time ago.

… some or even all of the data is needed to generate a preview and needs to be transferred over the network

Thanks @Nachlese I just tried it in arch with plasma and not a problem at all. Works the same as windows or mac. I haven’t tried it yet using kde manjaro. I’ll see if it works on that. I used archlinux-gui and it worked. Starting to think that it might just be in Nautilius?

Use the kernel CIFS module (via the terminal, or fstab, or systemd-mount, or Smb4K).

It’s much faster, more reliable, and you will use the files as if they were locally attached.

You can even set the “cache=loose” option if you’re the only one connecting to the share (single user, single connection) for even better performance.


The built-in “smb://” methods which use GVFS / KIO aren’t so great, and sadly it’s what most users rely on since it’s the “default” protocol for most file managers.

Thanks @winnie but how do I do that. Fairly new to this whole process. Strange, it works in kde plasma with no problems.

Is avahi running on the Manjaro-Gnome system.

I uninstalled gnome and now using kde. I would prefer gnome though.

I use the systemd-mount method (which automatically mounts / unmounts the share, seamlessly.)

I can share a template of what I use, and then let you change it for yourself and explore it further.


First you need to create two systemd units: one for the actual mount, and the other for the automount trigger.

Secondly, if you don’t want the password to be used in the systemd mount unit itself, you can create a hidden / restricted-access file that contains the credentials.

It’s easier to manage if you create a hidden directory named “.cifs” in your home folder, in which only your user has access to it. From here, you can create templates and use them to copy over the the actual system folder.

Replace all instances of “sharename” with the actual share’s name configured in your SMB server. (Do the same for mentions of “winnie” or the home folder location.)

mkdir ~/.cifs

Inside this folder, create a file named .cifs-sharename-credentials with the contents that look like so:

username=winnie
password=iLovePasta2022

Restrict it for only your user:

chmod 600 ~/.cifs/.cifs-sharename-credentials

Also in this folder, create two files. The names must follow this format. They instruct systemd where the mount paths exist. (Example: “mnt-cifs-sharename” tells it that the mount location will be /mnt/cifs/sharename)

File name mnt-cifs-sharename.mount with the contents:

[Unit]
Description=CIFS network mount for sharename
After=network-online.target
Wants=network-online.target

[Mount]
What=//192.168.0.22/sharename
Where=/mnt/cifs/sharename
Options=cache=loose,iocharset=utf8,rw,actimeo=60,x-systemd.automount,uid=1000,gid=1000,forceuid,forcegid,file_mode=0775,dir_mode=0775,credentials=/home/winnie/.cifs/.cifs-sharename-credentials
Type=cifs
TimeoutSec=10

[Install]
WantedBy=multi-user.target

File name mnt-cifs-sharename.automount with the contents:

[Unit]
Description=Automount for CIFS sharename

[Automount]
Where=/mnt/cifs/sharename
TimeoutIdleSec=120

[Install]
WantedBy=multi-user.target

Now copy those two files into /etc/systemd/system/ and reload the systemd daemon.

sudo cp -v ~/.cifs/mnt-cifs-sharename.mount /etc/systemd/system/
sudo cp -v ~/.cifs/mnt-cifs-sharename.automount /etc/systemd/system/
sudo systemctl daemon-reload

And enable only the automount unit:

sudo systemctl enable mnt-cifs-sharename.automount

Now when you browse to /mnt/cifs/sharename, it will automatically try to connect and mount it via the CIFS kernel module. After two minutes of inactivity, it will automatically unmount it.

To make things more streamlined, you can create a “Favorite” in your file manager that points directly to /mnt/cifs/sharename, and it will look like a local folder.


Look over every single option and contents. They will differ greatly on your setup. Everything must be consistent, or it will fail. I used “winnie” and “sharename” among other examples.


NOTE: Starting with kernel 5.17, you may need to include a third entry in your credentials file (“domain”) and set the domain to “workgroup” or whatever is configured in your SMB server, like so:

username=winnie
password=iLovePasta2022
domain=workgroup

wow. thanks heaps for this. So I would replace winnie with trevor and sharename with mac-mini?

Whatever matches your setup. That’s why this is more of a “template” to give you an idea.

I also advise against using “spaces” and special characters for share names, paths, and passwords. It makes life easier, and you don’t need to use any fancy “escape sequences” for systemd to parse it correctly.

The “dash” might cause issues for the mount path and file name. So use macmini in the references to the mount path and systemd unit file names. However, pointing to the network share, the “dash” should be fine.

For example:

What=//192.168.0.22/mac-mini
Where=/mnt/cifs/macmini

The files should be name accordingly, for example:
mnt-cifs-macmini.mount
mnt-cifs-macmini.automount

Thanks for the help @winnie and will reinstall gnome tomorrow and give it a shot. I really do appreciate the help you’ve given. I won’t worry about doing it on this setup (kde) as it’s working okay.

hi @winnie I get the following error >> sudo: systemd: command not found

You mean this line?

It’s a typo, it should read:
systemctl enable mnt-cifs-sharename.automount
and the sudo is (likely) not needed.

1 Like

yeah thats what I used.

That’s embarrassing. :flushed:

Correct. It should read systemctl.

sudo is needed, since it requires root privileges.

Nope. I done exactly as you said and still get the broken pipe message. I can access the shared drive okay but just can’t view anything on that drive without first downloading it. KDE works fine but not nautilius? Here is what I get: