Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm using an Ubuntu 12.04 (Server) VM as a development web server. I keep the served files on the VM host, therefore Apache uses NFS mounted directories for DocumentRoot To keep things as automated, I have Apache set to start on boot.

  • I have no problem with automounting NFS at boot.
  • I have no problem with starting Apache at boot.

The problem: mountall starts after upstart fires up Apache.

After fiddle-farting around with upstart and initctl I came up with a hack that works -- but is certainly not ideal -- nor portable.

/etc/fstab

nfs_server:/    /mnt/nfs_server  nfs4   _netdev,noauto  0   0

/etc/init.d/apache2
The following was inserted at the top beneath the INIT INFO section:

if [ ! -s "/var/www/default/index.php" ]; then
    echo -n "  Mounting NFS and Samba shares...."
    mount nfs_server:/
    result=$?
    if [ 0 -ne $result ]; then
        echo "  ERROR. mount returned $result";
    else
        echo "    [ OK ]";
    fi
fi
...

Otherwise, the script is what was installed originally ( see default file here ).

Notes

  1. I've tried using mountall instead of mounting the NFS share by name.
    • This results in other error messages (notably, swapon didn't mount my swap partition)
    • (however) upon final startup, everything seems fine.
  2. This VM will be zipped up and given to other developers. Some may mount using NFS, some may use Samba.
share|improve this question

1 Answer 1

One way to solve this is to change the order that these things load by modifying the order the init script calls them. There may be other (easier) ways to do this, but the bare metal way would be to -

  1. Find the runlevel the server is running on by issuing the command (as root) "runlevel".
  2. Go to /etc/rcX.d where X is the runlevel number you are in.
  3. You will see a whole lot of symlinks in that directory - they will typically be in the form SxxNAME, where "S" means start, xx is the order - earlier scripts run first - and name is the name of the script this links to in etc/rc.d. Rename the apache script to have a higher number then the nfs script.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.