Earth Notes: On Setting Up a Raspberry Pi 3 as Off-grid Server and WiFi AP
(IN DEVELOPMENT as of 2018/07: the live server is still the RPi 2.)
As of 2018/07/13 I thought that my stand-alone Technicolor TG582n router had died, though it seemed OK again after several hours powered off. But it consumes ~8W and crashes about once per month. Also, since it is talking PPPoE (PPP over Ethernet) to a BT Openreach ECI Telecom ON316150 FTTC modem it doesn't need to do anything analogue, so the routing and filtering done by the Technicolor ought to be do-able by a Pi. Also the Pi 3 has on-board WiFi that can be used as an access point.
With an RPi 3 I ought to be able to ditch the TG582n router, save about 2/3rds of the power used by the networking gear, and reduce the number of system outages.
Another advantage of an upgrade to the Pi 3 is a bit more speed, and a bigger range of power draw to make better use of available sunshine, etc. Though I have to see if the base consumption of a stripped back Pi 3 is still OK.
I can also take the opportunity to buy a larger SD card to boost storage, and effectively keep the old SD card as backup. (Currently the RPi2 has a 128GB micro SD card.)
Yet another advantage of an upgrade is moving to a newer OS distribution, allowing access to a newer Apache, HTTP/2, and various other goodies.
So an RPi 3 Model B+ and mains and 12V power supplies and other goodies have been ordered from RS to get started.
I'll record below as I prototype various aspects of PPPoE networking, new HTTP/2 support, etc.
I anticipate a fair period of prototyping and testing before (re)building the production server.
Starting with just the following RS parts, no keyboard or mouse or screen plugged in, and waiting for it to boot, settles to 2.5W power consumption measured at the mains.
|1373331||Raspberry Pi 3 Model B+|
|8157334||USB DC/DC Adapter 12Vin 5Vout 2.1A|
|9098135||Official Pi 3 Power Supply Black|
|1213897||SD Card preloaded with NOOBS - 16GB|
Directly plugging in the USB keyboard and mouse from a previous Maplin Raspberry Pi kit (R45Pi) raises consumption to 3.4W. Plugging in HDMI doesn't add any further load/consumption.
Have logged in and changed the default password for user 'pi'.
The Wifi does not seem to be in use to grab an IP (with DHCP) and get an Internet connection. This may be normal for NOOBS.
Via the Preferences menu entry and the Raspberry Pi Configuration tool I have:
- Set the system to boot to CLI rather than desktop.
- Set GPU memory to minimum (16MB).
- (NOT enabled SSH yet.)
- Set WiFi country to GB.
I am being asked to reboot for some of those to take effect.
I am still being auto-logged-in, which on the console is probably OK.
ifconfig now shows
wlan0, though not with an IP address.
uname -a shows ...
4.9.80-v7+ #1098 Fri Mar 9 19:11:42 GMT 2018 armv71 ...
Following Setting WiFi up via the command line I
sudo raspi-config and in "Network Options" enter SSID and passphrase. I exit raspi-config and ... I have an IP address on wlan0 and can ping the outside world!
Security dictates that the very next thing to do is
sudo apt-get update && sudo apt-get-dist-upgrade.
With all that finished, power consumption (measured at the mains) is 3.1W. (Unplugging the USB mouse seems to push that up to 3.2W!)
I have established that the RPi3 and WiFi are working. Also that power consumption is not outrageous even before any attempts to tune it.
PPPoE and AP
The next step may be to load up a minimal Raspbian, and (briefly) get the RPi3 talking PPPoE to my ISP and providing a WiFi Access Point. This would probably have to be a quick temporary swap-out with the current server, as none of the other services would be there, so there will be HTTP and mail server fails while the RPi is in place.
I also have to provide down-stream wired routed (and NATted) Ethernet connections for devices that need it, such as my Loop and SmartThings hubs, and my new storage system. They may need some protection against external attack, and possibly against being used to attack other things inside the house. So I'll need to adjust my
On 2018/10/12 I ordered a 256GB Class 10 U3 micro SDXC memory card (Samsung MB-MC256GA Micro SDXC EVO PLUS Class 10 UHS-I U3, Amazon). The price was a little over £50+VAT.
My choice was partly informed by Raspberry Pi Dramble's microSD Card Benchmarks.
Given that the "... "lite" download is about half that size, for the entire OS. The full fat version is over 4GB" (Ken Hagan), I'm inclined to start with "lite" to save some of the new GB!
So, from the Raspian download page I am pulling the "Raspbian Stretch Lite" "Minimal image based on Debian Stretch" with release date 2018/10/09 (kernel 4.14, 368MB, SHA-256 98444134e98cbb27e112f68422f9b1a42020b64a6fd29e2f6e941a3358d171b4) as a ZIP file.
For lolz, I'm trying Etcher as suggested on the Raspbian page. Nice and simple, but warned me that 256GB was "unusually large" for it to Flash. I told it to go ahead anyway. The process was fast, and the card was left unmounted afterwards.
2018/10/20: I inserted the "Lite" microSD card into the RPi3, connected up keyboard, plugged HDMI into the family TV, and powered up.
Some items noted during boot:
- A message appeared (somewhere, now off-screen!) about the (root) partition being resized. (Looking at
df -houtput shows that there is a small
/bootpartition of 44MB and a huge ext4 root partition of 235GB. OK, though previously I have had a separate
/localwith most of the actual data in it. It looks like there are plenty of inodes with 15M compared to ~360k used in RPi2 main filesystem.)
- "Started LSB: Autogenerate and use a swap file." (I'll likely want to run swapless again, with some ZRAM. There appears to be a 100MB swap file in /var/swap.)
- SSH host keys have been regenerated.
- Bluetooth service has been enabled (I'll most likely want to turn that off for security and power reasons).
- A message says that "Wi-Fi is disabled because the country is not set. Use raspi-config to set the country before use."
I logged in as
pi and changed the password. I should now be safe to connect up to the Intartubes and get updates, for example.
I have changed the
fstab parameters of the root filesystem to be
defaults,noatime,commit=120 as on the RPi2 to reduce write traffic and improve performance, and rebooted. I may further raise the commit interval to 300s as on the RPi2's
I have set the hostname to
I have set the Wi-Fi country to
raspi-config, connected to the Net with the correct SSID and password by editing
/etc/wpa_supplicant/wpa_supplicant.conf with a 'network' entry with 'ssid' and 'psk' items.
apt-get update and
apt-get dist-upgrade to be up to date on security. At this moment, no updates were needed.
I have set up NTP with apt-get but have not yet fully configured it (ie accepting defaults for now).
At this moment, power consumption from the mains, with HDMI on, is shown as ~3.2W. The target is to get that as near as possible to 1W when idling without HDMI.
- Set timezone to UTC and localisation to en-GB.
- Temporarily have Pi as Wi-Fi AP and client during set-up to avoid needing the TV and as a recovery mode!
- Enable ZRAM as on RPi2 and probably disable /var/swap swap file.
- Reduce syslog logging to reduce write traffic.
- Increase ext4 filesystem commit time to 300s.
- Turn off Bluetooth to save energy.
- Set lower idling CPU clock to save energy (idle default apparently 600MHz, non-idle 1200MHz).
- (Done) Install NTP.
- Configure NTP.
- Install/configure hardware clock (spare device, new battery?).
- Install/configure Apache w/ HTTPS and HTTP/2 support.
- Turn off unnecessary LEDs eg not network connector (and have main red LED indicate CPU activity rather than solid on).
- Turn off other unnecessary h/w.
For significant applications added to the RPi 3, eg with
npm, a note will be made of what and when and why here.
- App name
- YYYY/MM/DD, apt-get/npm command, motivation and comments.
- 2018/10/20, apt-get install tcsh, because I like tcsh!
- 2018/10/20, apt-get install ntp, for good timekeeping.
- 2018/10/20, apt-get install tcsh, because I like tcsh!