Fresh Ubuntu 21.10 installation - can't access a Windows 10 share
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?
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 theusername
value in yourmount
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:
- Open Terminal (if it's not already open)
- Edit the
/etc/fstab
file withsudo
:
Note: Be sure to replacesudo {editor of choice} /etc/fstab
{editor of choice}
with your editor of choice. - Add the following line to the end:
Note: As above, be sure to replace various values with those that work for your network and installation.//192.168.1.1/public /home/daerragh/Share cifs vers=2.1 0 0
- 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.
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.