Mounting NFS after boot

Post here if you are a new Porteus member and you're looking for some help.
Post Reply
rgroner
Black ninja
Black ninja
Posts: 58
Joined: 23 Oct 2014, 14:23
Distribution: Porteus 3.0.1
Location: U.S.

Mounting NFS after boot

Post#1 by rgroner » 18 Dec 2014, 16:53

I am able to mount the remote system and directory just fine. So I put that into the /etc/fstab file. Rebooted...not there. I was beginning to question why I was in Always Fresh mode when I finally read the top of the fstab file...it's always regenerated at reboot. Ah. So that's why my stuff was disappearing. It says to put my mount changes in /etc/rc.d/rc.local or sysvinit scripts.

I put the mount command in rc.local, but upon reboot, it was not mounted. I then executed the rc.local file, and it mounted correctly. So I'm wondering if perhaps the network had not yet been established before the mount command happened?

I'm somewhat surprised that searches don't reveal this to be a common problem. Am I going about this the wrong way? Is it trivially easy to do and I'm just missing it?

Mount cmd:

mount -t cifs \\\\WindowsSys\\my_dir /localLogs -o user,uid=500,rw,suid,username=u,password=p

User avatar
francois
Contributor
Contributor
Posts: 5081
Joined: 28 Dec 2010, 14:25
Distribution: kde xfce porteus manjaro kubun
Location: Enfin l'été, le changement climatique attendu: le soleil.

Re: Mounting NFS after boot

Post#2 by francois » 18 Dec 2014, 18:13

Do you work in always fresh mode or with the saves cheatcode in your grubloader instructions?
http://www.porteus.org/tutorials/26-gen ... -them.html
Voltaire: Le mieux est l'ennemi du bien.

rgroner
Black ninja
Black ninja
Posts: 58
Joined: 23 Oct 2014, 14:23
Distribution: Porteus 3.0.1
Location: U.S.

Re: Mounting NFS after boot

Post#3 by rgroner » 18 Dec 2014, 18:25

I'm not working in always fresh, I have saves set to the default (porteus/changes). And for all other things, saves works fine. But the fstab file is regenerated each boot, regardless of saves, so however I am to mount the NFS drive, it can't be that way.

User avatar
brokenman
Site Admin
Site Admin
Posts: 5574
Joined: 27 Dec 2010, 03:50
Distribution: Porteus v3.2rcX all desktops
Location: Brazil
Contact:

Re: Mounting NFS after boot

Post#4 by brokenman » 18 Dec 2014, 18:33

Use /etc/rc.d/rc.local or a sysvinit script to inject the line into fstab.
How do i become super user?
Wear your underpants on the outside and put on a cape.

rgroner
Black ninja
Black ninja
Posts: 58
Joined: 23 Oct 2014, 14:23
Distribution: Porteus 3.0.1
Location: U.S.

Re: Mounting NFS after boot

Post#5 by rgroner » 18 Dec 2014, 18:49

It says to do that in the top of the fstab file...and that is what I've been trying...but that is what I have trouble getting done.

I don't know how to "inject" this into the fstab file from rc.local. I just tried doing the "mount" command in there...is that the same thing? I put the line in rc.local and rebooted...and it did not work. But when I simply executed rc.local on the command prompt, it worked. So, the mount command I am using WORKS, but does not appear to work in rc.local.

Is there a log somewhere that might indicate what the problem was? I checked dmesg and it did not indicate anything had tried to run in rc.local and could not.

I checked the /etc/fstab file after I had rebooted and no new lines were added to it via the mount command I had put in rc.local.

rgroner
Black ninja
Black ninja
Posts: 58
Joined: 23 Oct 2014, 14:23
Distribution: Porteus 3.0.1
Location: U.S.

Re: Mounting NFS after boot

Post#6 by rgroner » 18 Dec 2014, 19:12

Ok, I was able to redirect the output of rc.local to a log file, and see that the reason the mount command is failing is because it can't resolve the address. I believe that the command in rc.local is executing before the network is technically "up".

Is there a delay command I need to use?

I still find it hard to believe no one else has ever tried to mount an NFS upon boot (at least based on search results, no one has ever tried, or no one had any problems doing it!)

rgroner
Black ninja
Black ninja
Posts: 58
Joined: 23 Oct 2014, 14:23
Distribution: Porteus 3.0.1
Location: U.S.

Re: Mounting NFS after boot

Post#7 by rgroner » 18 Dec 2014, 19:22

Ok...by adding a "sleep 10" command before the mount command, it now works. But doing this roughly doubles the boot time. :no: There goes the benefit of Porteus' quick booting.

Soooo, I think what I'm going to have to do is simply do the mount command at the beginning of the test script. The network will have come up by then, and if the mount fails, I can just go to a local directory instead. It's not flashy, but I don't see how else to get the mount command to happen without un-necessarily delaying system boot.

User avatar
fanthom
Site Admin
Site Admin
Posts: 4618
Joined: 28 Dec 2010, 02:42
Distribution: Porteus Kiosk
Location: Poland, currently - Cork, IE
Contact:

Re: Mounting NFS after boot

Post#8 by fanthom » 18 Dec 2014, 21:42

you can send the code to the background through rc.local:

Code: Select all

#!/bin/sh

(
sleep 20
mount xxx
) &
this way it wont slow down booting.
Please add [Solved] to your thread title if the solution was found.

rgroner
Black ninja
Black ninja
Posts: 58
Joined: 23 Oct 2014, 14:23
Distribution: Porteus 3.0.1
Location: U.S.

Re: Mounting NFS after boot

Post#9 by rgroner » 19 Dec 2014, 13:37

Excellent, thank you! :Yahoo!:

Post Reply