DEV Community

Cover image for How to Install Ubuntu Server on Raspberry Pi 4 (Headless Setup)
FlatlinerAtheist | CLI-NERDS
FlatlinerAtheist | CLI-NERDS

Posted on Originally published at clinerds.com

How to Install Ubuntu Server on Raspberry Pi 4 (Headless Setup)

The Raspberry Pi 4 is the cheapest way to have a real Linux server at home: silent, sips power, and perfectly capable of running Nextcloud, Immich, Pi-hole, or a small website. Ubuntu Server is a particularly good fit on it because you get the same apt world as any other Ubuntu machine — no special Pi quirks to learn.

Here's how to get Ubuntu Server onto a Pi 4 and reachable over SSH, without ever plugging in a monitor.

What you need

  • Raspberry Pi 4 (2 GB RAM is enough to start; 4–8 GB is comfortable)
  • A microSD card, 16 GB or larger, from a decent brand — cheap cards are the #1 cause of Pi weirdness
  • The official 5V/3A USB-C power supply (underpowered Pis corrupt SD cards)
  • A computer to flash the card with

Flash Ubuntu Server with Raspberry Pi Imager

Install Raspberry Pi Imager on your computer (available for Windows, macOS, and Linux), insert the SD card, and:

  1. Choose device — Raspberry Pi 4
  2. Choose OS — Other general-purpose OS → Ubuntu → Ubuntu Server 64-bit (use the LTS release)
  3. Choose storage — your SD card, double-checked
  4. Click Next, then open OS customization before writing

That customization screen is the important part for headless setup:

  • Set a hostname (e.g. pi-server)
  • Set a username and password
  • Configure Wi-Fi if the Pi won't use Ethernet (SSID, password, correct country)
  • Enable SSH (password authentication is fine to start)

Then write the image. It takes a few minutes including verification.

First boot and SSH in

Insert the card, power on the Pi, and give it 2–3 minutes for first boot (it expands the filesystem and generates SSH keys).

Find its IP address from your router's client list, or try the hostname directly:

ssh yourname@pi-server.local
Enter fullscreen mode Exit fullscreen mode

If .local doesn't resolve on your network, use the IP from the router. Accept the host key, log in with the password you set in Imager.

First-boot housekeeping

sudo apt update && sudo apt full-upgrade -y
sudo apt install -y htop curl vim ufw
Enter fullscreen mode Exit fullscreen mode

A few things worth doing immediately:

  • Static IP or DHCP reservation so the address survives reboots — our static IP guide covers both
  • SSH key login and then disable password auth (guide)
  • Firewall: sudo ufw allow OpenSSH && sudo ufw enable

Make the SD card last longer

SD cards wear out faster than SSDs, especially with logging and databases. Two easy wins:

  • Put big data on USB storage — a cheap USB SSD dramatically improves both speed and reliability for things like Immich or Nextcloud data
  • Reduce unnecessary writes: enable log2ram or trim log retention on systems that run 24/7

What to run on it

The Pi 4 handles a surprising amount: Pi-hole for network-wide ad blocking, Vaultwarden for passwords, a small website, monitoring, or a Nextcloud/Immich box for a small family. My own deGoogle setup started exactly this way — a $60 board in the closet replacing Google Photos.

Start with one service, keep it updated, and your little server will quietly pay for itself within months.

Top comments (0)