(February 2020 onwards) WMT Pi VMs

A forum for discussion on the software for the WMT River Control System
hamishmb
Posts: 1891
Joined: 16/05/2017, 16:41

(February 2020 onwards) WMT Pi VMs

Post by hamishmb »

Patrick came up with a clever way of shrinking the VM images to around 1 GB. We decided to upload them to the web server to make sure we don't lose them. Note that you need Virtualbox www.virtualbox.org to use these, as VDI format is required for some of the features.

There are available at https://wmtprojectsforum.altervista.org ... stem%20VMs.
Last edited by hamishmb on 25/05/2022, 12:40, edited 1 time in total.
Hamish
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Smaller Pi VMs available on webserver

Post by TerryJC »

Interesting!

I haven't quite got my head around all this yet, but by following the instructions in the README.md file, I have managed to get four of the VMs working:
  • The base image.
  • SumpPi.
  • Wendy Butts Pi.
  • V4 Gate Valve.
I have some comments and questions (and probably more later):
  1. In the file 'Verbose notes on creating the VMs', Patrick says that he doesn't know where "Reference 1.1.4" is. That's shorthand for Table 1.1, Item 4 - The Software Design Spec. (Yes I know that's not obvious, but it's fairly standard practice to do references like that in Industry.
  2. I notice that the configuration of the copies of Raspbian is different to the real Pis. I'm assuming that's because these VMs are based on Debian and not the X86 version of Raspbian. Two things that I've noticed are that the tool raspi-config doesn't seem to be installed (it default on native Raspbian) and that the IP address is set up through /etc/network/interfaces and not via /etc/dhcpcd.conf as it is in the real Pis. I don't see this as a real problem, but it threw me at first.
Now for the questions:
  1. Does the Base Image have to be running for the Pis to work? The README.md seems to say that, but I was able to load the SumPi VM without first loading the Base Image.
  2. In the file 'Verbose notes on configuring the VMs', Patrick says that he used scp to copy the Software Framework onto the VM. Presumably, the PC and the Pi have to be in the same subnet for that to work? My Router uses 192.168.1.*, so that would be a departure from the real Pi's configuration.
  3. Is there any reason why we can't create a shared folder on the VM so that files can be copied to and from the running machine?
Terry
PatrickW
Posts: 146
Joined: 25/11/2019, 13:34

Re: Smaller Pi VMs available on webserver

Post by PatrickW »

TerryJC wrote: 06/03/2020, 17:17 In the file 'Verbose notes on creating the VMs', Patrick says that he doesn't know where "Reference 1.1.4" is. That's shorthand for Table 1.1, Item 4 - The Software Design Spec. (Yes I know that's not obvious, but it's fairly standard practice to do references like that in Industry.
Noted. I haven't come across that specific type of table-row referencing before.

The verbose notes were really written as an aid to my own understanding, so you'll have noticed they're quite informal. I thought it as well to include them, since they were the best documentation I had. If we're using the VMs, it might be worth me writing something more formal, though I'd like to finish the Stage Pi control algorithm first.
TerryJC wrote: 06/03/2020, 17:17 I notice that the configuration of the copies of Raspbian is different to the real Pis. I'm assuming that's because these VMs are based on Debian and not the X86 version of Raspbian.
I am not aware that there is an x86 version of Raspbian, otherwise I would have used it. I spent quite a while digging around looking for one, but it seems to me that Raspbian is an ARM-only distribution.

In any case, the other hardware differences would probably have put pay to using raspi-config.
TerryJC wrote: 06/03/2020, 17:17 Now for the questions:
  1. Does the Base Image have to be running for the Pis to work? The README.md seems to say that, but I was able to load the SumPi VM without first loading the Base Image.
No, the base image does not have to be running. It just has to be loaded into the list of VMs in VirtualBox before any of the other ones are loaded into the list, because it contains the disk image which they refer to. Probably my wording could have been clearer.
TerryJC wrote: 06/03/2020, 17:17 [*]In the file 'Verbose notes on configuring the VMs', Patrick says that he used scp to copy the Software Framework onto the VM. Presumably, the PC and the Pi have to be in the same subnet for that to work?
Yes and no. If you set up the networking using a host only network, as I did, then your PC will have a virtual network interface directly into the virtual Pi network, and on that interface your PC will have an IP address in the correct subnet. This is in addition to your existing network interface(s) and IP addresses, which remain as they are. (The IP address and subnet mask for your PC to use on the virtual interface is specified in the host-only networking config in VirtualBox.)

So, your PC can continue to use the usual addressing to connect to the router, while simultaneously being able to connect to the Pis using their normal subnet.

Where this could cause an issue is if your router happened to be using the same subnet as the Pis, because then you'd have two network interfaces in the same subnet but connected to different networks, causing a conflict. In that situation, you'd have to opt for a different virtual network configuration to keep the virtual Pi network isolated from your PC. (Or you could use a "bridged adapter" configuration to connect the Pis directly to your real network, if there is nothing else on it that uses the same IP addresses.)
TerryJC wrote: 06/03/2020, 17:17 [*]Is there any reason why we can't create a shared folder on the VM so that files can be copied to and from the running machine?[/list]
I suppose in principle it would be possible, but it never crossed my mind that it would be worth doing.
Last edited by PatrickW on 06/03/2020, 19:53, edited 3 times in total.
PatrickW
Posts: 146
Joined: 25/11/2019, 13:34

Re: Smaller Pi VMs available on webserver

Post by PatrickW »

A note regarding host-only networking configuration:

In the README, I based my instructions on VirtualBox 5.1.38_Ubuntu r122592 from the Ubuntu repository.

We discovered that, in the latest version from Oracle, the configuration for Host-only Networks has been moved. If I remember correctly, it now has a dedicated menu entry in the File menu. The basic principles of the configuration are identical; they've just rearranged the GUI a bit.
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Smaller Pi VMs available on webserver

Post by TerryJC »

PatrickW wrote: 06/03/2020, 18:34 The verbose notes were really written as an aid to my own understanding, so you'll have noticed they're quite informal. I thought it as well to include them, since they were the best documentation I had. If we're using the VMs, it might be worth me writing something more formal, though I'd like to finish the Stage Pi control algorithm first.
No need to do that. The Installation Spec is the right place for the info and I'll include it. I will ask for the draft to be reviewed in due course.
PatrickW wrote: 06/03/2020, 18:34I am not aware that there is an x86 version of Raspbian, otherwise I would have used it. I spent quite a while digging around looking for one, but it seems to me that Raspbian is an ARM-only distribution.
The x86 version is available on the Raspberry Pi Downloads page.
PatrickW wrote: 06/03/2020, 18:34In any case, the other hardware differences would probably have put pay to using raspi-config.
It's a while since I used it; it has limited value anyway. I think there's a cut-down version of raspi=config.
PatrickW wrote: 06/03/2020, 18:34Yes and no. If you set up the networking using a host only network, as I did, then your PC will have a virtual network interface directly into the virtual Pi network, and on that interface your PC will have an IP address in the correct subnet. This is in addition to your existing network interface(s) and IP addresses, which remain as they are. (The IP address and subnet mask for your PC to use on the virtual interface is specified in the host-only networking config in VirtualBox.)
I'll look into that.
PatrickW wrote: 06/03/2020, 18:34I suppose in principle it would be possible, but it never crossed my mind that it would be worth doing.
I've always used the Shared Folder in VMs, which is why I thought of it.
Terry
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Smaller Pi VMs available on webserver

Post by TerryJC »

PatrickW wrote: 06/03/2020, 18:36We discovered that, in the latest version from Oracle, the configuration for Host-only Networks has been moved. If I remember correctly, it now has a dedicated menu entry in the File menu. The basic principles of the configuration are identical; they've just rearranged the GUI a bit.
Yes. I found it in the end.
Terry
PatrickW
Posts: 146
Joined: 25/11/2019, 13:34

Re: Smaller Pi VMs available on webserver

Post by PatrickW »

TerryJC wrote: 06/03/2020, 18:52 The x86 version is available on the Raspberry Pi Downloads page.
Oh yes, there it is. How on earth did I miss that?! :P Though, I see that it isn't actually Raspbian; rather it's Debian with some Raspberry Pi things installed, so it might not be all that different from what we've ended up with. Still, it might be worth a look if we need to rebuild the VMs at some point.
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Smaller Pi VMs available on webserver

Post by TerryJC »

It just occurred to me that this has the desktop, so it isn't much use to us.
Terry
TerryJC
Posts: 2616
Joined: 16/05/2017, 17:17

Re: Smaller Pi VMs available on webserver

Post by TerryJC »

OK. I've spent a bit of time this morning copying Patrick's instructions for creating, configuring and using these VMs into an Annex to the Installation Spec. At one point, Patrick says:
## NAS Box VM

One thing I can't easily recreate is Hamish's NAS Box VM; I don't know what to install on it or how it must be configured. Instead, I'll just copy Hamish's one and fstrim it for distribution.

Unfortunately, I did not know the IP address or login username of the NAS VM. I booted TinyCore Linux on it and used that to read the filesystem to obtain this information. The IP address on the second network interface is 192.168.0.250, and the user is nas, with password river17 as on the Pis.

It seems to run MySQL and Apache.
I too know very little about what goes on inside the NAS Box other than what Hamish has told me. The IP Address was originally specified in the Software Design Spec as 192.168.0.25 (not 250) and at some point this will have to be changed if 250 is used in the hardware. The reason for this is that the Webserver in the Railway Room Store runs a DHCP Server which allocates IP Addresses to Visitor's devices when they log into the WiFi. This server has reserved the DHCP range of 192.168.0.100 to 253, so if we ever get 150 visitors, there's likely to be a conflict.

I don't see this being a major issue yet, (if ever), but it will need fixing eventually. Of course we could always limit the DHCP range to 192.168.0.100 to 249, but that would involve a change to the Webserver code.

Additionally, if Hamish can furnish us with the minimum information, how easy would it be to set up a NAS Box VM in the same way as the others?
Terry
PatrickW
Posts: 146
Joined: 25/11/2019, 13:34

Re: Smaller Pi VMs available on webserver

Post by PatrickW »

As far as I'm concerned, I think it's fine for the NAS box to be an exception in the VM set-up, because it's not a Pi and doesn't run the same software. We can't really use the same base image for the NAS as we do for the Pis, because they have different sized disks (20GB vs 8GB) with different partitions on them (the Pis use a swap file instead of a swap partition). There's little benefit in trying to make two VMs share a base image if their partitions and basic OS installation are not identical.

The only thing I really changed about Hamish's NAS VM was to enable the "discard" option for its virtual disk image, and to add the corresponding "discard" configuration in /etc/fstab on the guest Debian OS. The rest is just making sure we know what software packages need to be installed on it, and how to configure them. I imagine the virtual NAS box is far simpler to set up than the real one, given that most or all of the packages it needs are probably available as pre-compiled Debian packages.

Regarding my instructions, I've just thought of some details which I didn't explicitly put in, but which are not necessarily obvious:
  1. You should close VirtualBox completely while making manual edits to the XML virtual machine definition files. (Changing absolute file paths to relative.)
  2. I did not explain why I deviated from VirtualBox's defaults when I specified paravirtualised network adaptors. This is a habit of mine when setting up VMs, because paravirtualised networking is so much more resource-efficient and performant than emulated network adaptors. In this application it probably won't make much difference, but there's no good reason not to use it here, so I enabled it as a matter of course.
Post Reply