Does anyone here regularly access Windows fileshares on Linux?

mikeymikec

Lifer
May 19, 2011
17,721
9,607
136
I don't have anywhere near as much Linux experience as I do for Windows, but I've had some exposure to some recent distros, and I just want to know what peoples' experiences are.

Rule of thumb #1 seems to be never to try and browse your way to the correct fileshare, just find out what the file share is and attempt to access it directly (either mounting through a terminal or through the file manager, ie. nemo on Linux Mint's address bar syntax seems to be smb://computername.local/sharename).

Rule of thumb #2 seems to be in general with Linux that if you want regular access to almost any storage volume and you want it to 'just work' then you always perma-mount it (e.g. through fstab).

I can't remember whether I had to install samba on Linux Mint 21 or if it came with it.
 

manly

Lifer
Jan 25, 2000
11,031
2,152
126
I don't think Samba is actually required for client access from CLI or GUI. The kernel supports CIFS mounting:

And the desktop environment's file manager doesn't use Samba, although I could be wrong about that.

I have no problem with browsing, but technically I connect only to Samba shares (on a Synology DSM server).

I do connect to an old HP laser printer that hangs off a Windows XP PC, and this doesn't work as cleanly as it should. Thankfully, I rarely ever print (just a few times a year). It used to work just fine, but sometime around upgrading to Ubuntu 20.04, authentication seems to have changed. Despite numerous attempts to cajole CUPS/Samba into cooperating, I've never been able to fix the issue. My printer is an anonymous share, so any guest on the workgroup could print to it. However, after upgrading my OS a couple years ago it seems like authentication is strictly enforced now. So if I print to the shared printer, a dialog box appears and I have to hit the Enter key to submit a blank password. But at least it works; IIRC cajoling Windows 10 into printing to legacy WinXP-shared printers is even more ridiculously difficult.

Before switching to Linux full-time in 2017, I used Mac OS X. IMO the UX for accessing SMB shares on macOS and modern Linux is pretty comparable.
 

mikeymikec

Lifer
May 19, 2011
17,721
9,607
136
Cool, I get to remove samba :) It had irked me that my Linux install was broadcasting my printers on the network!
 

Fallen Kell

Diamond Member
Oct 9, 1999
6,039
431
126
Rule of thumb #2 seems to be in general with Linux that if you want regular access to almost any storage volume and you want it to 'just work' then you always perma-mount it (e.g. through fstab).
I know this is from a month ago now, but I wanted to clear up this misconception. In reality, for any kind of regular access to "remote" storage, you NEVER want to put it in the fstab. Placing the entry in the fstab will mean that the local system will not boot and will hang unless that remote storage is up and available, a situation you almost never want to be in.

What you do want to do for that remote storage is setup the automounter to mount it on-demand when you want to access it. You may also find that you want to even access local storage through the automounter as well (very common for CD/DVD drives to already have an entry in certain distros), and for ease of creating consistent paths to applications and data across multiple computers (i.e., use the automounter to create a "/sw" where you have your software accessible, even though you might physically have it shared over the network, or under some path within a home directory or some bulk data drive, having it mapped within an automount map you can access it with just a simple "/sw/gcc-13.2.0", or "/sw/gcc-latest").

You can either create your own entire automount map (usually the best method), use a pre-defined one that might exist on your distro, or use the auto.direct map (not the recommended method, but in some situations, it can be the only way to do what you want). It is very simple once you understand you can do this and the power and ease of use that it can provide to you, especially in a multi-computer environment. I would highly recommend reading "man auto.master", and then read some quick tutorials online.
 
  • Like
Reactions: igor_kavinski

mikeymikec

Lifer
May 19, 2011
17,721
9,607
136
@Fallen Kell I planned to use automount-type stuff as the first resort, but the customer was running some Ubuntu Pro distro and a lot of the file manager functionality seemed not to work properly at all (network browsing seemed fairly broken, password management too), so I had to pursue more creative solutions.

The solution I ended up on (IIRC) was a script and a desktop launcher that fired up the connection and asked the user for their password.
 

mikeymikec

Lifer
May 19, 2011
17,721
9,607
136
Would you like to share?

It was just a standard mount command, I didn't make a note of exactly what I used for the customer and my memory of the situation (late 2022) is a bit vague. I think getting it to prompt for the password was just a case of leaving the password bit out of this command:
Code:
sudo mount -t cifs "//MIKE-LP.local/sharename" /mnt/mikelp/sharename -o "user=owner,password=password,workgroup=WORKGROUP",dir_mode=0777,file_mode=0666
 
  • Like
Reactions: igor_kavinski