(13) Start Configuring Gentoo

First job is to set the date, time and TimeZone correctly.

The Raspberry Pi does not have a Hardware clock. This is actually important, for portage to work correctly and calculate the correct versions of software packages.


(chroot) raspberrypi / #   ls /usr/share/zoneinfo

(chroot) raspberrypi / #   cp /usr/share/zoneinfo/Europe/London /etc/localtime
(chroot) raspberrypi / #   echo "Europe/London" > /etc/timezone date

We do need to confirm that the date and time are correct, to check simply type


(chroot) raspberrypi / #   date
Tue 19 Apr 12:43:02 BST 2016

To correct the date the format is the date MMDDhhmmYYYY (Month, Day, hour, minute and Year)


(chroot) raspberrypi / #   date 030715132016

Check its worked, this is error prone. . . .


(chroot) raspberrypi / #   date
Mon  7 Mar 15:13:00 GMT 2016

 

 

NTP - Fixing the Missing Clock

Because the Raspberry Pi does not have a Hardware Clock, we will install NTP (Network Time Protocol). First stop the ghost hardware clock from trying to start - and second, make sure swclock (Software Clock) service starts by default.


(chroot) raspberrypi / #   rc-update del hwclock default
  * rc-update: service `hwclock' is not in the runlevel `default'

(chroot) raspberrypi / #   rc-update add swclock default
  * service swclock added to runlevel default

Now we can install the NTP-Client.


(chroot) raspberrypi / #   emerge --ask net-misc/ntp

These are the packages that would be merged, in order:

Calculating dependencies... done!

[ebuild  N     ] dev-libs/libevent-2.0.22  USE="ssl threads -debug -static-libs {-test}" 
[ebuild  N     ] net-misc/ntp-4.2.8_p6  USE="ipv6 readline ssl threads -caps -debug (-libressl) -openntpd (-parse-clocks) -samba (-selinux) -snmp -vim-syntax -zeroconf" 

Would you like to merge these packages? [Yes/No]  Yes

Gentoo's wonderful automatic package compiler system will kick in, calculate the dependencies, and then compile in a sandbox, followed by automatically install. This takes about 5 minutes, so I am going to grab a quick coffee.

Let us make sure that this service starts by default.


(chroot) raspberrypi / #   rc-update add ntp-client default
 * service ntp-client added to runlevel default

We can start and stop services and check a service status in a similar manner, like this :

The problem is we are in a chroot shell, and another instance was started by Raspbian, so this is just for info


rc-service ntp-client status
rc-service ntp-client stop
rc-service ntp-client start

 

Known NTP-Client Bug [SOLVED]

Expect that every time you boot, that the NTP-Client will fail to start, I tried every fix and none of them worked reliably.

My solution was to add a short script to /etc/local.d/ntp-client-fix.start - (copy paste script) . . . Note that the file extension .start is important



(chroot) raspberrypi / #   nano /etc/local.d/ntp-client-fix.start


#!/bin/bash
#
# Genoot
# "ntp-client-fix.start"
#
# To activate this script 
# chmod +x /etc/local.d/ntp-client-fix.start
# rc-update add local default
#
sleep 45
OK=" * status: started"
RESULT=$( rc-service ntp-client status | grep started )
if [ "$RESULT" == "$OK" ] ;
then
 # echo -e "\nNTP-Client Running\n" 
 # Not strictly needed, but ntp-client is a real pain in the proverbial
 rc-service ntp-client restart ;
else
 #echo -e "\nStarting NTP-Client to set correct time and date\n" ;
 rc-service ntp-client start  ;
fi
exit


After copy pasting the script, make it executable and make sure it starts by default


(chroot) raspberrypi / #   chmod +x /etc/local.d/ntp-client-fix.start
(chroot) raspberrypi / #   rc-update add local default
 * rc-update: local already installed in runlevel `default'; skipping

One last point about the script, is take note that it works because of the delay of 45 seconds. If you make it shorter, the script might fail. If you get the odd failure, increase the value to say sleep 90 for a minute and 30 seconds.

Like most things, Gentoo has a proper page on the subject.

I also caution that before playing with portage, make sure the NTP-Client is really up and running... Because should portage thinks it is Thursday 1st January 1970 you are going to get some weird results. The Raspberry can boot and fail to start the NTP-Client, because some thing like the DHCPD has not completed or the swclock is not starting by default, or other reasons, so do check. If you have problems, come back to this page and check you completed all the small steps.

Next : locales

PREVIOUS INDEX NEXT