# ntpd not starting after upgrade to 12.0-RELEASE



## lbol (Dec 16, 2018)

after upgrading from 11.2-RELEASE to 12.0-RELEASE ntpd(8) won't start.
The error message in /var/log/messages is:

```
Dec 16 14:55:41 ludger-thinkpad root[2017]: /etc/rc.d/ntpd: WARNING: failed to start ntpd
```
When I execute `/etc/rc.d/ntpd start` manually I get

```
Starting ntpd.
su: unknown login: ntpd
/etc/rc.d/ntpd: WARNING: failed to start ntpd
```
The ntpd user is included in /etc/passwd

```
ntpd:*:123:123:NTP Daemon:/var/db/ntp:/usr/sbin/nologin
```
Any idea what I'm missing?


----------



## rigoletto@ (Dec 16, 2018)

Did you *carefully* run `mergemaster -p`? The ntpd user is new. Mine look like this:


```
ntpd:*:123:123::0:0:NTP Daemon:/var/db/ntp:/usr/sbin/nologin
```

Btw, I don't have how to test it because I don't have ntpd(8) installed.


----------



## meine (Dec 16, 2018)

Check your /etc/rc.conf for 
	
	



```
# NTP synchronize system clock
ntpd_enable="YES"
```

Your /etc/passwd is the same as here and all works as intended.

For testing, see https://forums.freebsd.org/threads/testing-ntp.41874/">


----------



## Eric A. Borisch (Dec 16, 2018)

Is there also an ntpd entry in /etc/group?


----------



## obsigna (Dec 16, 2018)

I had the same issue. Here, mergemaster added the ntpd user to /etc/passwd, but for some reason spoiled the password database. I simply ran `/usr/sbin/pwd_mkdb -p /etc/master.passwd` and this resolved the issue.

After updating another system, the old ntpd.pid file owened by the 11.2 root user was for some reason left in place and prevented the new ntpd starting up, because the user ntpd had no write permissions to the old .pid file (owned by root). I needed to delete said old .pid file manually and that resolved that issue.


----------



## lbol (Dec 16, 2018)

Thx, rebuilding /etc/master.passwd did the trick


----------



## Quarter Wave Vertical (Mar 10, 2019)

I have a similar situation to that of the original poster.

Prior to the upgrade, I had:

`ntpd_enable="YES"`

in /etc/rc.conf .

I upgraded my system to 12.0 with the following:

`freebsd-update fetch`
`freebsd-update install`
`freebsd-update -r 12.0-RELEASE upgrade`

I didn't run `mergemaster` at any time, nor do I recall any mention of it during the upgrading procedure.  I also re-installed all the packages and ports as required by the process.

Can I still get ntpd to run?


----------



## obsigna (Mar 10, 2019)

Quarter Wave Vertical said:


> ...
> I upgraded my system to 12.0 with the following:
> `freebsd-update fetch`
> `freebsd-update install`
> ...



After the upgrade command, there should have been more 3 install commands interlaced with reboots and before the final install one, rebuilding of all 3rd party software. Did you forgot to inform these steps, or were these simply not executed yet?

I wrote down a brief upgrade log which worked for all of the systems which I maintain:





						FreeBSD 12.0 has been released - an update log
					






					obsigna.com


----------



## Quarter Wave Vertical (Mar 11, 2019)

obsigna said:


> After the upgrade command, there should have been more 3 install commands interlaced with reboots and before the final install one, rebuilding of all 3rd party software. Did you forgot to inform these steps, or were these simply not executed yet?
> 
> I wrote down a brief upgrade log which worked for all of the systems which I maintain:
> 
> ...


Yes, there were a number of times in which I was required to reboot the machine and then run:

`/usr/sbin/freebsd-update install`

Towards the end, all the packages and, I believe, ports were rebuilt.

The command:

`pwd_mkdb -p /etc/master.passwd` ,

however, doesn't ring a bell with me.  Maybe I wasn't paying attention or something like that.  Would that have been the step that I missed?  If so, can I run it and fix my problem with ntpd?

Thanks.


----------



## Quarter Wave Vertical (Mar 17, 2019)

Quarter Wave Vertical said:


> Yes, there were a number of times in which I was required to reboot the machine and then run:
> 
> `/usr/sbin/freebsd-update install`
> 
> ...


It looks like I might have fixed the problem.  I ran:

`pwd_mkdb -p /etc/master.passwd`

and, afterward, changed the ownership of:

/var/ntp/ntpd.pid

to ntpd.

I set my watch to the WWV time signal and checked it against the computer's clock.  Both are synchronized.

As it turns out, this problem is a bug with `freebsd-update upgrade`, though not, it seems, with a fresh installation of FreeBSD 12.0.


----------



## Quarter Wave Vertical (Mar 17, 2019)

obsigna said:


> After the upgrade command, there should have been more 3 install commands interlaced with reboots and before the final install one, rebuilding of all 3rd party software. Did you forgot to inform these steps, or were these simply not executed yet?
> 
> I wrote down a brief upgrade log which worked for all of the systems which I maintain:
> 
> ...


Your link to your upgrade log was quite helpful.  Thank you.


----------



## cherdt (Mar 29, 2019)

Thanks for the tips everyone. I ran into the same issue and I have ntpd running again now.

However, it appeared that for some reason the /var/db/ntp/ntpd.pid file does not contain the correct PID:

`$ ps aux | grep [n]tpd
ntpd    24350   0.0  0.2 15856 15928  -  Ss   15:10       0:00.18 /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -f /var/db/ntp/ntpd.drift`

`$ cat /var/db/ntp/ntpd.pid 
39781`

Which also leads to an incorrect status:

`$ service ntpd status
ntpd is not running.`

The ntpd.pid and ntpd.drift appear to have the correct permissions, and the ntpd.pid file is updated when I restart the service -- just not with the PID that is actually running.

I killed the running ntpd process and deleted the ntpd.pid file and started ntpd again, e.g.:

`$ sudo service ntpd start`

Now the PID matches, status is reported correctly, etc. Just thought I'd mention it in case anyone else is running into the same thing.


----------



## vrqq (May 2, 2022)

FreeBSD 13.0-Relase, after ntpd enabled, the permission of /var/db/ntp/ntpd.pid is `root:ntpd`" instead of `ntpd:ntpd`, this cause that the service always said "ntpd is not running", but it actually running.
Using this command to fix it:

`# chown ntpd:ntpd /var/db/ntp/ntpd.pid`


----------

