Score:0

Fresh Ubuntu 21.10 installation - can't access a Windows 10 share

cn flag

I've got a fresh install of Ubuntu Desktop 21.10 and it can't access Windows Network and a Windows share. Other Windows PC can access the share.

When I click on the share, Ubuntu shows "Opening [share name] SMB" indefinitely. After a few minutes there's a time out error. And that's it.

I disabled the firewall and installed Samba. It didn't help. What can I do?

in flag
Samba would not be a solution as that allows you to share files from Ubuntu. One of the more common problems that I see with this sort of setup is that Windows is using a specific version of the SMB protocol, not broadcasting that version, and Ubuntu guesses wrong. Have you tried mounting the Windows share manually via Terminal with `mount`?
daerragh avatar
cn flag
Thanks for the asnwer. How do I do that? The Windwos share is on a PC called ASUS-VIVOPC and it's called Pliki.
Score:3
in flag

Windows 10 uses the SMB 2.1 protocol by default, but does not broadcast this to machines that might want to connect. As a result, connecting from Linux or FreeBSD-based machines can fail. That said, you can specify which SMB protocol to use if you are mounting the network share via Terminal.

Here's an example of how:

sudo mount -t cifs //192.168.1.1/public /home/daerragh/Share --verbose -o vers=2.1,user=daerragh

Notes:

  • be sure to replace 192.168.1.1 with the IP address of your Windows machine
  • be sure to replace public with the actual share name
  • be sure to replace /home/daerragh/Share with the location where you would like to mount the network share. Ideally, this will be a new (or empty) directory in you /home directory.
  • be sure to replace daerragh with the username you use on Windows
  • if you are prompted for a password by the Windows machine, you can define it as part of your mount command by adding ,password={password} after the username value in your mount statement. Of course, be sure to replace {password} with the actual password.

This probably looks complicated but, when you step through it, it's not too crazy. You're simply connecting to a network share with credentials and setting a location in your /home directory to act as a proxy for that network location


Assuming everything works, if you would like this share to mount at boot, you can do this:

  1. Open Terminal (if it's not already open)
  2. Edit the /etc/fstab file with sudo:
    sudo {editor of choice} /etc/fstab
    
    Note: Be sure to replace {editor of choice} with your editor of choice.
  3. Add the following line to the end:
    //192.168.1.1/public      /home/daerragh/Share cifs vers=2.1    0    0
    
    Note: As above, be sure to replace various values with those that work for your network and installation.
  4. Save the file

Now, when you (re)boot, the network share will mount. One word of warning, though: if you are doing this on a notebook that is not always booting at home, you can receive an error during boot because this share cannot be found. Generally what I do on mobile computers is add the mount command to .bash_aliases, as this allows me to mount the share manually when/if I need it. In the event I'm at the office or away at a conference (haha ) then the system will not hang for 300+ seconds during boot.

daerragh avatar
cn flag
Thanks fo the detailed answer. I will try it in a moment but I've got a question. What do I do when the share doesn't need a username and password? What would the command look like?
in flag
If you do not need to define any credentials, simply leave out the `username` and `password` values. You'll only need `-o vers=2.1`
daerragh avatar
cn flag
OK. I use the command "sudo mount -t cifs //192.168.1.40/Pliki /home/x/Pliki --verbose -o vers=2.1" and I get an error: "mount: /home/x/Pliki: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program."
in flag
You may need: `sudo apt install cifs-utils`. I sometimes forget about these little details in the answer ...
daerragh avatar
cn flag
Thank you. It is working. :) Another question. How to unmount the share? Also, I wonder if would work in GUI from the start if I had just installed cifs-utils?
in flag
To unmount, you can use the `umount` command. It would look like this: `sudo umount /home/daerragh/Share` ... assuming you mounted the share to that location. The GUI *may* have worked if `cifs-utils` was installed first, but I cannot answer this as Windows tends to be a very opinionated OS that reveals little. You can certainly give it a try, though
daerragh avatar
cn flag
Also, how do I make it stick at reboot? EDIT: It doesnt work in GUI after installation of cifs-utils. How to make it work in GUI? I guess I'd need to force Ubuntu to use SMB 2.1, but how?
in flag
I've updated the question to show that at the end of the answer along with a caveat
daerragh avatar
cn flag
I've got a problem with your solution. I can read but cannot write. I'm just learning linux and reading man pages is kind of hard. What would the mount command look like to allow writing?
Score:3
es flag

I have a slight variation you might be interested in.

The samba client which the file manager uses to browse then connect to SMB servers will negotiate with the server to determine the best smb dialect to use between 2.1 and 3.X automatically. But a bug in the gvfs backend stops this process by forcing the connection to SMB1.

You can bypass this bug 2 ways:

Ask for the server and share by using Connect to Server in the file manager using one of these formats:

smb://asus-vivopc.local/pliki 
smb://192.168.X.X/pliki 
smb://asus-vivopc/pliki

You will connect with SMB3.

You can then bookmark that for future use.

You can connect with a cifs mount which doesn't use the samba client or gvfs at all.

If you already have something defined in fstab and the mount point is in your home directory and you want the ability to mount and unmount on demand I would

Unmount the share: sudo umount /home/daerragh/Share

Change the line in fstab to something like this:

//asus-vivopc.local/pliki /home/daerragh/Share cifs uid=daerragh,noauto,user 0 0

Then make systemd happy:

sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target

Note: I purposely did not add a vers=xxx option since cifs determines the best version to use on it's own between 2.1 and 3.X. The way it is written above it will connect to Win10 using SMB3.X

Note2: It's customary when accessing a share that allows guest access to supply the "guest" option in fstab:

//asus-vivopc.local/pliki /home/daerragh/Share cifs guest,uid=daerragh,noauto,user 0 0

But if it works without it that's fine.

noauto == prevents the share from mounting at boot

user == allows an ordinary user ( not sudo ) the ability to mount the share.

uid=daerragh == will make you the owner of the mount so you can write to it.

Because the mount point is in your home directory it will create an icon on the side panel of your file manager labeled "Share" - in this case - that is "actionable".

Click on it and it will go to fstab to find out how to mount it. THe same icon can be used to unmount it when no longer required.

You can also use a systemd automount feature which is slightly more complicated and you have to change the mount point location.

daerragh avatar
cn flag
Thanks for the answer. I'm stuck at "smb://192.168.1.40/Pliki", it asks for authentication but the share doesn't need any password and Windows clients can read/write without a problem. I choose anonymouse user but it wants to authenticate again and again. What can I do?
Morbius1 avatar
es flag
For username you can add anything like guest or your own user name. For the password you can add spaces or even xxx. Not used to accessing a Windows machine without supplying a user and password. See if that works.
daerragh avatar
cn flag
I forgot to unmount the share I had mounted using the terminal. After PC restart it works when providing any username and password. Thanks :) But I have to ask, is there any way to make it work like it should've from the start, I mean I should be able to click on ASUS-VIVOPC in Nautilus and tadam, it should work :)
Morbius1 avatar
es flag
The problem here is what to do with SMB1. Win10 turns it off simply because there are too many security issues with such an old smb protocol. In turn samba and cifs in the Linux kernel have turned it off for the same reason. All of these can be turned back on but the user is exposed to greater risk.
daerragh avatar
cn flag
I can't edit anymore, I meant:"I forgot to unmount the share I had mounted using the terminal. After PC restart it works when providing any username and password. Thanks :)" -> "I forgot to unmount the share I had mounted using the terminal. After PC restart the way in GUI you wrote about works when providing any username and password and I CAN write to the share. Thanks :)"
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.