intall nfs via ipkg and configuration

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

intall nfs via ipkg and configuration

Post by priestnot » Fri Nov 21, 2014 1:40 pm

Hello did any one ever installed nfs on lacie network space 2 via ipkg and configurated it so that it is possible to mount a user share on a client machine?

Can please some one give some pointers in how to do that?

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Sat Nov 22, 2014 8:03 pm

Ok I got it...

I have installed nfs server with ipkg:

Here are the instructions:

Install ipkg: (you can use what ever method you like i use mine)

Code: Select all

[root@ns2 ~]# feed=http://ipkg.nslu2-linux.org/feeds/optware/cs08q1armel/cross/stable
[root@ns2 ~]# ipk_name=`wget -qO- $feed/Packages | awk '/^Filename: ipkg-opt/ {print }'`
[root@ns2 ~]# wget $feed/$ipk_name
[root@ns2 ~]# tar -xOvzf $ipk_name ./data.tar.gz | tar -C / -xzvf -
[root@ns2 ~]# mkdir -p /opt/etc/ipkg
[root@ns2 ~]# echo "src cross $feed" > /opt/etc/ipkg/feeds.conf

Install porpart and unfs3 via ipkg

Code: Select all

[root@ns2 ~]# ipkg install portmap
[root@ns2 ~]# ipkg install unfs3 
Configure nfs3 (I created a share in /shares/nfsshare do it were ever you like)

Code: Select all

[root@ns2 ~]# mkdir /shares/nfsshare
[root@ns2 ~]#  echo "/shares/nfsshare (rw, no_root_squash)" >> /etc/exports
Test it
Lacie NAS server:

Code: Select all

[root@ns2 ~]# cd /opt/sbin
[root@ns2 ~]# ./portmap
[root@ns2 ~]# ./unfsd
Test it
Client:

Code: Select all

[root@ns2 ~]# mount 192.168.1.100:/shares/nfsshare /mnt/lacieshare/
write and read stuff to test it.
Last edited by priestnot on Sat Nov 22, 2014 8:05 pm, edited 1 time in total.

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Sat Nov 22, 2014 8:04 pm

Now I just need some help on getting this to run on boot

I tried a bunch of option of initng is there any ideias?

I created in /etc/initng the file:
startDaemonNFS.i

Code: Select all

daemon startDaemonNFS {
	#require_network;
	forks;
	exec daemon = '/usr/bin/pyhton /root/startDaemonNFS.py';
	daemon_stops_badly;
}
And added the following line to the end of the file /etc/initng/runlevel/default.runlevel

Code: Select all

startDaemonNFS

/root/startDaemonNFS.py:

Code: Select all

import os
import time
import subprocess

#time.sleep(5)

portmap_pid = 0
unfsd_pid = 0

print "Start portmap..."
portmap_obj = subprocess.Popen(["/opt/sbin/portmap"], stdout=subprocess.PIPE)
portmap_pid = portmap_obj.pid
print "\tportpam started with pid = " + str(portmap_pid)

time.sleep(5)

print "Start unfsd..."
unfsd_obj = subprocess.Popen(["/opt/sbin/unfsd"], stdout=subprocess.PIPE)
unfsd_pid = unfsd_obj.pid                                                   
print "\tunfsd started with pid = " + str(unfsd_pid)

while True:
	print "Check if is every thing ok???"
	time.sleep(10)	
This way if I trey to run the initng daemon it gives me:

Code: Select all

root@Metronome initng]# ngc -u startDaemonNFS
 initNGControl (0.6.10.2 ) by Jimmy Wennlund http://www.initng.org/
Starting service "startDaemonNFS", hang on..

Service "startDaemonNFS" have failed!


[root@Metronome initng]# 

I already runned the ngc -z startDaemonNFS and ngc -d startDaemonNFS but nothing changes.

Does any one have any ideas?
Last edited by priestnot on Sat Nov 22, 2014 8:16 pm, edited 1 time in total.

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Sat Nov 22, 2014 8:16 pm

I tried to change some stuff but I still did not work:

Code: Select all

service startDaemonNFS {
	
	script start = {
		require_network;
		/usr/bin/pyhton /root/startDaemonNFS.py;
	
		exit 0;
	}
	
	script stop = {
		#kill $(ps |grep -v grep |grep 'startDaemonNFS.py' |awk '{print }');
			
		exit 0;
	}
}
but when I try to run in it gives me:

Code: Select all

[root@Metronome initng]# ngc -u startDaemonNFS   
 initNGControl (0.6.10.2 ) by Jimmy Wennlund http://www.initng.org/
Service "startDaemonNFS" previously failed (DAEMON_FAIL_START_LAUNCH),
it needs to be zaped "ngc -z startDaemonNFS", so initng will forget the failing state before you are able to retry start it.
I already runned the ngc -z startDaemonNFS and ngc -d startDaemonNFS but nothing changes.

kea
Posts: 39
Joined: Fri Sep 16, 2011 6:18 am

Re: intall nfs via ipkg and configuration

Post by kea » Mon Nov 24, 2014 2:17 pm

Hi,

Your script looks a little bit mangled, I where fighting with setting up a "local" script a couple of weeks ago and I wrapped together the following which is working.

I have the "need = samba/smbd" in there as I want to be sure the directories are mounted before making my mount.

By the way, why did you install nfs from ipkg and not using the nfs which is native on the box? Guess it would be enough to add "nfs" to runlevels default and maybe tweak the exports file? I haven't checked further into this as I haven't had the need for a nfs server.

