Skip to content

Node OS Setup Guide Raspbian Jessie

Matt Magoffin edited this page Oct 22, 2019 · 3 revisions

Upgrade Raspbian to Debian 8 (Jessie)

⚠️ WARNING: this is a very old guide, meant for advanced developers. If you are looking to get started with a SolarNode device, there are pre-built OS images for many popular devices.

This guide describes the steps I took to upgrade a Debian 7 based Raspbian image to Debian 8 for SolarNodes.

Update the OS

I performed the following steps first to start with the latest Debian 7 packages:

apt-get update
apt-get upgrade
apt-get dist-upgrade

I then removed the dphys-swapfile package to remove swap:

apt-get purge -y dphys-swapfile

Next, switch to Jessie sources:

sed -i 's/wheezy/jessie/g' /etc/apt/sources.list

Now upgrade to Jessie:

apt-get update
apt-get upgrade

When apt asked what to do with changed files (a couple of bash configs), I choose to use the maintainer's copy. Finally,

apt-get dist-upgrade

For the sysctl.conf file I kept the existing version when asked, because that contains some Pi-specific configuration.

Reapply custom bash setting

I lost the custom bash settings during the upgrade. Re-apply by editing /etc/bash.bashrc, adding:

	unset HISTFILE

Reboot

reboot

Swtich to systemd init

First install systemd-sysv:

apt-get install systemd systemd-sysv
reboot

Then remove old sysvinit:

apt-get remove sysvinit

systemd-networkd

Create /etc/systemd/network/eth.network with:

[Match]
Name=eth0
[Network]
DHCP=yes

Then,

systemctl enable systemd-networkd
systemctl enable systemd-resolved
systemctl start systemd-networkd
systemctl start systemd-resolved

# now map resolve.conf to resolved
rm /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

systemd managed iptables

This is adapted from Arch Linux. Create /lib/systemd/system/iptables.service with:

[Unit]
Description=Packet Filtering Framework
DefaultDependencies=no
After=systemd-sysctl.service
Before=sysinit.target

[Service]
Type=oneshot
ExecStart=/sbin/iptables-restore /etc/iptables/iptables.rules
ExecReload=/sbin/iptables-restore /etc/iptables/iptables.rules
ExecStop=/lib/systemd/scripts/iptables-flush
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

Create /lib/systemd/scripts/iptables-flush with:

#!/bin/bash
#
# Usage: iptables-flush [6]
#

iptables=ip$1tables
if ! type -p "$iptables"; then
  echo "error: invalid argument"
  exit 1
fi

while read -r table; do
  tables+=("/var/lib/$iptables/empty-$table.rules")
done <"/proc/net/ip$1_tables_names"

if (( ${#tables[*]} )); then
  cat "${tables[@]}" | "$iptables-restore"
fi

Make it executable:

chmod 755 /lib/systemd/scripts/iptables-flush

Create /var/lib/iptables/empty-filter.rules with:

# Empty iptables filter table rule file
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT

Create /var/lib/iptables/empty-nat.rules with:

# Empty iptables nat table rules file
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT

Now enable the iptables service:

systemctl enable iptables
systemctl start iptables

You can check the filter and nat tables with:

iptables -L
iptables -L -t nat

Switch to OpenJDK

The Oracle JDK was removed during the upgrade, but I want to use OpenJDK anyway.

apt-get install openjdk-8-jre-headless
Clone this wiki locally