Sharing folder between Win and Linux

Guide to configure shared folder between Windows and Linux system

Production Guide: Permanent Windows SMB Share Mount on Arch Linux (Hyprland)

This guide documents the configuration required to permanently mount a secure Windows shared folder onto an Arch Linux system running Hyprland. The mount is handled directly by the Linux kernel using the cifs filesystem driver, making it persistent, fast, and independent of any desktop environment.


Part 1: Windows Side Configuration

To allow secure access to a specific folder without exposing it to the entire network, follow these configuration steps on your Windows machine:

  1. Set Network Profile to Private:
    • Go to Network settings and change your connected Wi-Fi/Ethernet profile from Public to Private. This opens the necessary Windows Firewall ports for file sharing [shopping].
  2. Enable File Sharing:
    • Open Advanced sharing settings in Windows and turn on Network discovery and File and printer sharing under the Private profile section [shopping].
  3. Isolate and Share the Folder:
    • Create a folder on your C: drive named Sharing.
    • Right-click the folder -> Properties -> Sharing tab -> click Advanced Sharing… [shopping]
    • Check Share this folder [shopping].
    • Click Permissions -> select Everyone and click Remove (this prevents unauthorized network access) [shopping].
    • Click Add… -> type your precise Windows username (verify using the whoami command in CMD) -> click Check Names and confirm [shopping].
    • Select your username in the list and check Allow next to Full Control [shopping].
    • Apply and save all changes [shopping].

Gathered credentials needed for Linux:

  • Windows IP Address: (e.g., 192.168.0.110 from ipconfig)
  • Windows Username: (e.g., tomas from whoami)
  • Windows Password: (Your primary Microsoft Account password, NOT the local PIN)

Part 2: Arch Linux Side Configuration

Since Hyprland doesn’t rely on background auto-mounting daemons, we mount the network share natively through the system mount table.

Step 1: Install CIFS Utilities

sudo pacman -S cifs-utils

Step 2: Prepare the Local Mountpoint

Create the directory where the Windows files will appear inside your home directory:

mkdir -p ~/windows_share

Step 3: Secure the Credentials File

To avoid putting plain-text passwords into the public /etc/fstab file, create a dedicated credentials file hidden from other system users:

sudo vim /etc/win-credentials

Populate it with your Windows details:

username=tomas
password=your_microsoft_account_password

Lock down file permissions so only root can read it:

sudo chmod 600 /etc/win-credentials

Step 4: Configure /etc/fstab for Persistent Mounting

Open the static filesystem table configuration file:

sudo vim /etc/fstab

Append the following line to the end of the file (ensure the IP and paths match your setup):

# [Windows Network Path]        [Local Mountpoint]          [Type]   [Mount Options]
//192.168.0.110/Sharing        /home/tomas/windows_share   cifs     credentials=/etc/win-credentials,uid=1000,gid=1000,nofail,noatime,_netdev  0  0

Mount Options Explanation:

  • uid=1000,gid=1000: Maps file ownership directly to your regular Arch user (tomas), giving you full read/write permissions without requiring sudo.
  • nofail: Prevents the Arch Linux boot sequence from hanging or crashing if the Windows PC is offline during boot.
  • noatime: Disables access time logging on files to optimize network I/O speed.
  • _netdev: Forces the OS to delay mounting this share until the network stack (Wi-Fi/Ethernet) is fully up and running.

Step 5: Reload and Test the Configuration

Always force systemd to reload the modified fstab structure and run a safe test before assuming everything works:

sudo systemctl daemon-reload
sudo mount -a

Note: If sudo mount -a executes silently without throwing any terminal errors, the configuration is perfect.


Part 3: Verification & Inspection Cheat Sheet

Because network mounts do not register as physical drives via lsblk, use these diagnostic utilities to check active states:

  • List mounted network shares:
    findmnt -t cifs
    
  • Check storage capacity and usage stats:
    df -h | grep windows_share
    
  • Verify files list directly from the terminal:
    ls -la ~/windows_share