Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
NanoPi R1 as Pi Hole Device

NanoPi R1 as Pi Hole Device

This guide assumes you're using linux or some kind of OS with a shell, you can use Windows with some modifications.


Install Latest Xenial

Download the latest NanoPi R1, extract the zip file.

Image will look something like nanopi-r1_eflasher_friendlycore-xenial_4.14_armhf_20191230.img to an sdcard.

sudo dd if=./nanopi-r1_eflasher_friendlycore-xenial_4.14_armhf_20191230.img of=/dev/your_sd_card bs=4096

Boot From Serial

You can follow my guide to doing this with OpenWRT, it is exactly the same.

Boot From Serial Instructions

After you're done, it should boot directly to the bash shell with the pi user.


Remove Network Manager service

I had a lot of trouble with this installed, so I removed it.

sudo su -
systemctl stop NetworkManager
systemctl disable NetworkManager

Setup Wifi

Note: My wifi interface is wlan0, I'm not sure if this is the same across all devices or not. Do iwconfig to find yours if you have trouble.

sudo su -
killall wpa_supplicant
ifconfig wlan0 up
iwlist wlan0 scan | grep ESSID

Note above, I'm killing wpa_supplicant, if you reboot mid-instructions you'll need to kill it again.

Create conf File

Add quotes around your essid and passphrase if they have spaces.

wpa_passphrase your-ESSID your-passphrase | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf
vi /etc/wpa_supplicant/wpa_supplicant.conf

Edit to look like this, though this assumes you're using WPA2 which you probably should be. You may have to modify this further if you've got something custom. I don't know a whole lot about configuring these things, so use stackoverflow if you can't connect.


Try Connecting

wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0

This shouldn't return a fail, if it does you'll need to google around.

If it works, you can connect to it in the background.

wpa_supplicant -B -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0

Set WiFi to dhcp

dhclient wlan0
ifconfig wlan0
ping -c3

Setup wpa_supplicant Service

cp /lib/systemd/system/wpa_supplicant.service /etc/systemd/system/wpa_supplicant.service
vi /etc/systemd/system/wpa_supplicant.service


ExecStart=/sbin/wpa_supplicant -u -s -O /run/wpa_supplicant

Replace With:

ExecStart=/sbin/wpa_supplicant -u -s -c /etc/wpa_supplicant/wpa_supplicant.conf
ExecStop=/usr/bin/killall wpa_supplicant



Replace With:


Start/Enable wpa_supplicant Service

systemctl enable wpa_supplicant.service
systemctl start wpa_supplicant.service

Setup dhclient Service

vi /etc/systemd/system/dhclient.service

Add this:

Description= DHCP Client

ExecStart=/sbin/dhclient wlan0 -v
ExecStop=/sbin/dhclient wlan0 -r


Start/Enable dhclient Service

systemctl enable dhclient.service
systemctl restart dhclient

Other Stuff


Set Timezone

# List Them
timedatectl list-timezones
# Set One
sudo timedatectl set-timezone America/New_York
# Verify

Synchronize the System Time

apt install chrony -y

Remove Unused Locales

Generating locales takes a long time on this little computer, you can remove the ones you don't want. The list you put at the end of this command is what you want to KEEP, I'm only keeping en_US.utf8.

locale-gen --purge en_US.utf8


apt update && apt upgrade -y


Change the pi user password.

passwd pi


Just like this, but you probably don't want to add me to your machine.

useradd -m pjobson
usermod -a -G sudo pjobson
chsh --shell /bin/bash pjobson


From your client machine you should be able to ssh into the NanoPi now.

ssh pjobson@

Add USB Storage

These little computers don't have much storage, maybe add some with a USB stick. Insert the stick.

Use fdisk to find your drive and modify it. Hopefully you're using a new one or don't care what's on it, because we're gonna wipe it.

If your drive is NOT /dev/sda do not copy/pasta this! You'll want to do all of this as root or with sudo.

fdisk -l
fdisk /dev/sda

If you're unfailiar with fdisk here's what you want to do:

  • d to delete all partitions
  • g to set to gpt
  • n to create new
  • Partition number (1-128, default 1): 1
  • First sector (2048-31266782, default 2048): 2048
  • Last sector, +sectors or +size{K,M,G,T,P} (2048-31266782, default 31266782): 31266782

Your last sector will vary, mine is a 16GB stick.

Make the file system

mkfs.ext4 /dev/sda1

Put Home on USB Storage

I put my home directory stuff on the SD card, this is how I did it.

Again with the root user or sudo.

cd /home
mkdir /tmp/hometemp /tmp/hometemp/usbstick
tar czvf /tmp/hometemp/home.tar.gz .
cd /tmp/hometemp
mount /dev/sda1 /tmp/hometemp/usbstick
cd /tmp/usbstick 
tar xzvf ../home.tar.gz 
ls -la
umount /tmp/hometemp/usbstick

Edit fstab

vi /etc/fstab

Add this:

/dev/sda1         /home    ext4       defaults      0       2


rm -rf /home/*
mount -a
ls -la /home

This should show your users' directories.


Install PiHole

sudo apt install curl
sudo curl -sSL | bash

Go through the setup wizard at the end it'll show you a URL and password, browse there, put the password down somewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment