RTT #02 — Setting Up File Sharing on Windows and Access From Ubuntu 18.04 LTS Server (for absolute dummies)

Hajar Razip
3 min readJun 13, 2021

So currently I have this setup where I house all my source codes (and work on them “remotely” using VSCode) in a VirtualBox VM running Ubuntu 18.04LTS server with bridged networking, hosted on a Windows 10 machine. As a python developer, I prefer developing on Linux because I’m used to managing my virtual environments there. Recently I figured I needed to set up a shared folder on my Windows machine so I can quickly access certain files from my VM. Now, I’ve never really done a lot of administering on Windows so I’m a bit blur on getting around certain things (excuse my Manglish). But somehow I managed to pull it off; here is how I did it:

STEP 1: Prepping the shared file on Windows

Follow the instructions here on How to share files using File Explorer. Here is a summary:

  1. Create a folder anywhere you like in the File Explorer. I created one in “Documents” and named it “iris”.
  2. Right clik on the folder and click on “Properties”.
  3. In “Sharing” tab, click on “Share” in the “Network File and Folder Sharing” box.
  4. Pick “Everyone” in the drop down and click “add” button.
  5. Set “Permission Level” of “Everyone” to read/write and click “Share” button. Click “close” and “done”.
  6. Take note of the location of shared folder in right-click on folder > Properties > Sharing

7. Then run ipconfig on the cmd to check your IP address. You will use this IP address in place of “DESKTOP-HAJAR” above (of whatever it is that your machine is named). So in my case, I had a string that looked like this:

\\192.168.1.100\Users\hamor\Documents\iris

STEP 2: Mounting the shared folder on Linux

  1. Install cifs-utils .
    sudo apt install -y cifs-utils
  2. Create a folder where you will mount the shared folder to. I created mine in /mnt/iris :
    sudo mkdir /mnt/iris

Option 1: The manual way

We will use the mount command and pass the string from earlier, and use several other options. Be sure to set “user” to the user account that created the Windows shared folder. You will usually find this from the network path to the shared folder, right after “User” (see no.6 above):
sudo mount -t cifs -o user=hamor //192.168.1.100/Users/hamor/Documents/iris /mnt/iris

Option 2: The “permanent” way

  1. If you follow option 1, you will notice that the folder is not permanently mounted at /mnt/iris . To automatically mount on startup, we need to first edit /etc/fstab . Add the following line:
# <file system>             <dir>          <type> <options>                                                   <dump>  <pass>
//192.168.1.100/Users/hamor/Documents/iris /mnt/iris cifs credentials=/etc/win-credentials,file_mode=0755,dir_mode=0755 0 0

2. Create a file /etc/win-credentials and add the following info:

username=hamor
password=<password>

3. Mount the folder with mount /mnt/iris .

Conclusion

And you are done. Simple as that.

References

  1. https://pureinfotech.com/setup-network-file-sharing-windows-10/
  2. https://www.hiroom2.com/2018/05/04/ubuntu-1804-cifs-utils-en/
  3. https://askubuntu.com/questions/337128/mount-error13-permission-denied
  4. https://linuxize.com/post/how-to-mount-cifs-windows-share-on-linux/

Hi! Welcome to my third RTT (“Random Tech Tips”) — a series (updated sporadically, when some things come up and I feel like I would totally need that stuff for future reference) for various mini-guides in IT (and other computer things like coding, data science, etc.) that teaches you how to achieve certain things in a day-to-day of a constantly learning IT person. More than anyone the content of this series will be useful to me, who, given the nature of my day-job, will inevitably go through these sort of things repeatedly in the course of my career. But I hope it will help you achieve that certain thing too if that’s what you’re here for.

--

--

Hajar Razip

Lady in tech. Hobbyist. I post about the randomest things.