How to mount windows to linux

Introduction

A Windows share is a folder on a Windows machine that can be accessed by other machines within a network. The contents can be modified or retrieved by authorized users on other machines connected to the same network.

On the other hand, CIFS (Common Internet File System) is a network file-sharing protocol that allows different operating systems, including Linux, to access files and services on Windows and vice versa.

In this tutorial, you will learn to mount a Windows share on a Linux machine using CIFS.

How to mount Windows Share on Linux using CIFS - a tutorial.

Prerequisites

  • A system running Linux.
  • Root or sudo access.
  • A shared folder or drive on a Windows machine.

Mounting a remote Windows share via CIFS is similar to mounting regular file systems. Follow the steps below to mount a CIFS share on Linux.

Step 1: Install CIFS Utilities Packages on Linux

The CIFS-Utils package provides the necessary utilities for mounting SMB/CIFS shares on a Linux system. The installation steps differ depending on which Linux distribution you are using.

For Debian-based systems:

First, update the local package repository to ensure the latest available package gets installed:

sudo apt update

Run the following command to install the CIFS-Utils package:

sudo apt install cifs-utils -y

For RHEL-based systems:

First, update the system repository:

yum update

Next, install the CIFS-Utils package by running the following command:

yum install cifs-utils

For Fedora:

Run the following command to update the package repository:

sudo dnf update

Install CIFS-Utils by running:

sudo dnf install cifs-utils

After the package installs, move on to the next section to create a mount point for the Windows share.

Step 2: Create a Directory to Mount Windows Share

To mount the Windows Share, create a directory on the Linux machine to act as a mount point for Windows Share. You can create this directory anywhere you want.

For this tutorial, we’ll create a directory named winshare in the /mnt directory:

sudo mkdir /mnt/winshare

Step 3: Mount a CIFS Windows Share

After creating a directory, mount the Windows share. Use the following syntax:

sudo mount -t cifs //[IP_Address]/[share_name] /mnt/winshare -o username=[username]

Replace the [IP_Address], [share_name], and [username] with your details.

When prompted, enter your password and hit Enter.

Mounting a Windows share on Linux using CIFS.

After running the command and mounting the share, you should be able to access it from the /mnt/winshare directory on your Linux machine. Use the cd command to move to that directory and list the contents using ls:

Listing the contents of a directory in Ubuntu.

If you don’t have access to the share, check if it is mounted correctly by running:

df -h
Checking which filesystems are mounted in Ubuntu.

If the share is correctly mounted, the output shows an entry for the remote Windows share and its mounted location on your Linux system.

Step 4: Make the Windows Share Automatically Mount at Boot

Make the Windows share mount automatically at boot to avoid mounting it after each system reboot. To do so, edit the /etc/fstab file using a Linux text editor. In this tutorial, we will use nano.

Follow the steps below:

1. Store your login credentials in a separate file for security reasons. Use this command to create a new file:

sudo nano /etc/cifs-credentials

2. Add your username and password to the file using the following format:

username=[username]
password=[password]

Replace [username] and [password] with your credentials.

For example:

Creating CIFS credentials.

Save and close the file.

3. Change the file permissions to prevent unauthorized changes or access:

sudo chmod 600 /etc/cifs-credentials

4. Open the /etc/fstab file:

sudo nano /etc/fstab

5. Add the following line at the end of the file:

//[IP_address]/[share_name] /mnt/winshare cifs credentials=/etc/cifs-credentials 0 0

Replace [IP_address] and [share_name] with your information.

Save and close the file. Your Windows share will now automatically mount when the system boots.

How to Unmount CIFS Windows Share

Unmount the Windows share from your Linux machine with the umount command:

sudo umount /mnt/winshare

The command unmounts the Windows share from the /mnt/winshare directory. If you used a different directory as the mount point during setup, specify that directory in the command.

If errors arise when unmounting the share, it may be because a user is currently accessing the share or a file is open.

Force unmount the share by running the following command:

sudo umount -f /mnt/winshare

The -f (--force) flag force unmounts the share from your system.

Conclusion

This guide showed how to mount a Windows share on a Linux machine using CIFS and how to unmount it. The CIFS Windows is handy when you need to access files on a Windows machine using Linux.

Next, see how to install Samba on Ubuntu, an open-source Linux utility that enables file sharing, or install an NFS server on Ubuntu and view, store, share, or update files on remote computers.

