How to Install DietPi on a Raspberry Pi Zero? (or any other model)

how to install dietpi on a raspberry pi

I was looking for other distributions to try on my Raspberry Pi, and among all the failures I found DietPi that seems interesting
I tried it and was very impressed, it’s the perfect distribution for my Raspberry Pi Zero (or other models)
So today I’ll share with you what I learn

How to install DietPi on a Raspberry Pi Zero?
DietPi is a lightweight distribution, dedicated to single-board computers
It’s perfect for a Raspberry Pi, above all for a Raspberry Pi Zero
The installation is easy as an image is available, but you may need some help to use it at the beginning

Here is what I offer today, with a step by step guide, with a DietPi presentation, the installation process and a few tips to use it quickly

What is DietPi?

DietPi introduction

As its name suggests, DietPi is a lightweight distribution for your Pi
It’s working on a Debian OS you can configure to start with a minimal operating system (less than 200M once installed)

It’s highly optimized for a minimal CPU and RAM hardware, so it’s perfect for a Raspberry Pi Zero, but you can use it on any operating system
You start with a minimal system and can choose to install or not additional software (even a desktop environment if you want)

If you want to give a try, it’s even possible to use it on a standard PC or a VM (images available on the official website)

The DietPi story

The DietPi seems to exist since 2015 (I didn’t find clear information, but it’s the forum creation date, not a big deal)
As you may not yet know what DietPi is, here are the main links you can browse to learn more about this distribution:

As soon as it’s clear for you that DietPi is an interesting distribution to try, come back to the topic, and let’s move further 🙂

Why DietPi rather than Raspbian Lite?

As it’s based on Debian, DietPi is close to Raspbian Lite, and you may ask you why you need to choose one or the other

First thing to know is that DietPi is often updated
For example, it’s already available in Debian 10.0 (Buster) whereas it’s available since less than a month at the time of writing

Here is a short performance comparative I made between DietPi and Raspbian Lite
This way you’ll get a quick overview of the optimizations you can get:

DietPi Raspbian Lite
Image Size966 MB1780 MB
SD Card usage2.1 GB1.2 GB
Minimal memory usage36 MB110 MB
Bootup Time14 s15 s
Packages installed by default235463

These values are for a fresh new install, with nothing more than default packages, you may need to compare them in your specific environment
And it’s the same result for most of the indicators you can imagine (processes, swap usage, etc.)

So for a basic installation, DietPi is really a good try
It’s up to date, and easy to use (same commands as Raspbian most of the time)

How to install DietPi on a Raspberry Pi?

What do you need?

Like for any OS you need basic stuff to follow this tutorial
Here is a list of hardware you need to prepare:

  • A Raspberry Pi (the Zero seems perfect for DietPi, but any model is fine)
    My recommendations here if needed
  • A minimal SD card, let’s say at least 4G (so any new one is OK), and a way to read it on your computer (integrated slot or external SD card reader)
    Check my recommended products here

That’s all you need.
A screen, mouse or keyboard is not mandatory if you follow all the steps I’ll give you
For the software, just two are needed:

  • The latest DietPi image you can find on the official website
    Select “Download” in the main menu, choose Raspberry Pi and click on the download button (sorry, no direct link available)
    Link to the official website
  • And the Etcher software, my favorite to flash SD card for Raspberry Pi
    Etcher is available for Windows, Linux and macOS. Just click on the download button from your computer
    Free download here

That’s it, you are ready to start

SD Card preparation

Flash the SD card with Etcher

The first step is to prepare the SD card with DietPi
I use Etcher to do this, but if you prefer another software it’s your choice

  • Open Etcher
  • A windows like this shows up:
    etcher menu
  • Click on the first button, and browse to DietPi image location
    Select it and continue
  • Insert your SD card in your computer, Etcher will detect it automatically
    You can ignore your system messages about this SD card
  • Finally, click on “Flash!” to start the copy on the SD card

After a few minutes the SD card is ready, eject it

Wi-Fi configuration

If you want to use a wireless connection, especially if you don’t have a screen, you need to configure it before the first boot
So if you are trying DietPi on a Raspberry Pi Zero for example, follow these steps:

  • Insert the SD card back into your computer
  • Go to the boot partition in your file explorer
  • Find the dietpi.txt file, you’ll need to change one thing in it to enable auto Wi-Fi connection:
    • Open the file with your favorite editor
    • Find the line starting with “AUTO_SETUP_NET_WIFI_ENABLED” and set it to:
      AUTO_SETUP_NET_WIFI_ENABLED=1
      This will enable the wireless connection on boot, the SSID and password are in another file
    • You can also check quickly this file to change the settings you want directly here (keyboard layout, time zone, network configuration, host name, etc.)
    • If you don’t have a DHCP on your network, the network configuration is mandatory to use it without a screen
      But nothing else is required, you can do this later (I’ll show you)
    • Save and exit
  • Now, find the dietpi-wifi.txt file and open it
    • Here is what you’re looking for:
      dietpi wifi configuration
      It’s at the beginning of the file, with all the fields you need to configure your wireless connection
    • Fill at least the SSID and KEY variables if you have a basic network with WPA-PSK
      The other fields are for a highly secured network, most of the time for companies I think
    • Save and exit
  • Make sure you closed all the files and eject the SD card again

