LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-16-2012, 03:00 PM   #1
adellaci
LQ Newbie
 
Registered: Nov 2010
Location: Maine, USA
Distribution: Ubuntu, Fedora, CentoOS
Posts: 2

Rep: Reputation: 0
Newbie - Auto mount NFS upon log in of a user


I have two Black Armor 101 NAS on my network. I'm using Fedora 17 for OS. I have been unable to get a directory on the NAS that has its own user password that is different from the user password on Fedora system to mount with full privileges. The finial result would be, when i log in to Fedora, it auto mounts a NAS directory with full privileges. So some way to pass on the user and password for that NAS Directory. I have had success with mounting the Public directory with full privilege, but not any of the secured directories. Then un-mount when i log out.
 
Old 10-18-2012, 03:21 PM   #2
Rupadhya
Member
 
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Rep: Reputation: Disabled
I think one way you could do this is to run a crontab job to mount the NAS device. I use CIFS to mount another Linux machine or XP machine (depending how it is booted) and then exits. If is already mounted by checking if the backup directory on the other machine exists, the script exits.

Code:
#! /bin/bash
## Mount the other machine
mountpoint="//192.168.1.1/C"
volume="/home/$USERNAME/c"
MOUNTED=0
# Looking for a directory on the mountpoint.
if [ -d $volume/backup ] ;
then
  echo 'mounted' >/dev/null
  MOUNTED=1
else
  echo 'Not mounted, mounting now..  First trying the XP share of C'
  mount -w -t cifs $mountpoint $volume -o user=$USERNAME,passwd={secret_Password},rw,nosetuids,noperm,dir_mode=0777,file_mode=0766
  if [ -d $volume/download ];
  then
    echo 'mounted XP'
    MOUNTED=1
else 
## To mount the linux side.
    mount -w -t cifs //192.168.1.1/h /home/raj/c -o user=$USERNAME,passwd={secret_Password},
rw,nosetuids,noperm,dir_mode=0777,file_mode=0766
    MOUNTED=1
    echo 'Trying to mount Linux'
    if [ -d $volume/backup ];
    then
      echo 'Successful found backup directory on Linux mount'
    fi
  fi
fi
export MOUNTED
I hope this gives you a starting point. I have to think about the un-mounting question when you log out. umount is a privileged command, and you have to run it as root.

- Raj
 
Old 10-18-2012, 04:21 PM   #3
Rupadhya
Member
 
Registered: Sep 2012
Location: Hoffman Estates, IL
Distribution: Fedora 20
Posts: 167

Rep: Reputation: Disabled
You could put some logout commands in the /etc/bash.logout or ~/.bash_logout for each individual user, but I haven't figured a way to switch to root user without prompting for a password.
- Raj
 
Old 10-19-2012, 12:12 PM   #4
adellaci
LQ Newbie
 
Registered: Nov 2010
Location: Maine, USA
Distribution: Ubuntu, Fedora, CentoOS
Posts: 2

Original Poster
Rep: Reputation: 0
Thank you Raj. I will try that tonight, but looking at the script you wrote, when i mounted it i could never be able write to it, but never thought to define what mode to mount directory and file. I'll Let you know.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is this the best way to auto-mount nfs to a certain directory? DJOtaku Linux - General 4 08-02-2012 09:47 AM
How can I set up to auto log into a user a/c voip4africa Linux - General 2 06-15-2012 10:21 AM
NFS share in fstab fails to mount, but where is the log? gumpish Linux - Software 7 08-19-2009 08:22 PM
RHEL 5.2 log locations to debug an NFS mount tongar Red Hat 8 08-12-2009 01:53 PM
auto mount to nfs home dir when user login to nis client lijianatusa Linux - Newbie 4 02-26-2009 12:38 AM


All times are GMT -5. The time now is 09:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration