
In this article, we will delve into the issue of mounting SMB shares in fstab on Ubuntu 20.04. This issue is often encountered after upgrading the file server to Ubuntu 20.04, and we’ll explore possible solutions and troubleshooting steps.
To fix SMB share mounting issues in fstab on Ubuntu 20.04, you can specify the correct SMB version in the fstab entry by adding vers=3.0
. If that doesn’t resolve the issue, you can enable debug output using the dmesg
command to troubleshoot further.
Understanding the Issue
When you upgrade to Ubuntu 20.04, you might face difficulties with mounting SMB shares in fstab on your Ubuntu 20.04 computer. While the shares can be mounted successfully using the command line, they might not mount as expected when specified in fstab.
This issue might be due to the removal of SMB1 support in newer versions of Ubuntu for security reasons. If this is the case, you could try enabling SMB1 support in the smb.conf
file on the file server. However, this is generally not recommended due to the security vulnerabilities associated with SMB1.
Specifying the Correct SMB Version
One potential solution to this issue is to ensure that the correct version of SMB is specified in the fstab entry. For instance, specifying vers=3.0
in the fstab entry should force the client to connect using SMB 3 instead of SMB 1.
Here’s an example of how you can specify the SMB version in the fstab entry:
//server/share /mnt/share cifs credentials=/etc/samba/creds,vers=3.0 0 0
In this command, //server/share
is the SMB share you want to mount, /mnt/share
is the mount point on your local system, and credentials=/etc/samba/creds
specifies the location of the file containing your SMB username and password. The vers=3.0
option forces the client to connect using SMB 3.
Debugging the Issue
If specifying the SMB version doesn’t resolve the issue, you can troubleshoot further by checking the debug output using the dmesg
command. Running dmesg -t | grep -e CIFS
will show any CIFS errors that might be occurring.
You can enable debug of the cifs module for more detailed information. Run the following commands:
modprobe cifs
echo 'module cifs +p' > /sys/kernel/debug/dynamic_debug/control
echo 'file fs/cifs/* +p' > /sys/kernel/debug/dynamic_debug/control
echo 7 > /proc/fs/cifs/cifsFYI
In these commands, modprobe cifs
loads the cifs module, and the echo
commands enable debugging for the cifs module and all files in the fs/cifs directory. The echo 7 > /proc/fs/cifs/cifsFYI
command sets the debug level to 7, which is the highest level and provides the most detailed output.
After enabling debug, try mounting the SMB share again and check the debug output in dmesg
. This might provide more insights into the issue.
To disable the debug output, use the following command:
echo 0 > /proc/fs/cifs/cifsFYI
This command sets the debug level to 0, effectively disabling debug output.
Conclusion
In conclusion, fixing SMB share mounting issues in fstab on Ubuntu 20.04 involves ensuring that the correct SMB version is specified in the fstab entry and checking the debug output for any specific errors or issues. Remember, this guide assumes that network connectivity and permissions are properly set up and the SMB shares are accessible from the Ubuntu computer. If you’re still facing issues, it might be worth seeking professional help or consulting the Ubuntu community forums for further assistance.
You can check the version of Ubuntu you are using by opening a terminal and running the command lsb_release -a
. This will display detailed information about your Ubuntu version.
To edit the smb.conf
file, you can use a text editor like nano
or vim
. Open a terminal and run the command sudo nano /etc/samba/smb.conf
to open the file in the nano
editor with root privileges. Make the necessary changes and save the file by pressing Ctrl + X
, then Y
, and finally Enter
.
You can check if a specific SMB share is accessible from your Ubuntu computer by running the command smbclient -L //server/share -U username
. Replace //server/share
with the actual SMB share path and username
with a valid username for that share. If you can see a list of available shares and are prompted for a password, it means the share is accessible.
To specify a username and password for the SMB share in fstab, you can create a credentials file. Create a file (e.g., smb-creds
) in a secure location and add the following lines:
username=<your_username>
password=<your_password>
Replace <your_username>
and <your_password>
with your SMB username and password. Set the permissions of the file to restrict access by running sudo chmod 600 /path/to/smb-creds
. Then, in the fstab entry, use credentials=/path/to/smb-creds
to specify the location of the credentials file.
Yes, you can use a different mount point instead of /mnt/share
. When specifying the mount point in the fstab entry, replace /mnt/share
with the desired path for your mount point. Ensure that the directory exists and has proper permissions before attempting to mount the SMB share.