# Upgrade ntpd from ports - fails to start up



## mrdans (Oct 10, 2013)

Hi all,

This is my first post here as I'm really stuck and desperately need help. I'm attempting the build a Samba 4 Active Directory and Domain Controller (AD DC) to replace an aging Windows 2000 Server, but I need NTP Version 4.2.6 running and it refuses to start. The default/currently installed version with FreeBSD 9.2-RELEASE is ntp-4.2.4p8. Only ntpd version 4.2.6 supports the necessary authentication extensions and needs to be compiled with NTP_SIGND.

I have installed a clean FreeBSD 9.2-RELEASE on a new HDD.

Adding the necessary information to the current config files rc.conf and ntp.conf and then running `# tail /var/log/messages` shows that ntpd is running but without NTP_SIGND:

```
ntpd: ntpd 4.2.4p5-a (1)
ntpd: configure: keyword "ntpsigndsocket" unknown, line ignored
ntpd: configure: keyword "mssntp" unknown, line ignored
```

Next I compiled ntp from the ports - `# cd /usr/ports/net/ntp && make install clean` and installed ntp-4.2.6p5_2 into the default directory. I then appended 
`# echo 'ntpd_program="/usr/local/bin/ntpd/"' >> /etc/rc.conf`
`# killall HUP ntpd`
`# ntpd`

Strangely, my addition to rc.conf was ignored as `# which ntpd && ntpd --version` still shows:

```
/usr/sbin/ntpd
ntpd - NTP daemon program - Ver. 4.2.4p8
```

So I terminate the running nptd and run the newly complied version directly `# /usr/local/bin/ntpd` and get:

```
# tail /var/log/messages
ntpd 4.2.6p5@1.2349-o Wed Oct  9 23:30:25 UTC 2013 (1)
kernel: pid 48815 (ntpd), uid 0: exited on signal 11 (core dumped)
```

The ports version installed refuses to start. No other version of ntpd is running at the same time. What am I missing here? Did I forget to configure something? I can't figure it out and have searched everywhere for a solution. Any help would be appreciated.

Thanks


----------



## ShelLuser (Oct 10, 2013)

mrdans said:
			
		

> Next I compiled ntp from the ports - `# cd /usr/ports/net/ntp && make install clean` and installed ntp-4.2.6p5_2 into the default directory.


First of all you're missing out on a very important step there: `# make config` or optionally when your port has many dependencies which also require configuration: `# make config-recursive`. If you don't use this command and are building a port for the first time it'll show up again, otherwise it simply gets on going with the current (possibly default) settings.

In this case not a big problem, I already noticed that NTP_SIGND is enabled by default, but even so the `make config` step is also an important one.



			
				mrdans said:
			
		

> I then appended cmd]# echo 'ntpd_program="/usr/local/bin/ntpd/"' >> /etc/rc.conf[/cmd]
> `# killall HUP ntpd`
> `# ntpd`


What did you do with ntpd_enable? That needs to be disabled or removed. Otherwise you risk starting both processes at the same time.

Also HUP to the already running process you basically restarted the current ntpd. And that was the one from the base system, not what you're after.

Try running `# /etc/rc.d/ntpd stop` instead. If you did make sure to disable the NTP "base daemon" then it will give you a warning. In that case issue onestop instead of stop. So make sure that no process is running.

Then look into /usr/local/etc/rc.d and use the appropriate script to start the port version.

It looks to me as if you're confusing the ports and the base system. It's really advisable to look into the FreeBSD handbook, in this case particularly chapter 12.7 which explains more about the whole rc structure.

In short; /etc/rc.d contains the scripts which administrate the services which are provided with the base system whereas /usr/local/etc/rc.d provides the scripts for everything you install through the ports collection.


----------



## junovitch@ (Oct 11, 2013)

It's a program, not a directory.

```
ntpd_program="/usr/local/bin/ntpd[highlight]/[/highlight]"
```

Remove the trailing slash and I would think you would be good.

As far as the other stuff.  The `# make config` and `# make config-recursive` might be a time-saver so you can set your options and walk away but there's nothing wrong with a one stop-shop `# make install clean`.  Setting the configuration is still implied if it's never been configured before.


----------



## mrdans (Oct 15, 2013)

*Replace ntp base version with one compiled from ports*

Thanks for the great responses and help. I appreciate that the base version of ntpd is not the same as the one I'm trying to install from the ports tree. This is definitely an issue I needed clarity on. The issue unfortunately still persists. I'm not so worried about `# make config` as the option I need to have is in the default installation.

Here are the issues that I'm still having:
1. the ntpd version that is installed from the ports does not come with any sort of startup script, therefore there is nothing in /usr/local/etc/rc.d/ to run. Invoking the `# service ntpd start` will start the base version of ntpd.
2. Adding `ntpd_enable="YES"` and `ntpd_program="/usr/local/bin/ntpd"` to /etc/rc.conf does not seem to start the version installed from ports. The result is just `# tail /var/log/messages`:
	
	



