Page 1 of 1

Mounting NFS after boot

Posted: 18 Dec 2014, 16:53
by rgroner
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

Re: Mounting NFS after boot

Posted: 18 Dec 2014, 18:13
by francois
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

Re: Mounting NFS after boot

Posted: 18 Dec 2014, 18:25
by rgroner
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.

Re: Mounting NFS after boot

Posted: 18 Dec 2014, 18:33
by brokenman
Use /etc/rc.d/rc.local or a sysvinit script to inject the line into fstab.

Re: Mounting NFS after boot

Posted: 18 Dec 2014, 18:49
by rgroner
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.

Re: Mounting NFS after boot

Posted: 18 Dec 2014, 19:12
by rgroner
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!)

Re: Mounting NFS after boot

Posted: 18 Dec 2014, 19:22
by rgroner
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.

Re: Mounting NFS after boot

Posted: 18 Dec 2014, 21:42
by fanthom
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.

Re: Mounting NFS after boot

Posted: 19 Dec 2014, 13:37
by rgroner
Excellent, thank you! :Yahoo!: