Automatically mount a windows share at boot time with Linux

This document (7000932) is provided subject to the disclaimer at the end of this document.

Environment

Running SUSE Linux Enterprise Desktop (SLED), Server (SLES), or openSUSE products.

Windows or Samba Share available on the network.

Situation

A Windows (or Samba) share has been made available on the network.  On the SLED system, the share can be accessed by browsing or via the mount command, but there is a need to have permanent access to this share every time the SLED system is booted.

Resolution

The configuration file /etc/fstab is used to specify the local partitions and remote file systems to be mounted on startup of the system.  A line can be added to this file with the following format:

//<Winserver>/<Share> <Mountpoint>  <FileSystemType> <Options>  0  0

Here's an example, setting the group ID and the permissions to allow those in the group users read and write access to the share:

//winserver/share /mnt/winshare cifs gid=users,file_mode=0664,dir_mode=0775,auto,username=john,password=johnpass 0 0

This example assumes the following values (includes explanation where needed):

//winserver/share     (Windows Share)
The Windows system (winserver) could be identified as a DNS hostname or IP address.

/mnt/winshare     (Mount Point)                              
This is the already existing directory on the SLED local file system which will become the access point to the remote Windows share.  It can be created anywhere on the system; modify the command appropriately.

cifs     (File System Type)
This used to be smbfs but the smbfs module is no longer being developed and is no longer supported.

gid=users
All files and directories on the remote system (including the mount point) will be assigned the group users.

file_mode=0664
All existing files on the remote system will be assigned permissions of rw-rw-r--.

dir_mode=0775
All existing directories (including the mount point) on the remote system will be assigned rwxrwxr-x.

auto
Automatically mount on system boot.

username=john
Windows user to connect with:   john

password=johnpass
John's Password:                        johnpass

0
Indicates that this file system should not be dumped.

0
Indicates that this file system should not be checked by fsck.

Troubleshooting

If the share is not getting mounted, try to mount the share manually, as the root user, to see if there are any errors.  Here's the command:

mount -t cifs -o username=<WindowsUserID>,password=<UserPassword> //<WinServer>/<Share> /<Mountpoint>

Following our example:

mount -t cifs -o username=john,password=johnpass //winserver/share /mnt/winshare

If the password is omitted from the mount command it will be asked for after issuing the command.

Additional Information

On most systems, it is not desirable to have the user ID and password be viewable in the/etc/fstab file for security reasons.  Instead, one can create a file in a secure directory that will hold the user ID and password information and be referenced by the fstab entry.  Remove the"username=" and "password=" entries from the options and add"credentials=<PathToFile>".

The following 2 lines should be in the credential text file (replacing <bracketed> items with your specific information):

username=<WindowsUserID>
password=<UserPassword>

On SLES10, the package samba-client needs to be installed manually and started on bootup to mount Samba-shares automatically on boot.

This can be achieved by running the following commands:

# zypper in samba-client
# insserv smbfs

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7000932
  • Creation Date: 15-Jul-2008
  • Modified Date:03-Mar-2020
    • SUSE Linux Enterprise Desktop
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Join Our Community

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.


SUSE Customer Support Quick Reference Guide SUSE Technical Support Handbook Update Advisories
Support FAQ

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.

Go to Customer Center