```
ntpd[50746]: ntpd 4.2.6p5@1.2349-o Tue Aug  6 10:08:43 UTC 2013 (1)
Oct 15 09:32:54 kernel: pid 50747 (ntpd), uid 0: exited on signal 11 (core dumped)
```

I suppose the questions I should be asking are:
1. How do I replace the base version of ntpd with the one installed from ports? Or at least have the version from ports run instead of the base version.
2. As there is no script in /usr/local/etc/rc.d/, can someone help me create a script to run the ports version of ntp as a service... and at startup? I have no experience with scripts.
3. What should I be putting in my /etc/rc.conf to tell FreeBSD to run the ports version of ntp that is installed in /usr/local/bin as it just defaults to the base version of ntp in /usr/sbin/.

Thanks again for any help.


----------



## junovitch@ (Oct 15, 2013)

1. That is correct.  Without getting into the technical depths of what you can read in rc() or `view /etc/rc.subr`, the /etc/rc.d/ntpd script will execute the appropriate NTP program.  Normally that is defined in /etc/rc.d/ntpd with the defaults of this.

```
name="ntpd"
command="/usr/sbin/${name}"
```

2. It doesn't start it but the version it tries to start is correct. Setting the following should be enough although see below, I had errors and had to set one additional options.  

```
ntpd_enable="YES"
ntpd_program="/usr/local/bin/ntpd"
```

You can check the default version.

```
/usr/sbin/ntpd --version
ntpd - NTP daemon program - Ver. 4.2.4p8
```

Versus the port version.

```
/usr/local/bin/ntpd --version
ntpd 4.2.6p5
ntpd 4.2.6p5@1.2349-o Tue Oct 15 17:49:44 UTC 2013 (1)
```

3.  Are you getting more output than just the one line you had posted?  This is the whole of what I got.  

```
Oct 15 17:18:55 client ntpd[778]: ntpd 4.2.4p5-a (1)
Oct 15 17:19:04 client ntpd[779]: time correction of 14402 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.
Oct 15 17:37:07 client kernel: pid 11721 (try), uid 0: exited on signal 10 (core dumped)
Oct 15 17:54:56 client ntpd[161]: ntpd 4.2.4p5-a (1)
Oct 15 17:55:05 client ntpd[162]: time correction of 14402 seconds exceeds sanity limit (1000); set clock manually to the correct UTC time.
Oct 15 17:56:17 client ntpd[198]: ntpd 4.2.6p5@1.2349-o Tue Oct 15 17:49:44 UTC 2013 (1)
Oct 15 17:56:17 client ntpd[199]: proto: precision = 5.866 usec
Oct 15 17:57:33 client ntpd[213]: ntpd 4.2.6p5@1.2349-o Tue Oct 15 17:49:44 UTC 2013 (1)
Oct 15 17:57:33 client ntpd[214]: proto: precision = 4.469 usec
```

I had to enable it to sync on start because the offset was so high.  The following three lines are exactly what worked on a fresh system installed with the ports version of NTP.  All I did is copy and paste from /etc/defaults/rc.conf into /etc/rc.conf and change as shown.

```
ntpd_enable="YES"                    # Run ntpd Network Time Protocol (or NO).
ntpd_program="/usr/local/bin/ntpd"   # path to ntpd, if you want a different one.
ntpd_sync_on_start="YES"             # Sync time on ntpd startup, even if offset is high
```

If that doesn't work then I'm a bit baffled.  If this was one of several programs exhibiting a signal 11 error than I may point to some sort of hardware problem.  You can search online for signal 11 and read all about it.  If this is the only program than I'm not sure.


----------



## usdmatt (Oct 16, 2013)

> Strangely, my addition to rc.conf was ignored as # which ntpd && ntpd --version still shows:



Just to clear a few things up about the above statement.

1) The /etc/rc.conf file configures the rc system, which controls service startup/shutdown. Enabled services *should* start/stop automatically with the system, or can be controlled manually as follows:


```
# service {service} start|stop             - preferred (both system & 3rd party services)
# /etc/rc.d/{service} start|stop           - start/stop a system service
# /usr/local/etc/rc.d/{service} start|stop - start/stop 3rd party service
```

Typing `ntpd` at the command line will *always* run the system version (assuming you haven't deleted it), regardless of the /etc/rc.conf settings. The shell will just search $PATH for the first ntpd it finds (system locations first) and run it. The same goes for `which`. It's to be expected that both these commands will find/run the base copy of ntpd, they have nothing to do with the rc system.

2) In the case of ntpd, as mentioned in the previous message you should only need to enable the ntpd service, and configure it to run your ntpd executable rather than the default system one. One post mentioned removing 
	
	



```
ntpd_enable="YES"
```
 which is not correct in this case - you still want the local system ntpd script to run, but with your newer executable, configured with the ntpd_program variable.

It looks like your main issue is that the ports ntpd is crashing, although I can't provide any help on why that is. May be worth trying to run it with one of the debugging options enabled.


----------



## mrdans (Oct 22, 2013)

Thanks for all the help. Indeed, my confusion was with the ports version of ntpd and the base/system version. Once I finally understood the processes and the  differences between the two, I have successfully got the ports version running without crashing.


----------

