Network Profiles - home with SMB mounts / public without

I tried searching before posting, but this has never been a situation I have needed so I am not sure I am using the proper terms.

I normally work from home and never take my laptop outside of my home network. Today I am on a public hotspot and discovered that my Dolphin file manager is completely unresponsive for long periods of time. Then it dawned on my that it is trying to access my mounted SMB shares at home. (I have these mounts established via fstab) Obviously this is never going to happen, but I don’t know how to tell Dolphin to stop looking.

Is there a network connection setting or a way to set up a profile that will tell all applications that shares on my home network are not available?

Use SystemD automounts.

1 Like

Why don’t you disable the mounts in fstab then, when you’re not home? Maybe also adding options to your mounts can solve the issue (I guess a nofail option, noauto, and/or other options, see fstab documentation)?

Maybe share your fstab to see how it is and how it can be changed.

1 Like

Two excellent replies! @winnie - 'm reading the SystemD automounts article now, but that doesn’t sound like a 2 star easy solution. Or more likely I am just dense. However this does sound like what I want.

@omano - this definitely sounds like the easiest route. I can’t believe I didn’t think of that before posting a question. Here is an excerpt of my fstab:

#Network Mounts

#Synology (MemoryBeta)
//192.168.1.15/Main_Share/homes/        /home/paul/Shared/Backup    cifs x-systemd.automount,nofail,domain=WORKGROUP,username=****,password=****,uid=****,gid=users,file_mode=0777,dir_mode=0777 0  0
//192.168.1.15/Main_Share/Documents/    /home/paul/Shared/Documents cifs x-systemd.automount,nofail,domain=WORKGROUP,username=****,password=****,uid=****,gid=users,file_mode=0777,dir_mode=0777 0  0
//192.168.1.15/Main_Share/Music/        /home/paul/Shared/Music     cifs x-systemd.automount,nofail,domain=WORKGROUP,username=****,password=****,uid=****,gid=users,file_mode=0777,dir_mode=0777 0  0
//192.168.1.15/Main_Share/Photo/        /home/paul/Shared/Pictures  cifs x-systemd.automount,nofail,domain=WORKGROUP,username=****,password=****,uid=****,gid=users,file_mode=0777,dir_mode=0777 0  0

#QNAP (Blockbuster)
//192.168.1.10/Public/Videos/           /home/paul/Shared/Video     cifs x-systemd.automount,nofail,domain=WORKGROUP,username=****,password=****,uid=****,gid=users,file_mode=0777,dir_mode=0777 0  0
//192.168.1.10/Public/TV/               /home/paul/Shared/TV        cifs x-systemd.automount,nofail,domain=WORKGROUP,username=****,password=****,uid=****,gid=users,file_mode=0777,dir_mode=0777 0  0

I honestly don’t remember how I came up with those fstab config lines. I probably just copied/pasted and changed paths from a forum post.

I’ve got some reading to do, thank you both for chiming in on this post!

Since you’re using KDE, you can also look into Smb4K.

It has a user-friendly GUI where you can easily mount/unmount SMB shares. (It’s made for KDE.)

The package name is smb4k

There are a good handful of settings to customize its use. (Some things I wouldn’t just glance over, as they are pretty important.)

To assist you in converting your fstab entries above into proper .mount and .automount systemd-units, you could use the following while at home before removing those entries from your fstab:

  1. Save the below file in your home directory under anyname
    fe. as ~/convert_fstab_entries
  2. Give it execute permissions:
    chmod a+x ~/convert_fstab_entries
  3. Run it like ~/convert_fstab_entries

#!/usr/bin/env bash
# By: TriMoon
#
dest=~/converted_fstab_entries
myshares=(
	# System default ones, just as examples
	/
	/boot/efi
	# Your personal shares
	~/Shared/Backup
	~/Shared/Documents
	~/Shared/Music
	~/Shared/Pictures
	~/Shared/Video
	~/Shared/TV
	# My share for test
	#/media/SteamGames_Backups
)

