NTP stratum-1 on Ubuntu 14.04LTS

Some (incomplete) notes on setting up a stratum-1 NTP server on Ubuntu 14.04LTS

To handle the upcoming leap-second we want a leapfile, from: http://www.ietf.org/timezones/data/leap-seconds.list

The path of the leapfile goes into /etc/ntp.conf
leapfile /etc/leap-seconds.list
But Ubuntu uses apparmor, so we must grant permission for the ntp service to read this file in /etc/apparmor.d/usr.sbin.ntpd by adding:
/etc/leap-seconds.list r,
To make apparmor parse and apply the new rules we do:
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.ntpd
when the ntp service starts it is useful to look at /var/log/syslog where ntp will complain if it doesn't have permission to read the leapfile or if it is badly formatted.

Now let's edit the default options for the ntp service in /etc/default/ntp by adding:
NTPD_OPTS='-gN'
(-N runs ntpd at highest priority, -g makes it more robust agaist large time offsets, see man ntpd)

To get time in NMEA-format and a pulse-per-second (PPS) from gpsd we add two shared-memory (type 28) refclock drivers to /etc/ntp.conf

# GPS Serial data reference
server 127.127.28.0 maxpoll 3
fudge 127.127.28.0 time1 -0.230 refid GPS

# GPS PPS reference
server 127.127.28.1 prefer maxpoll 2
fudge 127.127.28.1 refid PPS

(the time1 adjustment number needs to be calibrated somehow..).

Finally we let ntp distribute time to the outside world by adding this line to /etc/ntp.conf (this is usually at the end of the file).
restrict default noquery

