In this tutorial I will show you how to set up a share on windows and then mount it on a Linux computer.
In the past, I have configured Samba shares on Linux servers to share files with Windows because our servers all run on Linux, but my colleagues prefer to develop in Windows. This is not ideal because the windows-side will "go slow", with Netbeans auto-complete functionality appearing to suffer. Another drawback is that windows realizes that it is a network mount, and will no longer show TortoiseSVN status emblems to indicate whether a folder has outstanding changes etc. Sharing the other way round with Windows -> Linux resolves these issues.
Check Windows Settings
Make sure your network profile is set to home or office.
Open your Network and Sharing Center.
Click on "Change advanced sharing settings".
Make sure that:
- network discovery is on.
- file and printer sharing is on.
- password protected sharing is on.
- keep the default 128 bit encrypted file sharing.
- Allow Windows to manage homegroup connections (recommended)
Create the Share
Create a folder that you wish to share with other computers. I prefer to keep these folders directly in C: for simplicity. In this case I have created a folder called
Right click the folder and click properties.
Sharing tab and then click
Share this folder and then click
Add to add a specific user.
Type your username into the box as indicated and then click "Check Names". The computer should give the full system name for the user as it needs it. You can then click ok.
Now make sure your own username is selected, and then ensure that "Full Control" and "Change" are selected.
Go back to the "Advanced Sharing" Window and click the Caching button.
Click the option to disable caching. This seems to make things work immediately.
Mount the Files on Linux
Install the necessary packages:
sudo apt update && sudo apt install cifs-utilsCreate a location to mount your windows share and mount it with the following script (make sure to fill in your settings as appropriate).
# Settings MOUNT_LOC=$HOME/code WINDOWS_MACHINE_IP=188.8.131.52 WINDOWS_USER="stuart" USER_ID=`id -u` SHARE_NAME="code" # Create our mount location mkdir -p $MOUNT_LOC # Mount the windows share sudo mount -t cifs \ -o user=$WINDOWS_USER,uid=$USER_ID,gid=$USER_ID,rw \ //$WINDOWS_MACHINE_IP/$SHARE_NAME \ $MOUNT_LOC
Thats it! You should now be able to view all the files in your mounted directory and edit them, or create new ones. If you find that you are unable to edit or create files, please make sure to re-visit the steps for adding yourself to share permissions and setting full control. If you are unable to mount the directory, be sure to check that you disabled caching, and that all your settings are correct, such as the windows username, and the IP address of the windows machine.