# Start clean
rm -rf "$dest"
mkdir "$dest"
for entry in "${myshares[@]}"; do
	# convert path-name to unit-name
	unit_name="$(systemd-escape --path "$entry")"
	for unit_type in {,auto}mount; do
		# Check if unit exists before converting it.
		# We use -- on purpose here...
		if systemctl --quiet list-unit-files -- "$unit_name.$unit_type" >/dev/null; then
			# Convert it and place in dest without first line.
			systemctl cat -- "$unit_name.$unit_type" \
				| tail --lines=+2 \
 				>"$dest/$unit_name.$unit_type"
			# Remove the 'Where=' option because that is already encoded in the unit-name.
			# Makes it easy to move the mount-point by just renaming the unit without any modifications.
			sed -i '/^Where=.*/ d' "$dest/$unit_name.$unit_type"
		fi
	done
done

echo "Converted entries are in: $dest"
ls -l "$dest"

:information_source:Take note that they won’t be automatically activated at boot in the form they are converted, you need to add a proper [Install] section in the unit(s) you want to be able to enable at boot-time.

  • fe. in the .automount files you could use:
    [Install]
    WantedBy=graphical.target
    
    :warning: When you have automount units, you should only add this section to the *.automount units and not to the normal *.mount units !

After making needed changes inside the generated files, you should copy/move them into /etc/systemd/system.

Only after such an section exists, and they are in proper location, you are able to issue systemctl enable --now followed by the unitname.automount :wink:

Hope this helps you in some way :vulcan_salute:

I leave it to another topic to discuss ways to automatically enable them when you are at home but disable them when not :wink:
(This kind of functionality is only available using systemd-units :stuck_out_tongue_winking_eye: )

2 Likes

I hate networking so much. Every time I start tinkering with it, I feel as though I am beating my head against a wall. smb4k finds the servers but cannot show me any of the shares. I lowered the SMB version to 1, but that made no difference. I am beginning to wonder if KDE is really worth all of the hassle. Been using it for years, but I just want to get my damned work done and it keeps getting in my way.

Of course, I can just comment out the fstab lines and reboot. Quick, simple, and easy to undo.

Sorry for the rant, I’m just frustrated.

You need to add the shares in Smb4K.

(Make bookmarks of them for quick access.)

Don’t rely on “browsing” a server. Long gone are the days of convenient browsing. And don’t enable SMB1, for reasons of security, performance, and features.

That’s just it, it won’t let me do that. The paths I am using and the credentials are correct and I keep getting errors.
smb4k_error01

smb4k_error02

Obviously those paths are valid as they work fine in fstab.

For real! Heaven forbid this stuff stuff be able to work easily and conveniently. I mean, we are still in computing and networking infancy!

That’s not the correct format. :sweat_smile:

Leave IP address blank and Workgroup blank. (It’s automatically understood whether you use a hostname or IP address in the “Location” field.)

You should fill it out like this, using the complete path (server/sharename) in the “Location” field.

This example assumes the full path is 192.168.1.10/Public/TV

“192.168.1.10” is the server’s address, and “Public” is the share name. “TV” is a folder within the share’s root.

smb4k


Don’t use the “Network Neighborhood” tab. (In fact, just hide it.)

Settings → Dock Widgets → uncheck it


There’s a good number of preferences to make Smb4k behave how you want it to some degree. I would recommend going through its settings.

Keep in mind there are still quirky Qt-/KDE-related aesthetic bugs for the tray icon. For the most part, just use the main application window itself.

2 Likes

Well that is just stupid! If there is a field for that, naturally a user would assume to put that info into there.

I went back up to @TriMoon 's post and so far it is working perfectly. I was a little uncomfortable with it since I am old and don’t learn as well as I used to. But I’m not getting any error messages and I am browsing my network shares without issue. I’ll be heading back to the public hotspot, so I will be able to report back on how it handles that situation.

Thank you all for chiming in, it really was helpful and I am betting that many other people might find this thread useful!

It should be the same, because all we did so far is converting the fstab entries into systemd versions…
You need to create specialized logic for them to be activated/deactivated when at home or public WiFi’s…

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.