Now let's set up gpsd. The service configuration file is /etc/default/gpsd, and as suggested in the file we edit it with the utility:
sudo dpkg-reconfigure gpsd
The options that worked for me are device /dev/ttyS0 and options -n (don't wait for clients to connect). After running the utility /etc/default/gpsd should look something like:

START_DEAMON="true"
GPSD_OPTIONS="-n"
DEVICES="/dev/ttyS0"
USBAUTO="false"
GPSD_SOCKET="/var/run/gpsd.sock"

You can verify that gpsd is working with cgps, xgps, or gpsmon.

This should result in Ubuntu automagically starting gpsd and ntpd in the correct order at bootup, and ntpq -p should show something along the lines of:
Screenshot - 06262015 - 10:18:31 AM

If you want to manually restart (or just start or stop) the services, required e.g. after any changes are made to /etc/ntp.conf, it is done with
sudo service ntp restart
sudo service gpsd restart

Rack PC Build - Part Two

Another rack-PC put together this week. Intel X99-chipset with LGA2011-3 CPU socket. Only PCI-e slots, no legacy PCI-slots.

Again I didn't get the polarity of the HDD-LED and Power-LED wires right on the first try. How come the industry cannot agree on a standard connector for the bundle that has the power-switch, reset-switch, HDD-LED, and Power-LED?

Another glitch was that this board has 8 slots for RAM, and the two RAM-sticks I got need to be installed exactly in the right slots - otherwise it won't even boot into the BIOS. Some reading of the motherboard manual was required.

After installing Ubuntu 14.04LTS (from USB-stick! No CD/DVD required) the NVIDIA-drivers (for the GTX750TI) were not automatically detected. I downloaded the latest driver from NVIDIA and installed it manually. This requires logging in to a text-only console (CTRL-ALT-F1), and then killing X for the duration of the install (sudo service lightdm stop)

Installing the latest KiCAD on Ubuntu 14.04LTS

Add the ppa:js-reynaud/ppa-kicad to your list of sources:

sudo add-apt-repository ppa:js-reynaud/ppa-kicad

Then update package repository info

sudo apt-get update

Then install kicad

sudo apt-get install kicad kicad-common

Done. As of 2014-10-19 I get "Build 2014-jul-16 BZR unknown" - which should be new enough to contain most of the features I want.

There is a problem with this install because the environment variable KIGITHUB is not set. We do that by adding this line to ~/.profile

export KIGITHUB="https://github.com/KiCad"

For this to take effect you need to log out and then log in again. You should now see KIGITHUB defined in the under Preferences/Library Tables in Pcbnew. I still have KISYSMOD undefined, but that doesn't seem to matter(?).

So far so good. Next stop is learning how to work with the kicad github plugin so I can store my own symbols/footprints in my own github repo.

Ubuntu 13.10 notes

Reinstalling Ubuntu on my laptop, a Lenovo IdeaPad Yoga 13".

Creating a bootable USB stick:

  • On another Ubuntu machine, use "Disks" from the menu to remove old partition, create a new one, and format a 1 GB stick
  • Use unetbootin to write the latest ISO from http://www.ubuntu.com/download to the stick

For some reason the driver support for this laptop is not that great. Wifi, bluetooth, screen brightness control do not work with standard Ubuntu. Amazingly the touch-screen does work - but I don't use it much. The wifi driver is an absolute must, since the machine does not have an Ethernet port.

Wifi driver fix:

git clone https://github.com/lwfinger/rtl8723au.git
cd rtl8723au/
make
sudo make install
sudo modprobe 8723au

Screen brightness fix:

  • Add the acpi_backlight=vendor to your grub default command line in /etc/default/grub, i.e. GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_backlight=vendor"
  • sudo update-grub
  • blacklist the ideapad_laptop by adding "blacklist ideapad_laptop" to your /etc/modprobe.d/blacklist.conf file.
  • sudo reboot

Useful packages and random tweaks:

  • git
  • build-essential
  • synaptic
  • indicator-multiload
  • flashplugin-installer
  • Firefox plugins: Tab Mix Plus (Why isn't multi-row tabs standard on Firefox?? I NEED about 8 rows of tabs!)
  • geany (simple text editor)
  • Privacy: from the menu "Privacy" then on the second tab turn OFF "record file and application usage"
  • filelight (see where all the diskspace went!)
  • vlc
  • stellarium (star map)

External sources

NTP to keep the system clock on time

  • sudo apt-get install ntp
  • add time1.mikes.fi and time2.mikes.fi to list of servers to /etc/ntp.conf
  • sudo service ntp restart
  • check that it is working: watch -n 2 ntpq -np

Reasons to still have a Virtualbox Win-7 install:

  • PADS schematic and PCB design - but I am trying to learn Kicad now
  • Wireless USB-stick based transfer of GPS data from my Garmin devices (I think this is doable in linux, I just haven't had the time to learn)
  • QuickRoute for plotting orienteering maps/GPS-data (I'ts a .NET application, so maybe would run under mono?)
  • Mechanical CAD applications. FreeCAD is on the way to become usable for serious stuff - but not yet...
  • NI Multisim for SPICE simulations. Is there a good alternative for linux?

Ubuntu One is very slow

Update5: Day 4 and it looks like this: laptop 18078 items (5.5Gb), desktop 17803 items (5.5Gb). I wonder why the file-count differs?

Update4: Day 3 of this experiment. Machines have been online for more than 72 hours. In total 50Mb have been uploaded from laptop today (since reboot in the morning). That might be a good sign. All the files should now be in the "cloud". But are they synced to my other machines? Laptop still shows 18800+ files, desktop now shows 17800 files. Getting close...

Update3: Here's another observation, when the laptop, which still has about 11000 un-synced files in the One-folder, boots up, ubuntuone-syncdaemon can take 1-3 minutes of 100% cpu and about 300Mb RAM. After that it settles down, but 100% cpu means the machine is slow and unresponsive for a while 🙁

Update2: Someone at canonical asked for my log-files (they are in ~/.cache/ubuntuone/log/), and I've sent them. Hope they find what is going wrong!

Update1: the sync does seem coupled to a reboot. This morning it appears about 400Mb more was synced after a reboot of the machine. I still have about 11000 files un-synced after 48 hours.

These days data wants to be distributed and in the cloud. This image shows my Ubuntu One folders on three machines. They are supposed to be in sync, but are far from that after being connected to a high-speed network for more than 24 hours 🙁

OK, so let's go buy 20Gb of space on Ubuntu One, and transfer my working-set of work/hobbies/etc files there and see how it goes. I use about three computers regularly, a new laptop at work, and a  desktop and an old laptop at home. The work machine is on the university network where bandwidth shouldn't be a problem, and I have 40Mbit broadband from welho at home. What could possibly go wrong?

Ubunutu One is very very slow. I didn't just dump all my files and pictures into the shared-folder at once, I thought I'd start with a subset which happened to be 18064 files taking up 5.5Gb. It appears that in the first 24 hours roughly 700 Mb of data was synced. Now I have rebooted the primary laptop and it has very rapidly sent out another 500 Mb - but then slowed down to a creep. Is there a bandwidth-cap? For paying users?

Does anyone use Dropbox for lots (10s of thousands) of files? Does it work? Fast?

Computer upgrade

A failed powersupply was my excuse to upgrade most of the other internals of the desktop computer too. Some notes on adding a disk to LVM, following Suji's notes from 2007 (all of these require sudo):

  • fdisk /dev/sdd

    (create a primary partition, type "8E" Linux LVM, exit with "w")

  • mkfs -t ext3  /dev/sdd1

    (this will create the file-system. option "-c" which checks for bad sectors is recommended by some, but takes ages to complete) (see comments)

  • pvcreate /dev/sdd1

    (this will create a physical volume)

  • pvdisplay

    will now list all the physical volumes and the newly created one should be visible.

  • vgdisplay

    will list the volume groups. On my machine there's one named "datadisk"

  • vgextend datadisk /dev/sdd1

    (this will extend the volume group with the new disk)

  • vgdisplay -v datadisk

    will now display info on the volume group. The new disk should show up in the list of physical volumes.

  • lvextend -l100%VG /dev/datadisk/data

    (this will extend the logical volume so that the new size is 100% of available space in the volume-group)

  • resize2fs /dev/datadisk/data

    (this will resize the logical volume. takes a long time to complete with big disks and there is no progress bar/display)

  • finally you can check that the mounted volume group is actually re-sized to the new size and has lots of free space:
    df -h
    

There is more info in the LVM-HOWTO.

EMC2 upgrade

I've upgraded Ubuntu and EMC2 on the Atom 330 machine I have for controlling the lathe. The Atom 330 is a dual-core chip, but with Hyper Threading the OS can see four cores. That's not good for real-time performance, so the first thing I did was turn off HT from the BIOS. Next I did a distribution upgrade to 10.04LTS which downloaded about 1 Gig in an estimated 9 minutes (2Mb/s is OK I guess...). I then used the emc2-install script which installs the real-time kernel and emc2, and finally I edited /boot/grub/menu.lst by adding "isolcpus=1" on the kernel line. This reserves one cpu core for real-time and the other for non-real-time tasks. Without "isolcpus=1" the latency-test jitter values were easily 10k and more with a light load on the machine. With one core dedicated to real-time the jitter numbers start out at around 4k at light load and double to 7-8k under heavy load.

Here are some selected screenshots:

Next stop is getting the X and Z servos moving, as well as the hefty 2 kW spindle servo.