Windows Network Share

From ArchWiki

Jump to: navigation, search
Article summary
An overview of methods available to users wishing to access Windows shares.
Available in languages
English
Related articles
NFS
Samba

This article covers accessing Windows shares using Samba.

Contents

Preparation

Install the smbclient package with pacman:

# pacman -S smbclient

Automatic share mounting

There are several alternatives for easy share browsing.

smbnetfs

1. Install smbnetfs:

# pacman -S smbnetfs

2. Add the following line to /etc/fuse.conf:

user_allow_other

3. Load the fuse kernel module:

# modprobe fuse

4. Start the smbnetfs daemon:

# /etc/rc.d/smbnetfs start

All shares in the network are now automatically mounted under /mnt/smbnet.

Add the following to /etc/rc.conf to access the shares at boot:

MODULES=(... fuse ...)
DAEMONS=(... smbnetfs ...)

fusesmb

Note: Because smbclient 3.2.X is malfunctioning with fusesmb, revert to using older versions if necessary. See the relevant forum topic for details.

1. Install the fusesmb package from the AUR using yaourt or other AUR Helpers:

$ yaourt -S fusesmb

2. Create a mount point:

# mkdir /mnt/fusesmb

3. Load fuse module:

# modprobe fuse

4. Mount the shares:

# fusesmb -o allow_other /mnt/fusesmb

For mounting shares at boot, add the command above to /etc/rc.local and add fuse module to /etc/rc.conf:

MODULES=(... fuse ...)

Autofs

Autofs is a kernel-based automounter for Linux. See the Autofs wiki article for details.

Manual share mounting

1. Create the mount point for the share:

# mkdir /mnt/MOUNTPOINT

2. Mount the share using mount.cifs. Keep in mind that not all options may be needed nor desirable, such as password:

# mount -t cifs //SERVER/SHARENAME MOUNTPOINT -o user=USERNAME,password=PASSWORD,workgroup=WORKGROUP,ip=SERVERIP
SERVER
The Windows system's name
SHARENAME
The shared directory
MOUNTPOINT
The local directory where the share will be mounted to
-o [options]
Specifies options for mount.cifs
user
Username used to mount the share
password
The shared directory's password
workgroup
Used to specify the workgroup
ip
The IP address of the server -- if the system is unable to find the Windows computer by name (DNS, WINS, hosts entry, etc.)
Note: Abstain from using trailing directory (/) characters. Using //SERVER/SHARENAME/ will not work.

3. To unmount the share, use:

# umount /mnt/MOUNTPOINT

Adding the share to /etc/fstab

Add the following to /etc/fstab for easy mounting:

//SERVER/SHARENAME /mnt/MOUNTPOINT cifs noauto,noatime,users,username=USER,password=PASSWORD,workgroup=WORKGROUP 0 0

The noauto option disables mounting it automatically at boot and noatime increases performance by skipping inode access times.

After adding the previous line, the syntax to mount files becomes simpler:

# mount /mnt/MOUNTPOINT

Allowing users to mount

Before enabling access to the mount commands, fstab needs to be modified. Add the users options to the entry in /etc/fstab:

//SERVER/SHARENAME /mnt/SHAREMOUNT cifs users,noauto,noatime,username=USER,password=PASSWORD,workgroup=WORKGROUP 0 0
Note: The option is users (plural). For other filesystem types handled by mount, this option is usually user; sans the "s".
Warning: A more secure option is to use sudo to grant privileges. Setting the setuid bit is potentially dangerous and is not recommended.

For users to be allowed to mount and unmount the Samba share, the setuid flag must be activated on the following two files to allow users to execute the commands with elevated privileges:

# chmod u+s /sbin/mount.cifs
# chmod u+s /sbin/umount.cifs
Personal tools