Sunday, 15 February 2015

Automatically setting the date/time on Snappy Ubuntu Core

The Raspberry Pi 2 doesn't come with an RTC by default, so when your OS boots it doesn't know what time it is and it defaults to 1970. This breaks all kinds of things, including SSL connections. Here is how to install ntpdate, which will set the correct time on startup (assuming your RPi has network connectivity).

First download the required deb file to your desktop and scp them over to your RPi:
http://ports.ubuntu.com/pool/main/n/ntp/ntpdate_4.2.6.p5+dfsg-3ubuntu4_armhf.deb

Then on the RPi remount the system partition read-write and install the packages:
sudo mount -o remount,rw /
sudo dpkg -i *.deb
sudo mount -o remount,ro /

Now reboot and once done, check with the date command if your system thinks it's 2015. The time will be in UTC, but for most servers that's actually what you want.

Have fun!

Enabling WiFi on Snappy Ubuntu Core

Update: this it no longer necessary. Check https://developer.ubuntu.com/en/snappy/start/installation-tips/ for details on how to enable wifi in ubuntu snappy without having to install anything.




I've been playing with my new Raspberry Pi 2, and Ubuntu Core as an OS looks very promising. One downside that I've found is that it doesn't support WiFi out of the box. Well, that's only partially true, since the kernel does have all the drivers & firmware blobs included. What's missing are the wpa_supplicant tools to authenticate. Ubuntu Core doesn't use apt-get anymore, but luckily dpkg is still there behind the scenes. Here is how to install the missing packages on your system partition and enable the RPi to connect to your WiFi network.

First download the missing deb files to your desktop and scp them over to your RPi:
wget http://ports.ubuntu.com/pool/main/w/wpasupplicant/wpasupplicant_0.7.3-6ubuntu2.3_armhf.deb
http://ports.ubuntu.com/pool/main/libn/libnl3/libnl-3-200_3.2.24-2_armhf.deb
http://ports.ubuntu.com/pool/main/libn/libnl3/libnl-genl-3-200_3.2.24-2_armhf.deb
http://ports.ubuntu.com/pool/main/p/pcsc-lite/libpcsclite1_1.8.11-3ubuntu1_armhf.deb

Then on the RPi remount the system partition read-write and install the packages:
sudo mount -o remount,rw /
sudo dpkg -i *.deb

Create a config file for your wlan0 interface:
cat <<EOF | sudo tee cat /etc/network/interfaces.d/wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
  wpa_ssid "<YOUR_WIFI_NAME>"
  wpa_psk "<YOUR_PASSWORD>"
EOF
sudo chmod go-r /etc/network/interfaces.d/*

And finish up by remounting the root partition as read-only:
sudo mount -o remount,ro /

Now you can plug in your USB WiFi dongle and it should connect to your network. Use ifconfig wlan0 to see what IP address your RPi got assigned and dmesg to see the kernel logs in case things don't work as expected.

Have fun!