ntp drift file in /etc/ntp instead of /var/lib/ntp - suggestion for a patch in Slack
SlackwareThis Forum is for the discussion of Slackware Linux.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
ntp drift file in /etc/ntp instead of /var/lib/ntp - suggestion for a patch in Slack
I run a script on my Linux machines that every night checks if anything has changed in /etc and below and if it has, makes a backup, keeping the last 5 versions.
This way I can check when something stops working if any configuration has changed.
Now I noticed that on one server (running Slackware 12.2 stable) my script said that the configuration changed every day.
Digging in a bit deeper, I found that ntp that runs on that particular box keeps the drift file in /etc/ntp and that file changes daily.
I found some discussions on the internet that this file should be in /var/lib/ntp - which makes sense to me, as it is not a configuration file at all.
I made the change myself (in /etc/ntp.conf) and now my script stops warning me about the new configuration every day.
The official ntp site says the default is /etc/ntp.drift and does not elaborate much on the subject.
The /etc hierarchy contains configuration files. A "configuration file" is a local file used to control the operation of a program; it must be static and cannot be an executable binary.
The drift file is definitely not "static".
It tell us about /var:
/var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files.
I vote for changing the ntp drift file to /var/lib/ntp in Slackware.
Should this be changed in the next release of Slackware by including a patched /etc/ntp.conf file?
After all, Slackware seems to follow the FHS quite well.
Last edited by niels.horn; 05-06-2009 at 06:51 AM.
Distribution: slackware64 13.37 and -current, Dragonfly BSD
Hi neils. When I first looked at you post I had to agree as the reasoning behind files in /etc being static makes sense. However that prompted me to have another look at the dates and timestamps of files in there.
Notice there is also the files under /dhcpc and /etc/ld.so.cache which are transient. There are probably others that I haven't noticed yet.
So it would seem some applications do store non-static data in there. Perhaps we are misreading the FHS's meaning on this or perhaps it's just being ignored ?
I'm pretty sure that /etc/ld.so.cache is one of those historical exceptions like /etc/mtab is not static. I don't use dhcpc so I'm not sure what files it maintains under /etc.
I also don't use ntp, but from this description:
The drift file is used to record the frequency offset of the local clock oscillator. If the file exists, it is read at startup in order to set the initial frequency offset and then updated once per hour with the current frequency offset computed by the daemon. If the file does not exist or this command is not given, the initial frequency offset is assumed zero. In this case, it may take some hours for the frequency to stabilize and the residual timing errors to subside.
it looks like it gets updated quite a lot. My feeling is that it would be more correctly placed under /var. But I'm not convinced that /var/lib/ntp would be right -it might be more correct under /var/run. But, /var/lib/??? serves as a catchall for other transient, hard-to-define files, so it is probably legal...
The ntpd behavior at startup depends on whether the frequency file, usually ntp.drift, exists. This file contains the latest estimate of clock frequency error. When the ntpd is started and the file does not exist, the ntpd enters a special mode designed to quickly adapt to the particular system clock oscillator time and frequency error. This takes approximately 15 minutes, after which the time and frequency are set to nominal values and the ntpd enters normal mode, where the time and frequency are continuously tracked relative to the server. After one hour the frequency file is created and the current frequency offset written to it. When the ntpd is started and the file does exist, the ntpd frequency is initialized from the file and enters normal mode immediately. After that the current frequency offset is written to the file at hourly intervals.
So, the ntp.drift file is updated hourly, but over time the data stored within it will become static. It is a file that can fit with either definition.
My opinion is that the decision lies with the upstream developers, who have decided to make /etc/ntp.drift the default. You are free to make a change if you desire.
One of the features of Slackware is that it respects the decisions of the upstream developers. This is usually a good thing, but it is easy to find situations in Slackware where a change in the default configuration can lead to enhanced usability. My pet example here is with xpdf. The default xpdf.rc has entries to point to Windows font files, but these need to changed to point to the default location of these font files in Slackware. This makes xpdf usable for pdf documents developed using Windows fonts. (I know there are better pdf viewers, but xpdf loads up very quickly and I make a lot of use of it for this reason).
I would prefer that Slackware continue with respecting the decisions of the upstream developers.
I picked /var/lib/ntp as it seems to be a common solution used in other distros.
I did some googling and found several references to this location.
At least it seems more appropriate than anything under /etc.
I also do not use dhcpc so I have had no conflicts with that one.
/etc/mtab is another situation, as it is "quite static" on most servers.
On desktops it might change a lot though.
I *think* the same goes for /etc/ld.so.cache
I never really cared for the idea of /var/lib/... as unlike /lib, or /usr/lib it doesn't contain libraries so the name just doesn't seem right to me. /var/state as a name seemed far more logical to me, but it looks like the FHS has chosen to go with /var/lib instead. Anyway, despite my nitpicking on the name, I agree with the guys above that the file really doesn't belong in /etc. /var/run doesn't seem to be the right place either, so /var/lib/ntp/ seems like a good choice.
Its pretty standard for myself and many others to have /var on it's own partition (and possibly even a network share (unlikely as it may be)) the partition needs to be available when the startup services are run.
I remember dhcpc having issues when someone tried to force a change from /etc to /var for the state files. You want your networking up before trying to mount remote shares after all.
/etc should be on the root partition and is one reason why some of these files reside there. Others (as mentioned) are either just historical or are just the way that upstream do things...
Never take anything at face value as there are often some obscure reasons for things being the way they are.
On most professional *nix servers, /var is on its own partition indeed.
Sub-dirs might be on external network shares or storages, but usually not the standard sub-folders like /var/run, /var/lib etc. At least, in my experience.
I respect (most) upstream developers, but my idea of open software is that I am in control.
So if I think that non-static files don't belong in /etc, I'll move them to a better place.
One thing I learned after several decades of working in the IT / support business is not to accept simply what suppliers / upstream developers tell me to do. I question things a lot. And I don't accept answers like "we do it this way because we always did it this way". I am always open for good arguments though.