29.03.2024, 14:01 UhrDeutsch | English
Hallo Gast [ Registrierung | Anmelden ]

Nfs-Kernel-Server Howto


I wanted to connect my laptop and my desktop computer for exchanging files.
Not a real network, just for copying files from one to the other.

Someone told me a, supposedly, simple solution: the NFS-kernel-server.
And as I want you to really have it simple, I wrote down how to manage that.
Lets go.

My laptop and desktop are both connected to a router, which gives them the IPs:
192.168.xx.xx and 192.168.xx.xy

I needed the following:
  1. The IPs for telling /etc/exports who should deal with whom....
  2. a running nfs-kernel-server that is like so many things started by /etc/init.d/xx start
  3. the portmap daemon has to run too, if not already active
  4. mount-points, where I can find the data of the respective computers.

In my case I decided to make "/mnt/desktop" on the notebook for the data of the desktop
and "/mnt/notebook" for the notebooks data on the desktop. As su on the desktop I did:
mkdir /mnt/notebook
// and then changed to the notebook, and did the following: 
mkdir /mnt/desktop


I found that the connection unnecessarily slows down my systems at boot and shutdown.
So I made a little script for starting and stopping this service only when i need it:
#!/bin/bash
if [ $(id -u) != 0 ]; then
echo Error: You must be root to run this script!
exit 1
fi
cat <<EOT > /etc/exports
/  192.168.xx.xx(rw,no_root_squash,no_subtree_check,sync) 192.168.xx.xy(rw,no_root_squash,no_subtree_check,sync)
EOT

# this line is needed only once if you don't need to delete /etc/exports  
# so you can do that manually and take out the line here
# for a CD or poormans install you would need it
echo exports set
/etc/init.d/portmap start # (if it was not running already)
/etc/init.d/nfs-kernel-server start
echo NFS-Server startet
mount -t nfs 192.168.xx.xy:/ /mnt/notebook
echo Notebook mounted 


This is the script I run on my desktop. I've named it nfsstart, made it executable with chmod +x and copied it to /usr/local/bin/ . Now as su in a shell I simply do nfsstart and it would run.

As for the laptop it does not know about the script that I made for it too. Only the sequence of the IPs in line seven is changed and instead of "notebook", "desktop" is mounted using it's IP.
The echo-commands I just did is to see what is happening.

The first lines in full, are stolen from Kano's scripts, from "#" to "fi", it controls if I did the script as su (a must).

If I don't need the connection any more I stop the connection. For that I've created the script nfsstop, as follows:
#!/bin/bash
if [ $(id -u) != 0 ]; then
echo Error: You must be root to run this script!
exit 1
fi
umount /mnt/notebook
echo Notebook umounted
# if you need portmap, don't stop it
/etc/init.d/portmap stop
/etc/init.d/nfs-kernel-server stop
echo Kernel Server stopped


Here the difference between the files, on both computers, is the umount-line only.

This script is also made executable and copied to /usr/local/bin/ ready to be used when I do nfsstop as su.

The names of the little "programs" are of your choice. Only don't give them a name already used by another program or script. Such would cause problems.

Once again, a rerun:
  1. give the computers a mountpoint (both should have one, if you want a connection in both directions)
  2. edit the scripts to put in your own IPs and mountpoints
  3. make the scripts executable and copy or move them to /usr/local/bin/

That's it. I had to run the script twice on that computer I started with, as the connection to the second was not yet possible, as the second computer at that time did not know about that. The scripts have to be run on both computers.


Two days later
(for Poorman's Install or from CD and a persistent Home
It is easily done if you have installed a program with Kano's scripts.
I had Opera installed that way. I had it in my /home/knoppix folder.
The main folder is /home/knoppix/dist.
Inside it you will find the /home/knoppix/dist/bin/ where you have to put the executable files.
The mountpoints should also be in your persistent home now, as when booting you would not have them anymore in /mnt.

So I changed in the scripts /mnt to /home/knoppix and find the content of my other computer now in /home/knoppix/desktop respectively /home/knoppix/notebook.

Just a tip, if you have a /home/knoppix/dist/bin anyways, you can add your own scripts there executable and start them as a simple command from the shell.


Native english people, please be so kind as to check this howto.
XML Revisions of $tag
Seiten-History :: Letzter Editor : bluewater :: Eigentümer : DerEinzigWahreMipooh ::
Powered by pnWikka 1.0
 
 
Deutsch | English
Logos and trademarks are the property of their respective owners, comments are property of their posters, the rest is © 2004 - 2006 by Jörg Schirottke (Kano).
Consult Impressum and Legal Terms for details. Kanotix is Free Software released under the GNU/GPL license.
This CMS is powered by PostNuke, all themes used at this site are released under the GNU/GPL license. designed and hosted by w3you. Our web server is running on Kanotix64-2006.