[Tutorial] DietPi on Vagrant

Guides and tutorials for various stuff. Posted by DietPi users.
Post Reply
User avatar
ravenclaw900
Posts: 19
Joined: Sat Jan 09, 2021 4:05 pm

[Tutorial] DietPi on Vagrant

Post by ravenclaw900 »

Vagrant is a tool for building and managing virtual machines. Specifically, it is for creating easily reproducible development environments. Since I do a lot of development work on DietPi, I thought that this would be a perfect tool to use! For anyone else who wants to develop on DietPi, or just easily create a VM with it, I documented my workarounds. Note that the box I created only works on VirtualBox, since it is the only VM software I have, and this tutorial should work on Linux or macOS. This guide also assumes that you already have Vagrant installed.

First, you should create a directory to work in:

Code: Select all

mkdir dietpi-vagrant
cd dietpi-vagrant
After that, you should download the DietPi Vagrant box:

Code: Select all

vagrant init ravenclaw900/dietpi
This box contains a pre-installed version of DietPi 7.2 (current version as of time of writing). This version contains nothing but what comes pre-installed with DietPi, namely Dropbear and DietPi-RAMLog.
Vagrant expects a vagrant user to use for SSH, but since DietPi only has the dietpi user, we'll have to tell Vagrant to use that. In the newly created Vagrantfile, insert, somewhere between Vagrant.configure("2") do |config| and end:

Code: Select all

  config.ssh.username = "dietpi"
Then, it's just a matter of running:

Code: Select all

vagrant up
You'll probably get a few errors like Connection reset. and Remote connection disconnect. while the machine boots up and runs the timesync, those are okay to ignore.

You now have an easily replacable and managable DietPi virtual machine. To connect to it, just run:

Code: Select all

vagrant ssh
EDIT: Updated image to fix time sync running
Post Reply