I was looking for other distributions to try on my Raspberry Pi, and among all the failures I found DietPi, which seemed interesting.
I tried it out 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 have learned.
DietPi has a version available for any Raspberry Pi model.
After downloading the image, it can be flashed on a new SD card with Balena Etcher. A wizard will guide you on the first boot to complete the installation.
Here is what I will share with you today: a step-by-step guide, a DietPi presentation, the installation process and a few tips to use it quickly.
If you are looking to quickly progress on Raspberry Pi, you can check out my e-book here. It’s a 30-day challenge, where you learn one new thing every day until you become a Raspberry Pi expert. The first third of the book teaches you the basics, but the following chapters include projects you can try on your own.
What is DietPi?
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!
As its name suggests, DietPi is a lightweight distribution for your Pi.
It’s based on Debian and you can configure it 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 additional software or not (even a desktop environment if you want).
If you want to give it 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
It seems that DietPi has been around since 2015 (I wasn’t able to find clear information, but it’s the forum creation date).
As you may not yet know what DietPi is, here are the main links you can browse to learn more about this distribution:
- The DietPi official website
- The DietPi community forums
- Their Twitter account to follow news and updates
If you still think that DietPi is an interesting distribution to try, let’s move further to learn more :).
Why DietPi rather than Raspberry Pi OS Lite?
As it’s based on Debian, DietPi is close to Raspberry Pi OS Lite, so you might ask yourself why you’d need to choose one or the other.
First thing to note is that DietPi is updated often.
For example, it’s already available in Debian 10.0 (Buster) whereas it’s been available for less than a month at the time of writing.
Here is a short performance comparative I made between DietPi and Raspberry Pi OS Lite.
This will give you a quick overview of the optimizations you can get:
|DietPi||Raspberry Pi OS Lite|
|Image Size||966 MB||1780 MB|
|SD Card usage||2.1 GB||1.2 GB|
|Minimal memory usage||36 MB||110 MB|
|Bootup Time||14 s||15 s|
|Packages installed by default||235||463|
These values are for a fresh new install, with nothing more than default packages, so you might need to compare them in your specific environment.
And, it’s the same result for most of the indicators (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 Raspberry Pi OS most of the time).
How to install DietPi on a Raspberry Pi
Download the DietPi Image
Like for any OS you need basic information 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 available 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, which is my favorite to flash an 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!
Flash the DietPi Image to an SD Card
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:
- Click on the first button, and browse to DietPi image location.
Select it and continue.
- Insert your SD card into 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.
Configure the Wi-Fi Before the First Boot
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, 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 order 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:
This will enable the wireless connection on boot. The SSID and password are in another file.
- You can also quickly check this file to change any 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 in order 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:
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 highly secured networks, such as companies.
- Save and exit.
- Here is what you’re looking for:
- Make sure you close all the files and eject the SD card again.
This time it’s good. We are ready to start the Raspberry Pi.
Start DietPi for the First Time
Insert the SD card into your Raspberry Pi and start it.
A few seconds later, you will be able to 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:
On Windows, you have to install a software, like Putty (download here).
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 Raspberry Pi OS 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 you’ve completed any changes you want, 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). You can do everything later, including installing a desktop environment on a lite version.
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-30 min I don’t know precisely as I didn’t stay at my computer during that time).
But after that, you are ready to use your new DietPi system, congrats!
A few tips to get started with DietPi
Most of the commands are those from Raspberry Pi OS or Debian.
If you need help with basic commands on Raspberry Pi OS/Debian, check this 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 at anytime, you can use:
- To only see and edit the configuration part (raspi-config equivalent), use:
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:
- Another great tool I like is to back up your DietPi system before moving to another device:
It allows you to save your files to a specific location and 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 will let you try them yourself:
- I didn’t find full up-to-date documentation, so you will 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.
Grab your free PDF file with all the commands you need to know on Raspberry Pi!
If you have any comment, suggestion or just want to chat with us about this tutorial,
you can post your messages in the community on Patreon. See you there!
That’s it, you know what DietPi is and how to install it on your Raspberry Pi (Zero or other models).
I really like this distribution, so I think I’ll use more in my projects.
If you have good skills on Raspberry Pi OS Lite, it won’t 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 Raspberry Pi OS.
What do you think?