Sabayon is a Gentoo-based, GNU/Linux distribution. The latest version, Sabayon 5, was released on October 2, 2009. The GNOME edition was just reviewed here. One thing I pointed out in that review is that the NTP (Network Time Protocol) package is not installed by default. This post provides a step by step guide on how to install and setup NTP on Sabayon 5.
NTP is the protocol that allows a networked device to sync it’s clock with that of NTP servers on the Internet. It allows your computer’s clock to be accurate, atomic-clock accurate.
Step one is to launch Sulfur, Sabayon’s graphical package manager, from the menu (System > Administration > Sulfur) or by double-clicking Sulfur’s icon on the desktop. Make sure that the “Available” tab is selected, and type in “ntp” into the search box. From the search results, right-click on the NTP package and select “Install”. Then click on the Installation tab to see the packages that are going to be installed.
The Installation tab shows that two packages will be installed. Click on the Commit Actions button to start installation.
When the installation is completed, you will find two scripts related to NTP under the /etc/init.d directory. These are the ntp-client and ntpd scripts. ntpd is used to maintain time on a running system. It is automatically started after installation. ntp-client is used to set time at boot. Unlike ntpd, you’ll have to manually start it. To do that, launch a shell terminal (Applications > Accessories > Terminal), su to root, and type
/etc/init.d/ntp-client start as shown in the screenshot below.
With that out of the way, now we are ready to set up the system to use NTP. Launch the Time and Date utility from the menu (System > Administration > Time and Date). Click on the Unlock button to gain the rights needed to change the system’s time.
Time and Date utility
With the Time and Date utility unlocked, you’ll notice that by default, the system sets its time manually. Click on the Configuration dropdown and select “Keep synchronized with Internet servers”. Make sure that your timezone is correctly selected.
With NTP selected as the mode for setting time, the next screen presented allows you to select NTP servers to use. By default, four NTP servers are pre-selected, so you do not really need to do anything here.
The NTP servers pre-selected by the system. You may chose to de-select those and choose the NTP servers that you prefer to use.
That is all it takes to install and set up a Sabayon system to use NTP to set system clock.
In this tutorial you start the ntp-client manually by using the command:
# /etc/init.d/ntp-client start
However that command would not cause ntp-client to be started automatically when you reboot; it only starts ntp-client for the current session.
Don’t you also have to add net-client to the default runlevel so that it starts automatically when you next boot?:
# rc-update add ntp-client default
Or does using ‘Kickoff > Computer > System Settings > Date & Time’ to configure KDE 4 to synchronise automatically with an NTP time server add ntp-client to the default runlevel for you?
Having now configured a couple of PCs to sync their system clock by using NTP, I can answer my own question regarding ntp-client:
Although I have read on some sites that /etc/init.d/ntp-client should be added to the default runlevel in order to read the time from an NTP server (once-only, during start-up), this in fact does not work because usually the network connection is not up by the time the ntp-client initscript runs. Some solutions to this problem are given in the Sabayon Linux Forums thread http://forum.sabayon.org/viewtopic.php?f=59&t=15119
If you are using NetworkManager on your PC, an elegant solution is to use NetworkManagerDispatcher to restart ntp-client in order to resync your system clock every time a network connection comes up. Another way is to create a cronjob to run the ntpdate command or the “/etc/init.d/ntp-client restart” command. Yet another way (a ‘quick-and-dirty’ solution) is to delay running ntp-client until the network is up after boot by putting e.g. “sleep 10s && /etc/init.d/ntp-client restart” in /etc/conf.d/local.
Regarding the NTP daemon, it is possible to set this to run at start-up from the command line rather than via a Desktop Environment GUI. The command:
# rc-update add ntpd default
will add the daemon’s initscript to the default runlevel so that it is run automatically at next startup, and the command:
# /etc/init.d/ntpd start
will start the daemon running right now.
If you make clock_systohc=”YES” in the file /etc/conf.d/hwclock then the time in the system clock will be written to the BIOS (CMOS) clock (a.k.a. hardware clock) when you shut down your PC. Sabayon Linux has the file configured this way by default.
Note that, by default, the NTP daemon won’t correct, all in one go, a time difference between your system clock and the remote NTP server if that difference is above a certain size. However, if you want to override the default behaviour, i.e. allow the NTP daemon to make a large first adjustment to the system clock, you can set the environment variable NTPD_OPTS in the /etc/conf.d/ntpd file as follows:
This would mean that you would not need to run ntp-client before ntpd. However, if you run ntp-client automatically — either once after start-up or periodically — then that would be good enough for the typical desktop user and could be an alternative to having a continuously-running NTP daemon. Nothing stops you doing both if you want, of course.
Thank you. For something this detailed, perhaps you should post it in the forum.
Btw, running NTP is not as involved on a Debian-based system. It just works.