Virtual Pi

Every time I screw up badly, I end up having to go through to the house, swap SDs on the Raspberry Pi and start another backup. AND I’m told by our friend from Raspbian that I should not be doing this as live backups are asking for problems. Now, to be fair I’ve never HAD A problem with the Raspberry Pi SD copy program but that’s not to say I won’t – and of course none of the other Pi-like machines I own have such a simple backup facility (don’t go giving me a lecture on complex Linux backups please).

tmpD42CAnd so it was that one of our readers (MrShark) put me onto a VPS (virtual Private Server) facility this week – for less than £3 a month you can have your own virtual Debian. I took this up for a trial as I’d had immense difficulty in the past with Virtual PC etc. on my computer due to making the mistake of installing Docker.  So I’ve been playing over the weekend with this VPS service called OVH. Now, their service works really, really well - but the customer service is virtually non-existent as far as I can tell.  It was with that in mind that I grabbed some coffee today and sat down to clean up my Windows 10 PC and install VirtualBox.

I followed the instructions and downloaded a virgin Debian – expecting the same kind of experience that I got out of OVH or one of my little SBCs (I should say at this point that my script – which installs the kitchen sink – works absolutely perfectly on OVH).  Up came a fully-laden Debian complete with graphical desktop and all the trimmings… I went into a terminal and the first thing that came to mind was “sudo apt-get update”.  Well, that’s what you do, isn’t it.

Nope. No “sudo” – never heard of it, mate. This came as something of a shock. Anyway turns out it wasn’t installed, I sorted that and did an update. After a file edit to stop it looking for repositories on a DVD that the VM doesn’t have – I was away with a full update and upgrade. Dare I try my script.

tmpE86DWell, that failed at the first hurdle – virtually every one of the general pre-requisites and utilities I normally install failed miserably. So much for Linux not having the version issues Windows (supposedly) does! Debian isn’t even the same as Debian!

It was at that point of utter despair that my pal Jonathan called in on Skype as if sensing I was getting annoyed. No – you don’t want to do it like that, he said,  there’s a ready-built DIETPI image for VirtualBox.

And so there was.

I grabbed the image from the DIETPI website, loaded it in, created a PI user (I’ve a short script for that, too)  and loaded up my script. NOT A SINGLE ERROR – it’s not even this clean on a proper PI !!! Mosquito, Node-Red, my start-up page, MQTT, SQLITE – it’s all there!!

I’ve done a backup of the basic Debian and a backup of Debian plus all my tools and toys – and now I’m ready to take on the world. For those who don’t know, VirtualBox, DietPi and my script are all available on the web and all available for free. What a great way to test stuff out, now I can make changes to the script fearlessly (my ain is to make it a lot “cleaner” – without all the messages you can’t do anything about), safe in the knowledge that if the whole thing explodes, I’m a button-push away from starting again and it’s all a LOT faster than a PI on my Windows 10 machine (which was super fast about 4 years ago).

Can’t QUITE see how to get the USB emulation going so I can mess with SDs, but no doubt someone reading in here will have figured that out. If you do try out my script – make sure you tell it that this is NOT a real Pi – and don’t try adding GPIO….

DietPi on VirtualBox

Facebooktwittergoogle_pluspinterestlinkedin