Mounting_Error

Figure: Error occurred while accessing the windows drive

Following are the step wise instructions to access windows drives in Ubuntu (Any Version),

1. Open terminal and type sudo ntfsfix error mounting location as shown in above picture and press enter button.
2. It will ask for system password, enter password and again press enter.
3. It will take some seconds to process command and at the end shows the message like “NTFS partition was processed successfully.”
4. Again click on windows drive, now you are allow to access clicked drive.

For Example:
Step 1:

Type sudo ntfsfix /dev/sda3 and press enter as shown in below picture then it will ask for system password, enter password and again press enter.

Step 2:
It will take some seconds to process command and at the end shows the message like “NTFS partition was processed successfully”, as shown in below picture.

Last Updated :
23 Dec, 2018

Like Article

Save Article

In the Windows operating system, there is a feature called file sharing. On one computer, you can set up windows-shared folder that will be accessible to all computers on the local network. This is done using the SMB protocol, which has several versions. In Linux, you can open and create shared folders using Samba.

The Samba server supports all versions of the SMB protocol. However, there are some compatibility issues. In this article, I will explain how to access a Windows Shared folder in Linux using popular desktop environments and the command line.

Table of Contents

Why It May Not Work?

In older versions of Linux distros and Windows 7 everything worked fine because they used the SMB1 protocol. However, there have been several changes recently. In 2017, the Wannacry virus emerged, which exploited vulnerabilities in the SMB1 protocol. As a result, modern versions of Windows have disabled support for SMB1 and now use SMB3 by default. Samba has also disabled SMB1 since version 4.11. However, SMB2 and SMB3 lack support for device discovery in the local network.

In general, this is no longer necessary because there is a network discovery protocol called Zeroconf. In Linux, its open-source implementation, Avahi, is used. Linux servers and NAS storage can publish themselves on the local network using this protocol. So that, there is no need to support it in SMB. However, Microsoft decided to use its own protocol called WS-Discovery, and that’s where the problems began.

At the time of writing this article, Linux system has issues with discovering shared folders in the local network. The Nautilus file manager in GNOME does not support WS-Discovery at all, and there are no production-ready terminal utilities for it either. You can track the current status of implementing WS-Discovery support in this GVFS issue. However, in 2020, the KDE team added support for this protocol in the Dolphin file manager using kdsoap-ws-discovery-client.

Later, a program for KDE called Smb4k appeared, which can discover network resources using Avahi and the WS-Discovery protocol, but it needs to be compiled with a special option. So that, in GNOME, you can only open a Windows shared folder by knowing the IP address of the computer where it is located. Whereas in KDE, it is a bit more convenient to do so.

Ensure that Everything is Set Up Correctly in Windows

Previously, it was enough to go to File Explorer and enable file sharing there. But it no longer works that way. First, you need to make your current network private in Windows. By default, only private networks are considered secure, and Windows machines can be discovered in them. To do this, open Settings -> Network & Internet -> Ethernet and select Network Profile Type -> Private Network:

If your current network is wireless, you should do the pretty same thing. Next, go back and select Advanced Sharing Settings. In this window, enable Network discovery and File and printer sharing:

Finally, you need to ensure that the firewall is configured correctly and allows SMB connections. To do this, go back to the main Settings menu, then open Privacy & Security -> Firewall & network protection. Click on Allow an app through the firewall:

Make sure that File and printer sharing and Network discovery are enabled for Private networks:

That’s it. Now you can go to your Linux machine.

Finding Shares in Linux Terminal

Although there are no command-line tools for working with WS-Discovery, you can try to find devices with shared resources using Nmap. This program cannot search for resources like Avahi does, but it can help you find IP addresses with an open port 445. This port is used by SMB. To do this, you need to install the following packages (Ubuntu):

sudo apt install nmap smbclient

Or Fedora:

sudo dnf install nmap samba-client

Also, you need to find out the IP address range of your local network. You can take your IP address and mask and just replace the fourth digit with zero. For example:

ip -br a

The command for the search will look like this. Replace 192.168.124.0/24 with your local network address range and run it in the the terminal window with sudo privileges:

nmap -p 445 --open -n -Pn 192.168.124.0/24

The -p option specifies the port 445, -Pn option disables ICMP discovery and treats all IP addresses as alive, -n disables DNS hostname resolution. The command may take quite a while, but as a result, it will find hosts with open port 445 if such hosts exist in your local network:

