How to Install DietPi on a Raspberry Pi (Complete Guide)


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 by using 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 get started.

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.

I answer your questions - Raspberry...
I answer your questions - Raspberry Pi FAQ

What is DietPi?

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!

DietPi introduction

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:

Download the Pi Glossary!
If you are lost in all these new words and abbreviations, request my free Raspberry Pi glossary here (PDF format)!

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 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 the 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.).

The best robot kit
Have fun with your Raspberry Pi.
PiCar-X is an AI self-driving robot car for Raspberry Pi.

Buy now Check my review

So for a basic installation, DietPi is really a good choice.
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

Here are the required steps to install DietPi on your Raspberry Pi:

  • Download the image from the official website.
  • Extract the file from the archive and flash it to your SD card.
  • Insert it into your Raspberry Pi and follow the instructions.

Let’s see how to do each step in details.

Download the DietPi Image

Like for any OS, you need a few prerequisites 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).
    You can find my latest 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).

That’s all you need.
A screen, mouse or keyboard is not mandatory if you have a computer and follow all the steps I’ll give you (we’ll connect remotely).
For the software, just two things 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.

    Make sure to pick the one corresponding to your Raspberry Pi model. If you have a recent model, you can download the 64-bit image for increased performances.
  • Then download Balena Etcher, 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.
    You can also use Raspberry Pi Imager if you prefer (DietPi is not in the OS list, but you can flash a custom image with it).

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.

Note: DietPi is one of the rare distributions delivered as a 7zip archive. You need to extract the image manually before going further. It seems that Balena Etcher is not support this file format (you can download 7zip here if needed).

  • Open Balena Etcher.
  • A window 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 into your computer, Etcher will detect it automatically.
    You can ignore your system messages about this SD card.
    It also works fine with a USB drive if you prefer.
  • Finally, click on “Flash!” to start the copy on the media.

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:
      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 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:
      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 highly secured networks, such as in companies.
    • Save and exit.
  • 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 or plug the USB drive to 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 and macOS, it’s available directly in the terminal: ssh user@IP.
    On Windows, you can install a software, like Putty (download here). But on the latest versions, ssh is also available natively in the command prompt.
    puTTy configuration
    Fill the host name with the IP address and click “Open”.

I have a full guide about SSH with a Raspberry Pi. I recommend checking it if you are a bit lost with this step.

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, DietPi will complete a few preparation steps for you and 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 services and applications.
      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.
      Use the arrows to highlight one line, and space to check/uncheck one application.
    • 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.

    You can always use APT later to install any package manually, as on Raspberry Pi OS.

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

It can take some time depending on the model you use and the apps you chose. But after that, you are ready to use your new DietPi system, congrats!

A few tips to get started with DietPi

DietPi basics

Most of the commands are the same as on Raspberry Pi OS or Debian.
If you need help with basic commands on Raspberry Pi OS/Debian, check this guide on the topic.
You can even download my cheat sheet in PDF format to keep them with you all the time.

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 added by DietPi to manage your system:

  • To go back to the installation wizard at anytime, you can use:
    dietpi-software
  • To only see and edit the configuration part (raspi-config equivalent), 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, and you can choose what to include or exclude.
    And obviously, you can restore a previous 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:
    • 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 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.

Video

Reminder: Remember that all the members of my community get access to this website without ads, exclusive courses and much more. You can become part of this community for as little as $5 per month & get all the benefits immediately.

Conclusion

Get My Cheat Sheet!
Grab your free PDF file with all the commands you need to know on Raspberry Pi!

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?
If you are looking for something else, please check my top distributions for the Raspberry Pi here.

Raspberry Pi Resources

Not sure where to start?
Understand everything about the Raspberry Pi, stop searching for help all the time, and finally enjoy completing your projects.
Watch the Raspberry Pi Bootcamp course now.

Master your Raspberry Pi in 30 days
Don’t want the basic stuff only? If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.
Download the e-book.

VIP Community
If you just want to hang out with me and other Raspberry Pi fans, you can also join the community. I share exclusive tutorials and behind-the-scenes content there. Premium members can also visit the website without ads.
More details here.

Need help building something with Python?
Create, understand and improve any Python script for your Raspberry Pi.
Learn the essentials, step-by-step, without losing time understanding useless concepts.
Get the e-book now.

You can also find all my recommendations for tools and hardware on this page.

Patrick Fromaget

I'm the lead author and owner of RaspberryTips.com. My goal is to help you with your Raspberry Pi problems using detailed guides and tutorials. In real life, I'm a Linux system administrator with a web developer experience.

Recent Posts