Software & AppsOperating SystemLinux

How To Fix “mount.cifs: bad UNC” Error When Mounting Remote Drive in Ubuntu

Ubuntu 18

In this article, we will delve into the details of how to fix the “mount.cifs: bad UNC” error when mounting a remote drive in Ubuntu. This error typically occurs due to incorrect usage of the Universal Naming Convention (UNC) syntax. We will walk you through the steps to correct this issue and successfully mount your remote drive.

Quick Answer

To fix the "mount.cifs: bad UNC" error when mounting a remote drive in Ubuntu, you need to correct the UNC syntax in your fstab entry, ensure the server name is resolvable, and use the correct mounting command with the appropriate options.

Understanding the “mount.cifs: bad UNC” Error

Before we dive into the solution, it’s important to understand what the error means. The “mount.cifs: bad UNC” error message is usually a result of incorrect UNC syntax. The correct UNC syntax is //server/share. This means you should have double slashes before the server name and a single slash between the server name and the share name.

Steps to Fix the Error

1. Correct the UNC Syntax

The first step is to correct the UNC syntax in your fstab entry. The fstab file, located in /etc/fstab, is used to define how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem.

For instance, if your current entry looks like this: /servername//data.xxx.xxx.ac.uk/, you need to correct it to: //servername/data.xxx.xxx.ac.uk/.

2. Resolve the Server Name

Next, ensure that the server name is resolvable. This means that your system should be able to translate the server name into an IP address. You can check this by using the host command followed by the server name. For example, host servername. If the server name is resolvable, the command will return the corresponding IP address.

3. Use the Correct Mounting Command

Finally, instead of manually running sudo mount -a, use the mount command with the appropriate options. Here is an example:

sudo mount -t cifs //servername/data.xxx.xxx.ac.uk/ /media/windowsshare -o user=myuserid,password=mypassword,iocharset=utf8,sec=ntlm

Let’s break down this command:

  • mount is the command to mount filesystems.
  • -t cifs specifies the type of the filesystem. CIFS stands for Common Internet File System, a protocol that allows sharing of files and printers with Microsoft Windows systems.
  • //servername/data.xxx.xxx.ac.uk/ is the UNC path to the remote share.
  • /media/windowsshare is the local directory where the remote filesystem will be mounted.
  • -o is used to specify several comma-separated options. In this case, we have:
    • user=myuserid,password=mypassword: Replace myuserid and mypassword with your actual credentials.
    • iocharset=utf8: This option specifies the character set to use for file names.
    • sec=ntlm: This option specifies the security mode. NTLM is a Microsoft authentication protocol.

Conclusion

Fixing the “mount.cifs: bad UNC” error when mounting a remote drive in Ubuntu is a straightforward process once you understand the UNC syntax and the correct mounting command. By following the steps outlined in this article, you should be able to successfully mount your remote drive and avoid this error in the future.

What is the purpose of the `fstab` file in Ubuntu?

The fstab file is used to define how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem.

How can I correct the UNC syntax in the `fstab` entry?

To correct the UNC syntax, you need to ensure that you have double slashes before the server name and a single slash between the server name and the share name. For example, change /servername//data.xxx.xxx.ac.uk/ to //servername/data.xxx.xxx.ac.uk/.

How can I check if the server name is resolvable?

You can check if the server name is resolvable by using the host command followed by the server name. For example, host servername. If the server name is resolvable, the command will return the corresponding IP address.

What is the `mount` command used for in Ubuntu?

The mount command is used to mount filesystems, including remote filesystems. It allows you to access and use files stored on external drives or network shares.

What does the `-t cifs` option in the `mount` command specify?

The -t cifs option specifies the type of the filesystem to be mounted. In this case, it indicates that the filesystem is a Common Internet File System (CIFS), which is used for sharing files and printers with Microsoft Windows systems.

What does the `-o` option in the `mount` command do?

The -o option is used to specify several comma-separated options for the mount command. It allows you to provide additional parameters such as the user credentials, character set, and security mode for the mount operation.

How can I specify my user credentials when using the `mount` command?

You can specify your user credentials using the user=myuserid,password=mypassword option in the -o parameter of the mount command. Replace myuserid and mypassword with your actual credentials.

What is the purpose of the `iocharset=utf8` option in the `mount` command?

The iocharset=utf8 option specifies the character set to use for file names. In this case, it sets the character set to UTF-8, which is a widely supported character encoding that can handle a wide range of characters and symbols.

What is the purpose of the `sec=ntlm` option in the `mount` command?

The sec=ntlm option specifies the security mode to use for the mount operation. NTLM is a Microsoft authentication protocol that is commonly used for accessing Windows-based network shares.

Will following these steps fix the “mount.cifs: bad UNC” error permanently?

Following these steps should fix the error and allow you to successfully mount your remote drive. However, if the error persists, there may be other underlying issues that need to be addressed.

Leave a Comment

Your email address will not be published. Required fields are marked *