This can’t be considered as normal network discovery, but it works. Now you can use smbclient to see which shared folders are on the server that you found. For example:

smbclient -L \192.168.124.63

The command will ask you to enter the share password. Usually, it is password for your Windows user, and then it will show all available shared folders:

Now let’s have a look at how to mount them.

Open Shared Folder in KDE Dolphin

To open a shared folder in KDE, you can use the Dolphin file manager. As I mentioned earlier, here you can see all available computers that have network drive on the local network. To do this, run Dolphin, then open Network, and then Shared Folders (SMB):

Click on one of the resources and enter the username and password to view the available folders:

This is what shared folders from Windows 11 look like. Here you can find windows files:

If network discovery does not work in your case, you can still enter the IP address of the resource in the text field at the top of the window and connect to it. For example, smb://192.168.124.63/

Open Share in GNOME Nautilus

If you want to connect to a Windows shared folder in the GNOME graphical interface, you can use the Nautilus file manager. Open Other Locations and find at the bottom of the window the inscription Connect to Server and a field for entering an address.

There’s no point in opening the Windows Network item, because GVFS, which is used in GNOME for disk mounting, does not support the WS-Discovery protocol. To connect to a remote windows share located on a server with IP 192.168.124.63, enter this address and press the Connect button:

smb://192.168.124.63

In the next window, you need to enter a password and after that, you can view the files of the shared folder:

After this, you can browse your windows folders.

Additionally, you can use a shortcut on the left panel to access a remote share which is already mounted.

Mounting a Shared Folder in the Terminal

If you want to mount windows share in the terminal, you can use cifs-utils and the mount command. Firstly, install the cifs-utils package. The command for Ubuntu:

sudo apt install cifs-utils

In Fedora:

sudo dnf install cifs-utils

Now, you can execute the mount command specifying the cifs file system type and the username option. Note that you can’t mount the root of the cifs share, you need to add any folder in the path. For example, Users on 192.168.124.63:

sudo mount -t cifs -o username=losst //192.168.124.63/Users /mnt/

If you want to have write access to the windows share folder, you need to add the uid option with the identifier of your user. For the first user, it’s usually 1000:

sudo mount -t cifs -o username=losst,uid=1000 //192.168.124.63/Users /mnt/

You can find the identifier of the current user in the UID environment variable:

echo $UID

If you want to mount share automatically at system startup, you need to save the share username and password in a credentials file, for example, /etc/share/windows-credentials. For instance:

sudo mkdir -p /etc/share/

/etc/share/windows-credentialsusername=losst
password=password
domain=workgroup

And then add the following line to the /etc/fstab file:

/etc/fstab//192.168.124.63/Users /mnt/share cifs credentials=/etc/share/windows-credentials,uid=1000,nofail 0 0

The nofail option is needed to allow your computer to boot even if the remote folder could not be mounted. After this, reload systemd settings:

sudo systemctl daemon-reload

Create the mount point directory:

sudo mkdir -p /mnt/share

You can check that everything is working using the following command:

sudo mount /mnt/share

If everything is ok, you could see contents of mounted share in the /mnt/share folder:

Wrapping Up

In this article, we looked at how to mount Windows network share in Linux using a graphical interface or in the terminal. Despite some difficulties, this can be used quite effectively. Do you know any other applications or scripts which can help with that? Share their names in the comments section below.

Found a mistake in the text? Let me know about that. Highlight the text with the mistake and press Ctrl+Enter.

Creative Commons License

The article is distributed under Creative Commons ShareAlike 4.0 license. Link to the source is required .

Windows drives aren’t mounted automatically when you log in on Linux. But that doesn’t mean you can’t access those NTFS drives at all.

inside of a hard disk

If you are rocking a dual-boot setup with Windows and Linux, you might want to access data stored in the Windows drives from the Linux system.

However, you might find that Windows drives do not appear in the file manager. This is because, in some distros, you need to manually mount them. Let’s take a look at how you can access your NTFS/Windows drives in Linux.

Step 1: Install the NTFS-3G Driver

To successfully mount and access NTFS drives on Linux, you will need to install a driver to ensure no incompatibility issues arise. The go-to driver when working with NTFS drives is NTFS-3G. It’s cross-compatible between Debian/Ubuntu derivatives, Arch Linux-based systems as well as RHEL/CentOS/Fedora systems.

