A Windows share can be mounted on a particular mount point on Ubuntu Linux using the cifs option when using the mount command. One can use the mount command to mount shares at a particular mount point identified on a Linux directory. When mounting a Windows share, a suitable protocol to use is the Common Internet File System (CIFS) is a network file-sharing protocol. It’s part of the SMB protocol that allows file and printer sharing on Windows systems. Below, we’ll show you how to configure a Windows 11 machine to allow file sharing to allow Ubuntu to mount Windows shares. To get started with mounting Windows shares on Ubuntu Linux, follow the steps below.
Enable Network Discovery in Windows 11
As we mentions above, shares must be advertised for other devices to view or access them. In Windows, Network Discovery needs to be turned for advertising of shares to be viewed from other devices. If your Windows devices are not able to see or discover each other on your private network, it might likely be that Network Discovery is disabled. To enable Network Discovery, continue below. Windows 11 has a centralized location for the majority of its settings. From system configurations to creating new users and updating Windows, all can be done from its System Settings pane. To get to System Settings, you can use the Windows key + I shortcut or click on Start ==> Settings as shown in the image below: Alternatively, you can use the search box on the taskbar and search for Settings. Then select to open it. Windows Settings pane should look similar to the image below. In Windows Settings, click Network & internet, then select Ethernet on the right pane of your screen shown in the image below. In the Ethernet settings pane, under Network profile type, choose Private. This profile will allow devices in your network to be discovered. This profile should also be selected if you need file sharing or use apps that communicate over this network. The private profile is suitable for homes, workplaces, and networks that are trusted. If you have other networks like Wi-Fi (if you’re connected to a wireless network) or Ethernet (if you’re connected to a network using a network cable), you can also set the profile type to Private. When you’re done, exit and network discovery should be enabled.
Turn on Public Folder Sharing in Windows 11
Use the steps below to set up file sharing. Windows 11 has a centralized location for the majority of its settings. From system configurations to creating new users and updating Windows, all can be done from its System Settings pane. However, changing the account username is still done in the old Control Panel. To get to Control Panel, you can click on Start and start typing Control Panel as shown in the image below: In the Control Panel, select Network and Internet as highlighted in the image below. On the next pane, select Network and Sharing Center as highlighted below. Next, select Change advanced sharing settings as highlighted below. In the Advanced sharing center, select Private (current profile) and Turn on file and printer sharing. Save your changes and exit. On the same Advance sharing options page, scroll down All networks. There you should see settings for Public folder sharing, Media streaming, File sharing connections, and Password protected sharing. Windows should automatically turn on file and printer sharing in private networks. However, in some instances, this will not be enabled. If you can not automatically find printers and shared resources in your private network, then the File sharing option may be disabled. If you enable password-protected sharing, only people who have accounts on the local computer or in the domain environment will be able to access shared files and printers. Make your changes and save, then exit. The settings above can easily be done using the commands below when run as administrator. You must open the command prompt as administrator to run the commands above.
How to create Windows shares
You cannot mount a Windows share if you don’t share a folder or directory. To learn how to create a share on Windows, read the post below. You’ll need to complete the steps in the post below to create a share before mounting it on Ubuntu Linux. How to create Windows 11 shares Now that you have created a share on Windows, continue below to mount it on Ubuntu Linux.
How to mount Windows shares on Ubuntu Linux
Now that Network Discovery and file sharing are enabled, you can now log onto Ubuntu Linux and begin mounting Windows shares To mount a Windows share on Ubuntu Linux, first, you need to install the CIFS utility package. The commands below will install it. After running the commands above, you can begin mounting shares using the mount commands with the cifs file system. Mounting a remote Windows share is similar to mounting regular file systems. A simple mount command below will mount a Windows share to the /mnt/Windows_Share directory on Ubuntu Linux. Make sure that the directory or folder already exists on Ubuntu Linux. The commands above are detailed below:
mount -t cifs = file system type (protocol) username = username of Windows account //WindowsPC_IP/ShareName = the Windows PC share name /mnt/Windows_Share = the mount point on Ubuntu
For example, if my Window username is richard, I’d run the commands below: When you run the commands above, it should prompt you for your Windows account password to mount the share. Once the share is mounted, the mount point becomes the root directory of the mounted file system. You can work with the remote files as if they were local files. If you want to include the password with the mount command, simply add the password filed option as below: By default, the mounted share is owned by the root, and the permissions are set to 777. If you want to set custom permissions, you can use dir_mode option to set the directory permission and file_mode to set the file permission. An example format would be: For security reasons, it’s recommended to use a file for account credentials so it’s not exposed to the mount commands. You can create a file and type in the username, password, and domain details, then reference the file with the mount command. The format of the credentials should be entered as below: Then protect the file using the commands below if the file is located at /etc/credentials. You can then use the mount commands below with options for credentials as shown:
How to auto-mount Windows shares on Ubuntu
If you don’t want to always type the mount commands to mount Windows shares, you can utilize the/etc/fstab file to automatically mount the shares. The file contains a list of entries that define where and how the filesystem will be mounted on system startup. Run the commands below to open the file: Then enter the mount commands at the bottom of the file and save. Now every time Ubuntu Linux starts up, the share should automatically. If you want to unmount, run the commands below to disconnect the mounted share. That should do it! Conclusion: This post showed you how to mount Windows shares on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.