Connecting laptop to sever

Nils Kassube kassube at gmx.net
Sun Aug 3 19:16:45 UTC 2008


John wrote:
> Nils Kassube wrote:
> > What is the error message if you use this command
>
> sudo mount -t nfs server.lan:/some/exported/path /mnt
>
> Normally when I run my connection script, it just hangs, even if I try
> terminal mode. What I did for this test was to open a terminal window
> and paste one of the commands direct from the script under sudo. I'm
> pleased to say it worked!

Now that's at least a good start :)

> This now leads to another question - how do I ensure that a script run
> from my user desktop only runs as root?

In your script you could check if $UID is 0. Something like

if [ "$UID" != "0" ]; then
  echo "Run $0 as root."
  exit 1
fi

near the start of your script.

> Then how do I ensure that my mounted files are writeable?

There are several conditions which all must match:
- The files must be writeable on the server.
- The files must be exported rw.
- The UID / GID of the writing process must match the file permissions 
(after UID / GID mapping).
- The share must be mounted rw.
- Did I miss anything?

I don't know about your particular problem, but usually my problem is the 
different UID for a particular user on the server and client machines. 
Ubuntu starts with UID 1000 for the first user, IIRC SUSE starts with 
500.

Probably you already read the man pages for exports and mount. But did you 
also read these pages? Maybe there you find something useful:
<https://help.ubuntu.com/community/SettingUpNFSHowTo>
<https://help.ubuntu.com/community/NFSv4Howto>


Nils




More information about the ubuntu-users mailing list