This time it’s good, we are ready to start the Raspberry Pi

First boot on DietPi

Insert the SD card into your Raspberry Pi and start it
A few seconds later, you can connect through SSH, or follow the instructions on the screen

Connect to DietPi via SSH

If you want to connect via SSH (recommended):

  • Find the IP address of the Raspberry Pi
    You can scan your network or check the computers list on your router (probably your Internet box)
    If you don’t know how, check this tutorial on how to find your Pi IP address
  • Once you find it, you can connect with an SSH client (SSH is enabled by default)
    On Linux an macOS it’s available directly in the terminal: ssh user@IP
    On Windows, you have to install a software, like Putty (download here)
    puTTy configuration
    Fill the host name with the IP address and click “Open”

DietPi configuration wizard

Once connected via SSH, or directly on the screen, here are the default DietPi login and password:

  • Login: root
  • Password: dietpi

Once logged in, a wizard shows up to help you with the configuration process
Yes, we probably need this on Raspbian Lite for beginners 🙂

  • First, accept the license
  • Then, it will ask you a few questions for the basic steps:
    • The passwords you want to use for DietPi users (recommended)
    • Disable the serial console if not needed (probably the case)
  • Then you get a complete wizard to configure the system and install new software directly from here:
    • A list of useful links to start with DietPi
    • Everything you need for the basic configuration (DietPi-Config): Display, audio, performances, advanced options, language, security, network, auto start and other tools!
    • A few lines to search and install new software
      You can also browse a list of recommended packages to install

      You can even install your favorite desktop environment from here, with an easy to use checklist
    • Configure your favorite services for the main servers you want to use (SSH, File server, Web server, etc.)
    • Location of the home folder
    • Once all the changes you want done, click on “Install” to install everything you selected
      You can always do this later with the dietpi-software command
  • You can also make no changes for now, and click “Ok” to close this wizard and keep a minimal image (or apply the changes you made)
    If you prefer to use apt to manage your packages later, just do this

Once you confirm, the setup continues with at least the apt updates available

It can take some time on a Raspberry Pi Zero (maybe 20-30min I don’t know, I didn’t stay at my computer during that time ^^)
But after that time, you are ready to use your new DietPi system, congrats!

DietPi usage tips

DietPi basics

Most of the commands are those from Raspbian or Debian if you know them
If you need help with basic commands on Raspbian/Debian, check that guide on the topic

Once done, I’ll give you a few extra tips for DietPi specifically in the next paragraph

DietPi specific commands

Here are the few commands DietPi offers you to manage your system:

  • To go back to the installation wizard I showed you at anytime, you can use:
    dietpi-software
  • To only see and edit the configuration part (raspbian-config equivalent), just use:
    dietpi-config
    Here you’ll find all the basic things you saw during the installation wizard: network, display, audio, etc.
  • To check if a new DietPi version is available for your Raspberry Pi, use:
    dietpi-update
  • Another great tool I like is to back up your DietPi system, before moving to another device:
    dietpi-backup
    It allows you to save your files to a specific location, you can choose what include or exclude
    And obviously you can restore a backup from here 🙂
  • Here are the other dietpi commands you can check if interested
    I use them less, so I let you try them yourself:
    • dietpi-autostart
    • dietpi-banner
    • dietpi-bugreport
    • dietpit-cleaner
    • dietpi-cron
    • dietpi-drive_manager
    • dietpi-explorer
    • dietpi-justboom
    • dietpi-launcher
    • dietpi-letsencrypt
    • dietpi-logclear
    • dietpi-morsecode
    • dietpi-process_tool
    • dietpi-services
    • dietpi-survey
    • dietpi-sync
  • I didn’t find any full an up-to-date documentation available, so you have to try them and see what happens 🙂
    Most of the time, a wizard opens to ask what you want to do if you just type the command

Conclusion

That’s it, you know what is DietPi and how to install it on your Raspberry Pi (Zero or other models)

I really like this distribution, I think I’ll use more in my projects
If you have good skills on Raspbian Lite, it’ll not change many things, except the easier installation process who is great
And then you have a lightweight distribution to do the same thing as on Raspbian

What do you think?

Leave a Reply

Your email address will not be published. Required fields are marked *