Issues with NFS mounting on boot

Today, I ran into an odd issue where NFS mounts were not being mounted at boot, despite having all of the proper settings in the /etc/fstab entry. There were no errors of note in server logs but I was able to determine that the issue was related to the fact that the server was trying to mount the nfs mount prior to networking coming up. To resolve this, I found the two entries in the /etc/rc3.d/ directory that corresponded to networking and network filesystems:

[[email protected] rc3.d]# ll | grep netfs
lrwxrwxrwx 1 root root 15 May 21 14:00 K75netfs -> ../init.d/netfs
[[email protected] rc3.d]# ll | grep network
lrwxrwxrwx 1 root root 17 May 21 09:10 S10network -> ../init.d/network

Once I located those two files, it was clear that the problem lay in the fact the server was running K75netfs prior to S10network due to rc.d’s habit of starting services in alphabetical order. To resolve the problem, I located an empty “slot” after S10 to move the K75netfs symlink to:

[[email protected] rc3.d]# mv K75netfs S86netfs

By doing this, the network and netfs rc.d scripts are now in the proper order:

[[email protected] rc3.d]# ll | grep network
lrwxrwxrwx 1 root root 17 May 21 09:10 S10network -> ../init.d/network
[[email protected] rc3.d]# ll | grep netfs
lrwxrwxrwx 1 root root 15 May 21 14:00 S86netfs -> ../init.d/netfs

I did a test reboot to confirm and sure enough, when the server was accessible via networking, the nfs mount was in place and accessible as expected. I thought I’d make a post on this for anyone else having the same issue, as google was not too helpful for me.

Allocate x IPs to OpenVZ VEs

I ran into an interesting issue today where we had a client migrating to us that needed us to allocated X IPs to each VPS on a node he had with us. X ranged from 1 IP to up to 12 per VE so I wrote a script that took three input files (one with available IPs [newips], one with VEIDs [veids], and one with the number of IPs each VEID was allocated [numips]) and doled out the IPs as needed. Here is the result:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/bin/bash
 
let r=1
let k=1
 
for i in `cat veids`
do
    numips=$(sed -n "$k"p numips)
        for (( c=1; c<=$numips; c++ ))
          do
                ip=$(sed -n "$r"p newips)
                echo "Add $ip to $i"
                vzctl set $i --ipadd $ip --save
                let r=r+1
        done
    let k=k+1
done

Hopefully this will help any others who run into a similar issue.

Have a great day!