Skip to content
This repository has been archived by the owner on Apr 20, 2019. It is now read-only.
Patrick Schroen edited this page May 18, 2016 · 16 revisions

Below you'll find steps to build a PiHead image based on the Minimal image Raspbian Jessie Lite. Many of these steps are useful for other platforms and devices as well. :)

Installation

Download the Raspbian Jessie Lite image, and write the image to your SD card.

For OS X, note the RAW disk device rdisk is much quicker.

sudo dd bs=1m if=path_of_your_image.img of=/dev/rdisk<n>

SSH into your RPi as pi and change to root. Set your locale, time zone, US keyboard, update, upgrade, install dependencies, and rpi-update.

sudo su
export LANG=en_CA.UTF-8
sed -i "s/^en_GB.UTF-8 UTF-8/# en_GB.UTF-8 UTF-8/" /etc/locale.gen
sed -i "s/^# $LANG UTF-8/$LANG UTF-8/" /etc/locale.gen
locale-gen
echo LANG=$LANG > /etc/default/locale
update-locale
echo $(curl -sLk https://headless.io/timezone) > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
sed -i "s/^XKBLAYOUT=\"gb\"/XKBLAYOUT=\"us\"/" /etc/default/keyboard
apt-get update
apt-get -y upgrade
apt-get -y install fontconfig rpi-update git-core

Install Node.js.

curl -sL https://nodejs.org/dist/v4.4.4/node-v4.4.4-linux-armv7l.tar.xz | tar -Jxv -C /usr/local/ --strip=1
node -v
npm -v

Install PhantomJS.

wget https://github.com/piksel/phantomjs-raspberrypi/raw/master/bin/phantomjs -P /usr/local/bin/
chmod +x /usr/local/bin/phantomjs
phantomjs -v

Install Headless.

mkdir /opt/headless
curl -sL https://github.com/pschroen/headless/archive/stable.tar.gz | tar -zxv -C /opt/headless/ --strip=1
cd /opt/headless
npm install
useradd --system headless
sed -i "s/^#ExecStartPre=\/bin\/sh upgrade.sh/ExecStartPre=\/bin\/sh upgrade.sh/" headless.service
mv headless.service /etc/systemd/system/headless.service
chown -R headless:headless .
systemctl enable headless

List the partition tables, make note of the last End block.

fdisk -l

Cleanup. Clear history, shutdown and power off.

apt-get -y autoremove
apt-get clean
rm /lib/udev/rules.d/75-persistent-net-generator.rules
dmesg -C && cat /dev/null > ~/.bash_history && history -c && exit
cat /dev/null > ~/.bash_history && history -c && sudo shutdown now && exit

Clone the disk with the last End block plus one (+1), compress and release.

sudo dd bs=512 if=/dev/rdisk<n> count=<end block+1> of=`date +%Y-%m-%d`-raspbian-jessie-pihead.img
zip -9 pihead_latest.zip `date +%Y-%m-%d`-raspbian-jessie-pihead.img
Clone this wiki locally