How to mount a network folder automatically?

I have to mount a folder in a server. At present i use command “sudo mount -t cifs //shfiler1/iproot /shfiler1/iproot -o credentials=$HOME/.smbpwd” to mount it to iproot folder. Content in .smbpwd is like

username=foo
password=plaintext

This way is ok to mount it. But i want to mount this folder every time when openSUSE start up. I tried NFS client, there is no option to setup username and password, so connection failed. I don’t know if there is anyother way to do that.
Hope someone can help me.

On Tue, 21 Aug 2012 00:36:02 +0000, JeromeCui wrote:

> This way is ok to mount it. But i want to mount this folder every time
> when openSUSE start up. I tried NFS client, there is no option to setup
> username and password, so connection failed. I don’t know if there is
> anyother way to do that.

NFS won’t do CIFS.

When you mount the volume, have a look in /etc/mtab and see what the
entry looks like - that should guide you for an /etc/fstab entry.

Jim


Jim Henderson
openSUSE Forums Administrator
Forum Use Terms & Conditions at http://tinyurl.com/openSUSE-T-C

I found an entry like this:
//shfiler2/iproot/ /shfiler1/iproot cifs rw,relatime,sec=ntlm,unc=\shfiler2\iproot,username=x_cui,uid=0,noforceuid,gid=0,noforcegid,addr=134.244.234.100,file_mode=0755,dir_mode=0755,nounix,rsize=16384,wsize=131007,actimeo=1 0 0

You could write a bash script and have it run on each startup. I have a script that helps write scripts here: N.S.F. - New Script File, Bash Script File Header Creator - Version 2.81 - Blogs - openSUSE Forums

You could put it in the after.local script perhaps, to run as root, but you would have to hard code the user name: systemd and using the after.local script in openSUSE 12.1 - Blogs - openSUSE Forums

For scripts run in user space that needs to use the sudo command, have a look at this bash script: asroot version 1.14 allows you to run a program (with options) as a root user - Blogs - openSUSE Forums

Of course I just use Samba to browse shares, which may not apply to a server, but here are a couple of examples: Samba S.W.A.T. - Samba Web Administration Tool Setup for openSUSE - Blogs - openSUSE Forums

And this to do it automatically for you: SWAT - Samba Web Administration Tool - Setup & Creation Script - 1.03 - Blogs - openSUSE Forums

Thank You,

Thanks a lot. That’s really great!

On 08/21/2012 10:36 AM, JeromeCui wrote:
> mount -t cifs //shfiler1/iproot /shfiler1/iproot -o
> credentials=$HOME/.smbpwd" to mount it to iproot folder. Content in
> .smbpwd is like

Try this line in fstab (and also make the last line in fstab a blank line):

//shfiler1/iproot /shfiler1/iproot   cifs
username=foo,password=plaintext,_netdev   0 0


Regards
swerdna

On 08/21/2012 10:36 AM, JeromeCui wrote:
> mount -t cifs //shfiler1/iproot /shfiler1/iproot -o
> credentials=$HOME/.smbpwd" to mount it to iproot folder. Content in
> .smbpwd is like
Try this line in fstab (and also make the last line in fstab a blank line):

//shfiler1/iproot /shfiler1/iproot   cifs
username=foo,password=plaintext,_netdev   0 0


Regards
swerdna