After posting the instructions on how to install Raspberry Pi (rPI) OS into a Virtual Machine running on ESXi-Arm, I was already thinking about an easier consumption method that not only benefited VMware customers interested in running rPI OS as a VM but also the larger rPI OS development community. Just imagine, you can now easily deploy, build and test multiple rPI OS/application on a single physical rPI and get all the benefits of vSphere that many customers have enjoyed for the past two decades.
My goal was to build an rPI OS OVA that would enable some basic guest customization such as networking and configuring the password for the default pi user. As you can see from the screenshot below, I was able to accomplish this with minimal trial/error and works fantastic!
I was initially planning to release the rPI OS OVA as a VMware Fling which can then be made available to the community. However, due challenges in the way rPI OS is distributed today via an image file and the inclusion of packages that makes it difficult for redistribution, I decided to forgo the VMware Fling route and simply publish the instructions with some supplemental scripts that can be used to produce the same rPI OS OVA that I have built for my own personal use.
It would have been great if this could be made available and if anyone from Raspberry Pi organization is reading this and is interested in hosting the download, I would be more than welcome to provide you with OVA file.
- Linux or Mac environment to run the shell scripts
Step 1 – Setup and prepare rPI OS VM on ESXi-Arm as outlined in this blog post. You will also need to install VMware Tools as part of the setup, so the customization can be supported. You can follow the instructions outlined here.
- rc.local – Is the startup script that will automatically run and if system has not been customized, it will execute setup.sh script
- setup.sh – Is the customization script that will process the OVF properties and apply the network and password configuration
- cleanup.sh – Is the initial clean up script that will remove previous commands and shell history prior to shutting down for export
Step 3 – Switch to the root user by running the following command:
sudo su –
Step 4 – Run the following commands to move the three scripts to their final destination on the rPI OS VM:
mv /home/pi/setup.sh /root/setup.sh
mv /home/pi/cleanup.sh /root/cleanup.sh
mv /home/pi/rc.local /etc/rc.local
chmod +x /root/setup.sh
chmod +x /root/cleanup.sh
chmod +x /etc/rc.local
Step 5 – At this point, you can make any other changes that you want to include in the final rPI OS OVA. Once you have finished your customization, go ahead and run the cleanup script which will zero out empty blocks in the OS, clean up the shell history and then shutdown the OS:
Step 6 – Once the rPI OS VM has shutdown, we will export the VM to the OVF format and then apply the OVF template which I have already pre-created. To do so, download create_pi_ova.sh and rpi_ovf_template.xml to your local desktop. Next, you will need to edit the create_pi_ova.sh script and replace the variables with your environment. Once you have finished, save your changes and you can then run the script to start the export and if everything was successful, you should end up with .ova file.