DEV Community

masoomjethwa
masoomjethwa

Posted on

Headless Raspberry Pi 3B Setup, Benchmarking & Backup – A Developer’s Guide

The Raspberry Pi 3B may be modest in specs — just 1GB RAM and a 4-core ARM CPU — but with a minimal Lite OS and a headless setup, it becomes a lean and efficient coding machine.

In this guide, we’ll cover everything from first boot to benchmarking and creating portable backups of your custom setup. Ideal for devs, tinkerers, and minimalist hackers!


🧰 What You’ll Need

  • Raspberry Pi 3B
  • microSD card (8GB+ recommended)
  • Raspberry Pi OS Lite (no desktop)
  • SSH access (headless setup)
  • Wi-Fi or Ethernet

🛰️ Step 1: Headless Setup of Raspberry Pi OS Lite

📁 1. Prepare the SD Card

Download Raspberry Pi OS Lite and flash using:

  • Raspberry Pi Imager
  • balenaEtcher
  • dd (for advanced users)

⚙️ 2. Enable SSH and Wi-Fi

Place these two files in the /boot partition of the SD card:

  • ssh (empty file)
  • wpa_supplicant.conf (for Wi-Fi):
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
  ssid="Your_SSID"
  psk="Your_PASSWORD"
}
Enter fullscreen mode Exit fullscreen mode

🔌 3. Boot and Connect via SSH

Insert the SD card, power up the Pi, and connect:

ssh pi@raspberrypi.local
# or use the IP
ssh pi@<ip-address>
Enter fullscreen mode Exit fullscreen mode

🔒 Step 2: Initial Setup & Security

Once logged in:

passwd  # Change default password
sudo apt update && sudo apt upgrade -y
sudo raspi-config
Enter fullscreen mode Exit fullscreen mode

In raspi-config, set:

  • Locale
  • Timezone
  • Hostname
  • Enable interfaces (SSH, I2C, etc.)

🛠️ Step 3: Essential Package Installation

Install tools for development, monitoring, and coding:

sudo apt install -y \
  git curl wget build-essential \
  python3 python3-pip python3-venv \
  vim nano tmux htop neofetch \
  nodejs npm
Enter fullscreen mode Exit fullscreen mode

Python setup:

python3 -m pip install --upgrade pip
python3 -m pip install virtualenv ipython
Enter fullscreen mode Exit fullscreen mode

📊 Step 4: Benchmark Your Raspberry Pi

Install benchmark tools:

sudo apt install -y sysbench stress hdparm
Enter fullscreen mode Exit fullscreen mode

🧠 CPU Benchmark

sysbench cpu --threads=4 --cpu-max-prime=20000 run
Enter fullscreen mode Exit fullscreen mode

💾 Memory Benchmark

sysbench memory run
Enter fullscreen mode Exit fullscreen mode

📀 Disk Benchmark

sudo hdparm -Tt /dev/mmcblk0

dd if=/dev/zero of=testfile bs=10M count=100 conv=fsync
rm testfile
Enter fullscreen mode Exit fullscreen mode

🌡️ Monitor Temps

vcgencmd measure_temp
watch -n 1 vcgencmd measure_temp
Enter fullscreen mode Exit fullscreen mode

💾 Step 5: Back Up Your Setup

📂 Create Backup Directory

mkdir -p ~/pi-backup/etc-backup
Enter fullscreen mode Exit fullscreen mode

🗃️ Copy Dotfiles and Configs

cp ~/.bashrc ~/pi-backup/
cp -r ~/.config ~/pi-backup/
Enter fullscreen mode Exit fullscreen mode

🧷 Save Package List

apt-mark showmanual > ~/pi-backup/manual-packages.txt
Enter fullscreen mode Exit fullscreen mode

📁 Copy System Configs

sudo cp -r /etc ~/pi-backup/etc-backup/
Enter fullscreen mode Exit fullscreen mode

📦 Optional: Compress Backup

cd ~
tar -czvf pi-backup.tar.gz pi-backup
Enter fullscreen mode Exit fullscreen mode

To extract later:

tar -xzvf pi-backup.tar.gz
Enter fullscreen mode Exit fullscreen mode

♻️ Step 6: Restore on a New Pi

✅ Copy pi-backup folder to new Pi

🔁 Run Restore Script

#!/bin/bash

echo "Restoring packages..."
xargs sudo apt install -y < ~/pi-backup/manual-packages.txt

echo "Restoring configs..."
cp ~/pi-backup/.bashrc ~/
cp -r ~/pi-backup/.config ~/
Enter fullscreen mode Exit fullscreen mode

Make executable:

chmod +x restore.sh
./restore.sh
Enter fullscreen mode Exit fullscreen mode

🚀 Bonus Tips

  • Use VS Code Remote SSH to edit code from your main computer
  • Use tmux or screen to keep sessions alive
  • Use git to manage and sync your dotfiles

🧠 Conclusion

With just a few tools and best practices, your headless Raspberry Pi 3B becomes a powerful coding box — light on resources, but heavy on possibilities.

Whether you're into Python dev, automation, or server-side scripting, this guide gives you a solid base to build from — and repeat any time.


Top comments (0)