25 thoughts on “Virtual Pi

  1. sudo was NEVER a default on STANDARD debian... it exists, but things are done with standard root, debian is for hardcore (well, not like on slackware, or even worst on gentoo...)

    the debian derivative used on SBC are for education (at least it's raspbian), and as such it teachs NOT to do all as an administrator...

    for dietpi, i told you to go that route in an email today... add me on skype, if you need: mrsharkit

    for sd/usb test, you need to add the virtualbox extension pack to enable usb passthrough: you could then pass an usb device from your host to your virtual pc (disconnecting from host, of course), as if you disconnect a dongle from a pc and connect to an other: http://www.virtualbox.org/manual/ch09.html#idm7608

    oh, you can take snapshots of a vm while using it (better if it's shutted down) and revert to that snapshot anytime (i do this before dangerous commands of to test updates)

    1. Well for one thing I can test out new script variations - and who said I don't use DietPi on my SBCs - blog coming up where I look at the Odroid C2 - just about the most powerful of the lot - running DietPi. If you think about it for home control applications - you're probably not using the IO on the Pi or similar - certainly I don't.. so compatibility at the hardware level isn't such a big issue. Actually I was wondering if it would be possible to write a little usb node to make a usb-enabled ESP8266 or Arduino emulate some of the pin operations - so that would work with Node-Red and ANY of the boards - AND the emulator.

      1. why not? Their code base is the same... apart from speed, they share 99% of the same code, except for specific kernel features and for hardware support, of course (virtual environment are very standardized, so developers need to support very few hardware combination... that's the point why exists a DietPI vmware or virtualbox image, and NOT an installable ISO image...)

        1. This sounds interesting. I have 2 questions. I currently run either Ubuntu or Win 10 (same machine). A Diet Pi emulation running locally would be very useful for me - is this possible? Q.2. Is there a foolproof way of transferring a DietPi configuration to a real Pi when its time to put it into production. Thx 🙂

          1. Good morning.

            So I'm not an Ubuntu user but Windows 10 you can run Diet Pi - but don't get confused - this is NOT emulating a Raspberry Pi - it is running Diet Pi which is a perfectly good operating system (Debian modified a bit) to run on a range of SBCs. I am currently running this in a VirtualBox window on Windows 10 as discussed in the blog - lovely. Emulating a Raspberry Pi on the other hand is a no-go - as far as I'm aware there is only some really old emulation software which was never very good in the first place called QEMU - and even that isn't going to emulate the Raspberry Pi hardware.

            Transferring DietPi to Real Pi...if you mean moving the emulation to real hardware I would say NO because they are specific builds for different machines (or virtual machines). Now, whether you could move parts of that over is another matter. For example if you had Node-Red setup and you wanted that transferring, that is merely a matter of ensuring you have the relevant nodes on the "real" machine and transferring a couple of files.

  2. Hi, my comment was supposed to be a reply to Aleksei

    I'm no expert but Ubuntu or any Debian based systems are so similar to Rasbian that I'm not sure I see the purpose of Diet Pi.

    In the past I've run an Ubuntu VPS and can use it to write Python code, run Node-Red and MQTT as well as many things that I might do on a Pi. At home on my desktop I run Linux Mint and the same goes for that, command line, ssh, update, apt-get, they are all the same.

    Making an SD card image from a.n.other Debian system is not possible, one is compiled for Intel type processors and the other is for ARM processors.

    For the avoidance of doubt, burning a Raspberry image to a Raspberry SD card using Debian, Ubuntu or Mint is as easy as anything. So is ssh and file sharing.

    1. so, what's the point? Can we use whatever version we want? Sure we can... is DietPi more suitable for devices with small resources? Yes it is... so? We use it... who cares about other distro or different architecture... having the SAME operating system on a virtual environment (where you can do, destroy and redo things at full speed, while testing) AND on an SBC, reduce the time needed to optimize configurations... then, it's just a matter of installing basic system on an sbc, copying configurations (absolutely portable, they're text files...) and restoring backups, after eventually compiling specific packages not available in standard repositories... the end...

  3. Some words to VPS.
    I also use a VPS Server as MQTT server and Alexa Endpoint. Why not local ? Well, i try to avoid making Port Forwarding holes in my Firewall.

    What i have learned are that most VPS services are provide plain images with less security stuff configured / installed. I'm not a security expert, but please think about following basic things (if not already done).

    + Install some kind of Firewall (UFW, IPtables). Be aware to enable SSH before activate.
    + block any ICMP requests to be hidden for simple PING scanner
    + add an SUDOR user and disable root login on SSH
    + Install fail2ban to block ssh attacker (an there will be a lot of attacker :-))
    + move SSH (and other services running) to an unusual port to be more hidden for scanner (attacker)

    Regards.

  4. All right 🙂
    Anyway, just want to point out to keep security in mind in the fast growing IoT World. Especially in this day and age where everything seems so easy to setup, sadly sometimes at the expense of security. Regards.

  5. For VPS's I can recommend Bluehost, I have 2 with them and you can often find lifetime discounts.

    For Windows, don't forget that Windows 10 now includes an Ubuntu subsystem for free, just turn on developer mode and you get a full Ubuntu command line.

Leave a Reply

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