# Recommended settings for chrony on KVM

**URL:** https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368
**Category:** Uncategorized
**Created:** [April 28, 2022, 9:53pm UTC](https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368 "2022-04-28T21:53:18Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![mibere](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mibere](https://community.ntppool.org/u/mibere)
#### Post date: [April 28, 2022, 9:53pm UTC](https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368/1 "2022-04-28T21:53:18Z")

</div>

Hello,

I operate chrony 4.2 on Debian 11 in a KVM virtualized system with 4 dedicated CPU cores (KVM host is a AMD EPYC 7452).

Are there any recommended settings for the operating system and/or chrony in such an environment?  
To name a few chrony settings, what about _filter_ / _minsamples_ / _clockprecision_?

The reason for my question is: I’ve noticed that the values in the columns _NP_ and _NR_ of chronys’ _sourcestats_ command conspicuously often fall back to the minimum values (6|3), and they also rarely get high.

---

<div class="post-metadata">

### Author: ![Bas](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/bas/32/465_2.png) [@Bas](https://community.ntppool.org/u/Bas)
#### Post date: [April 30, 2022, 6:15pm UTC](https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368/2 "2022-04-30T18:15:31Z")

</div>

You can not control the local-system-clock from a virtual system.

Just run it with server or pool params and it will work fine.

---

<div class="post-metadata">

### Author: ![mibere](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mibere](https://community.ntppool.org/u/mibere)
#### Post date: [May 4, 2022, 9:21pm UTC](https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368/3 "2022-05-04T21:21:21Z")

</div>

> [@Bas](#):
>
> You can not control the local-system-clock from a virtual system.

You’re right. I use a dedicated server now, and maybe you have a hint for me, I really don’t get it…

The server has a Intel i210 NIC, _ethtool -T_ shows

```auto
Capabilities:
        hardware-transmit
        software-transmit
        hardware-receive
        software-receive
        software-system-clock
        hardware-raw-clock
PTP Hardware Clock: 0
Hardware Transmit Timestamp Modes:
        off
        on
Hardware Receive Filter Modes:
        none
        all

```

After starting the system there’s a _/dev/pps0_ and _/dev/ptp0_.  
Running chrony with _hwtimestamp eth0_ reports _Enabled HW timestamping on eth0_.

What I don’t know and really don’t understand now, should or do I have to install the package _linuxptp_ to use

- ptp4l ?
- phc2sys ?

And even without _linuxptp_ installed, is it helpful/recommended to configure something like this in chrony:

`refclock PHC /dev/ptp0 pps`

---

<div class="post-metadata">

### Author: ![apuls](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/apuls/32/1467_2.png) [@apuls](https://community.ntppool.org/u/apuls)
#### Post date: [May 4, 2022, 9:36pm UTC](https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368/4 "2022-05-04T21:36:51Z")

</div>

There is no special configuration.  
Sync your hypervisor with a Reflcock or (Pool)server and on the client do the same. That’s it.  
Or you can sync the hypervisor and use a client clock which sync with the hypervisor. IIRC Amazon EC2 is doing likely the same.

Maybe Red Hat have some good suggestions:

> **[Chapter 8. KVM Guest Timing Management Red Hat Enterprise Linux 7 |...](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_deployment_and_administration_guide/chap-kvm_guest_timing_management)**
>
> The Red Hat Customer Portal delivers the knowledge, expertise, and guidance available through your Red Hat subscription.

---

<div class="post-metadata">

### Author: ![mibere](https://avatars.discourse-cdn.com/v4/letter/m/e9c0ed/32.png) [@mibere](https://community.ntppool.org/u/mibere)
#### Post date: [May 4, 2022, 9:51pm UTC](https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368/5 "2022-05-04T21:51:46Z")

</div>

> [@apuls](#):
>
> Sync your hypervisor

I don’t have one anymore, see previous post 🙂

---

<div class="post-metadata">

### Author: ![Bas](https://sea2.discourse-cdn.com/flex016/user_avatar/community.ntppool.org/bas/32/465_2.png) [@Bas](https://community.ntppool.org/u/Bas)
#### Post date: [May 5, 2022, 9:51am UTC](https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368/6 "2022-05-05T09:51:25Z")

</div>

It’s my understanding that your NIC doesn’t have a clock, it just stamps network packages in order to minimise the offset.  
Also, for it to work, all NIC’s need hardware timestamping else it’s ignored as far as I know.

In order to get accurate time from a refclock, you still need a GPS with PPS.

As for onboard clocks, forget about those, none of them is accurate and they wander all over the place.

---

<div class="post-metadata">

### Author: ![mlichvar](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@mlichvar](https://community.ntppool.org/u/mlichvar)
#### Post date: [May 5, 2022, 10:08am UTC](https://community.ntppool.org/t/recommended-settings-for-chrony-on-kvm/2368/7 "2022-05-05T10:08:14Z")

</div>

> [@mibere](#):
>
> What I don’t know and really don’t understand now, should or do I have to install the package _linuxptp_ to use
> 
> - ptp4l ?
> - phc2sys ?

Only if there is PTP provided in the local network and you would want to use it as a time source.

> [@](#):
>
> And even without _linuxptp_ installed, is it helpful/recommended to configure something like this in chrony:
> 
> `refclock PHC /dev/ptp0 pps`

No, the clock would need to be synchronized (e.g. by ptp4l) to be useful as a reference clock.
