Linux – Mount network share

Article/credits from: linhost.info

Create Mount Point

For every network share you wish to mount you need to specify a mount point just like we do with hard drives and USB drives. I would recommend creating the mount point in the /mnt directory.

mkdir /mnt/shares/share1

Install Cifs-util Suite

If the system you are working with lacks the cifs-util it can be installed using the package manager for your distribution.

Ubuntu and Debian users can use apt-get.

apt-get install cifs-utils

Scientific Linux and CentOS users can use yum.

yum install cifs-utils

Mount Network Share With Credentials

The basic command below will attempt to mount a network share with credentials, in this case the file server is a Windows Server 2003 and the client is a Ubuntu 12.04 server.

mount.cifs //192.168.1.107/share1/  /mnt/shares/share1/ -o user=user1,pass=user1password

Description:

  • mount.cifs – Mount using the CIFS
  • //192.168.1.107/share1/ – IP address or name of file server followed by the share name
  • /mnt/shares/share1/ – This is the mount point where our network share will reside
  • -o users=user1,password=user1 – This means options and in my case I am specifying the username and password to the share

Mount Public Share

To mount a public share or one that doesn’t require a password is even easier. All you are required to specify is the server IP address, share and mount point.

mount.cifs //192.168.1.107/share1/  /mnt/shares/share1/
  • mount.cifs – Mount using the CIFS
  • //192.168.1.107/share1/ – IP address or name of file server followed by share name
  • /mnt/shares/share1/ – This is the mount point where our network share will reside

Mount Share At Boot

Now that was easy, keep in mind that using the commands above will only result in the network shares being temporarily mounted, if the system were to be rebooted all mounted shares will be unmounted. If you would like to keep the network shares mounted even after a reboot you can acomplish this with the help of the fstab configuration file.

Add the following line to the bottom of your fstab configuration file. Modify to fit your needs.

//192.168.1.129/share1  /mnt/shares/share1  cifs  username=user1,password=user1password  0  0

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s