To install the NTFS-3G driver on your Linux system, fire up a terminal and install it using the package manager of the distro that you’re running:

On Debian and Ubuntu, run:

 sudo apt install ntfs-3g 

On Arch-based systems, run:

 sudo pacman -S ntfs-3g 

To install the NTFS-3G driver on Fedora, CentOS, or RHEL, issue the following command:

 sudo dnf install ntfs-3g 

This should install the driver on your Linux system. Now you can move on to the next steps.

Step 2: Identify the NTFS Partition

output of the fdisk -l command

A preliminary step before mounting a drive is to first identify its device ID. This is important because you might end up causing unwanted data loss by working with the wrong partition or drive.

To identify all the drives and their partition types, use the fdisk command with the -l flag.

 sudo fdisk -l 

The output will display all the different drives and partitions along with useful information like size, available free space, partition type, and more. Take note of the device name carefully. You will be needing it later on in this guide.

Step 3: Make a Directory to Mount the Drive

In Linux, everything is treated as a file, including hardware devices. So, to mount your NTFS drives on Linux, you have to create a separate directory wherein the drive will be mounted, and its content laid out.

This process is as simple as creating a regular directory on Linux. Using the mkdir command, create a new directory in the root partition of your Linux system. For the sake of better organization, make the directory under the /mnt directory and name it «media».

 sudo mkdir /mnt/media 

Now that we’ve allocated a directory for the NTFS drive, we need to update the file system tables on Linux with the location of the drive.

Step 4: Update the File System Tables and Mount the Drive

update fstab

Updating the file system tables is a crucial step that enables your Linux machine to recognize and mount new storage drives. In Linux, the /etc/fstab file stores the file system configurations.

 sudo nano /etc/fstab

You need to add the NTFS drive’s location and other important data to make sure that your system can mount it without any hiccups.

To update the file system table of your Linux system, use any text editor of your choice and open the /etc/fstab file.

In a new line, add the NTFS drive location, the directory that you created earlier, the driver to use (NTFS-3g), and read, write, and user access information. Make sure to separate each input with one Tab space. If you’re unsure what to type in, you can replicate the settings for any drive that’s already mounted and functional.

Write out the file once you’re done inputting the data. Fire up the terminal and use the mount command in conjunction with your device ID to mount it:

 mount /dev/sda3 /mnt/media/drive_location_here

In case you wish to unmount the drive, you can do that using the umount command:

 umount /dev/sda3 /mnt/media/drive_location_here 

That’s all you need to do. Optionally you can restart your system, however, it won’t be required in most cases. You can now explore your NTFS drive from the terminal using the cd command or via the file manager of your Linux distro.

Now You Can Access Windows Drives in Linux

While it may be a bit tedious, it is still straightforward and a permanent process. You can now freely mount and unmount your Windows drives when logged into Linux. In case you want to permanently use the drive on Linux, you will need to format it.

Linux and Windows systems have major differences, with different file systems and protocols in use. Sharing files between them can be difficult, especially because they use two different sharing protocols. That doesn’t mean it’s impossible to mount a Windows share folder on Linux, however. Follow along below to find out how.

Also read: How to View Shared Files and Folders in Windows 10

Before you do anything, you need to ensure that Windows has been correctly set up to allow for networking file sharing.

To enable this on Windows, right-click on the network icon in the notifications area of your Windows taskbar. From here, click «Open Network & Internet Settings.»

How To Mount A Windows Share Folder On Linux Networks

Under the «Status» category, click «Sharing options.»

Windows Network Sharing Settings Menu

In your Windows sharing options menu, make sure that «Turn on network discovery» and «Turn on file and printer sharing» are enabled.

Click the radio buttons next to both options to make sure this is the case.

Windows Enable Network Sharing

Click «Save changes» to save your settings. Once this is done, open Windows File Explorer and locate the folder you’re looking to share with your Linux PC.

Right-click the folder and click «Properties.»

How To Mount A Windows Share Folder On Linux Desktop Properties

In your folder properties, click the «Sharing» tab, then click «Advanced Sharing.» Click to enable the «Share this folder» checkbox, then click «Permissions.»

Windows Share Folder

Under the «Permissions» section, set the control rights for your folder. By default, Windows will grant read-only access to your files.

If you want to allow everyone to read or write to the folder, click «Allow» for the «Full Control» permissions set. Set these permissions to suit your own requirements.