Code: Select all

#!/sbin/itype

service local {
need = samba/smbd;
    script start = {
            [ -d /media/internal_6/shares_manual ] || sleep 60
            /bin/mount /media/internal_6/shares_manual/foton /shares_manual/fotos
            # Copy static samba passwd into place
            /bin/cp /etc/samba/private/smbpasswd.static /etc/samba/private/smbpasswd
            exit 0
    };
    script stop = {
            /bin/umount /shares_manual/fotos
            exit 0
   };

}
KeA

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Mon Nov 24, 2014 6:47 pm

Hello thanks for your answer

I will try to use your script and see if it works.
I also have an idea tahat I might have a problem with PID of the programs that I am runnig.
By the way, why did you install nfs from ipkg and not using the nfs which is native on the box? Guess it would be enough to add "nfs" to runlevels default and maybe tweak the exports file? I haven't checked further into this as I haven't had the need for a nfs server.
Herm I have a NEtwork Space 2 with the original firmware version 1.2.9 I think that it does not have a nfs server.
CAn some one please confir this. And if it has wer is the export file so I can configure it?

kea
Posts: 39
Joined: Fri Sep 16, 2011 6:18 am

Re: intall nfs via ipkg and configuration

Post by kea » Mon Nov 24, 2014 8:31 pm

Ok, I have firmware 2.0.5 on my oldest lacie and 2.2.8 on the newer one.

Both are easily rootable via the trick with symlinks on a ext2 formated usb flash drive.

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Mon Nov 24, 2014 8:44 pm

Ok, I have firmware 2.0.5 on my oldest lacie and 2.2.8 on the newer one.
And are they Network Space 2 lacie NAS?
And they have nfs server?

kea
Posts: 39
Joined: Fri Sep 16, 2011 6:18 am

Re: intall nfs via ipkg and configuration

Post by kea » Tue Nov 25, 2014 11:20 am

Yes, the older one is a Network Space II and the newer one is a Network Space II "lite".

They do have nfs, but it's not possible to enable it from the web console.

I have shared filesystems by tweaking the exports file and starting the nfs service by using what's on the box.

Starting nfs on lacie

Code: Select all

# Setup the exports file
[root@Lacie02 ~]# echo "/shares/media    192.168.0.0/255.255.255.0(rw)" > /etc/exports


# List the exports, no output as nfs is not running at this point
[root@Lacie02 ~]# exportfs

# Start nfs
[root@Lacie02 ~]# ngc --start nfs
 initNGControl (0.6.10.2 ) by Jimmy Wennlund http://www.initng.org/
Starting service "nfs", hang on..

Service "nfs" is now in state: WAITING_FOR_START_DEP


# Running exportfs shows that it's shared
[root@Lacie02 ~]# exportfs
/shares/media               192.168.0.0/255.255.255.0
Mounting from a Raspberry Pi

Code: Select all

# showmount to list exported filesystems
root@raspberry:~# showmount --exports lacie02
Export list for lacie02:
/shares/media 192.168.0.0/255.255.255.0

# Mounting
root@raspberry:~# mount -t nfs lacie02:/shares/media /tmp/mnt/

# df of mounted fs
root@raspberry:~# df /tmp/mnt/
Filesystem            1K-blocks      Used Available Use% Mounted on
lacie02:/shares/media 974620800 758355232 216265568  78% /tmp/mnt
Last edited by kea on Tue Nov 25, 2014 11:36 am, edited 1 time in total.

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Tue Nov 25, 2014 11:36 am

And in the NS2 2.0.5 do you have nfs installed with ths original firmware?

kea
Posts: 39
Joined: Fri Sep 16, 2011 6:18 am

Re: intall nfs via ipkg and configuration

Post by kea » Tue Nov 25, 2014 12:09 pm

The code snippet above where from the 2.0.5 with nfs pre-installed in the firmware.

I have a old note saying that I had to run "mkdir /var/lib/nfs/v4recovery" on the 2.2.8 box, but I don't remember the reason, nfs failed to start due to the directory missing, but I can't recall if this where the client or server requiring this.

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Tue Nov 25, 2014 2:39 pm

Then maby the nfs was introduced in a newer version of the NS2 because I cannot find the nsf executable anywere.

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Wed Nov 26, 2014 10:07 am

Hello I managed to make the portmap and unfsd start on boot.

The problem is that if it starts on boot the shares are not accessible. But if I kill the unfsd and run it by hand the shares work.
I know for shure both progrmas (portmap and unfsd) are runing after boot.

I think the problem is that in boot the unfsd does not recognize the /etc/exports file and wen it loads up it does not have any shares,

Is there any way to avoid this?

kea
Posts: 39
Joined: Fri Sep 16, 2011 6:18 am

Re: intall nfs via ipkg and configuration

Post by kea » Wed Nov 26, 2014 10:36 am

Is the directory you are trying to export mounted at the time when you start up the unfsd?

Most of the mounts are happening quite late on the lacie as they are mounted by the unicorn service, that's the reason why I have the "need = samba/smbd;" in my local.i

priestnot
Posts: 47
Joined: Sun Mar 20, 2011 3:44 pm

Re: intall nfs via ipkg and configuration

Post by priestnot » Wed Nov 26, 2014 1:00 pm

In the scritp that boots the unfsd I put tha same line as you "need = samba/smbd;" SO that it only starts after the samba server

Post Reply