Windows Folder Share Permissions

Once you’re done, click «OK» three times to close each of the dialog boxes.

Your folder should now be shared on your network, ready for you to access from your Linux PC.

Install CIFS-utils

Depending on your Linux distribution, you may be able to mount your Windows-shared folder automatically in your distribution’s file explorer.

However, this may not work correctly. The safest way to mount Windows-shared folders on Linux is to use the CIFS-utils package and mount the folder using the Linux terminal.

This allows Linux machines to access SMB file shares used by Windows PCs.

Linux Install Cifs Utils

To install CIFS-utils, open a new terminal window. For Ubuntu and Debian-based distributions, type:

sudo apt install cifs-utils

For Arch users, type:

Once installed, you can then mount your Windows share folder from the Linux terminal.

Mount Windows SMB Share on Linux

You’ll need to create a mount directory before you can mount your Windows SMB-shared folder on Linux. This is where Linux will mirror the contents of your shared folder.

To do that, open a terminal window and type:

Once created, type the following:

sudo mount.cifs //Windows/SharedFolder /mnt/share -o user=account

Replace «Windows» with the IP address or hostname for your Windows PC and «SharedFolder» with your shared folder name. For the username, replace «account» with your Windows username or full Microsoft account email.

Linux Mount Folder Command

You’ll be asked to provide your Windows password before the mounting process is complete. Type this in, then click Enter. If you used the correct information, your Windows folder should now be mounted and accessible in the folder you created.

Sharing Files Between Linux and Windows in Dual Boot

Sharing files between Windows and Linux works great when you mount a shared folder between the two devices, but can you still share files with a dual boot setup? Linux and Windows have separate file systems. Linux usually uses Ext4, while Windows uses NTFS and also works with FAT32. This doesn’t mean it’s impossible to see and share files, though.

You’ll need a compatible Windows system, build 20211 or higher, and a few other resources to make it work. Don’t worry. Everything is free. This guide walks you through each step in the process, including a way to read and share files between Windows and Linux.

Frequently Asked Questions

1. Why do I get a syntax error when trying to mount a folder in Linux?

Either there’s a small error in the command in the terminal window, or you have a space in the folder name. Spaces don’t always come across correctly in the syntax. Instead of recognizing the command as the full name of the folder, the system sees two unrelated items.

Avoid this by placing the name in quotes. For instance, Shared Folder would become «Shared Folder.» Of course, you can also just rename the Windows 10 folder to place the words together or have a dash between them.

2. Can I mount a shared folder if I use VirtualBox?

Yes. The process should work the same way. You can also share devices, such as USB drives.

3. Can I mount guest, network, or password protected folders?

Yes, but since you’re not using the main Windows 10 account, you will need to adjust the syntax a bit. Plus, if you’re mounting a network folder, you’ll also need the server or machine name.

While this guide applies to Ubuntu, it should work for most major Linux distros as well. It lists the syntax for different scenarios, assuming you’ve already completed all of the steps (except the final mounting) above.

4. Why do I only have read access for the shared folder?

If you want to store files in the shared folder from Linux, make sure you have full read/write access to the folder in Windows. If the Windows user account only has read permission, this is the only permission you’ll have from Linux as well. You must change your account permissions from within Windows 10. For companies, you’ll need your IT admin to make the change for you.

5. Why aren’t folder changes showing up?

If you’ve made changes to the permissions of the folder, they may not show up immediately in Linux. You’ll need to remount the folder for changes to take effect.

Use the command above to remount any shared folders. This should ensure things work as expected. If you have any random glitches, remounting typically fixes them.

Wrapping Up

Mounting Windows and Linux shared folders gives you the freedom to access your most important files, no matter the operating system. The SMB protocol is well supported on Linux, so you shouldn’t find it difficult to continue accessing your Windows files and folders once you’ve installed the CIFS-utils package.

If you’d rather use a single system, here are five of the best Linux distros for Windows users you could use.

Crystal Crowder

Crystal Crowder has spent over 15 years working in the tech industry, first as an IT technician and then as a writer. She works to help teach others how to get the most from their devices, systems, and apps. She stays on top of the latest trends and is always finding solutions to common tech problems.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

  • How to run windows apps on linux
  • How to play windows games on android
  • How to share printer in windows
  • How to make windows backup
  • How to play roblox on windows 7