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.
Step 2 - Download the rc.local, setup.sh and cleanup.sh shell scripts and upload them to the rPI OS VM.
- 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.
Hi William, thanks for the work here. I am getting this error when the script tries to process the first sed line of the create_pi_ova.sh script:
sed: -e expression #1, char 1: unknown command: `.'
Kostas Gotsis says
There must be an error in create_pi_ova.sh script at the sed commands. How should the xml file be embedded tin the ova file?
Great Idea and quite handy:-)
William Lam says
I just realized the 'sed' syntax is different on macOS which requires you to specify backup file -i, you can remove -i and its argument and that should work. If so, I'll fix it up so it can detect the underlying OS
Yep. That was the issue. Works in Ubuntu correctly without the -i parameter. Thanks!
Kostas Gotsis says
You can also remove the space between the -i and .bakx. Try "sed -i.bak1..." and you can have your backup too
Can you please explain Step 6 a bit more. For someone like me who has very rarely worked on a "naked" ESXi it is hard to guess the next neccesary steps needed to get the image to work as a "template" now. It´s realy frustrating to get to step 6 and than hit a wall there 😉 Especially on what I have to paste where in both files.
Thank you for the sharing and effort to make those amazing tutorials for ARM-based ESXi hosts. I already made all the steps but i now stack on step 6 as i don't have a vCenter implementation on my environment.
William Lam says
OVF properties are the best supported when you have vCenter Server. I'm not 100% sure if you'll be able to deploy OVA with OVF properties directly to ESXi UI, you can try and see if it works?
Hiya. Great stuff, but ... like others, I'm stuck at #6. This is what I'm getting:
./create_pi_ova.sh: line 12: unexpected EOF while looking for matching `"'
./create_pi_ova.sh: line 15: syntax error: unexpected end of file
sorry - should have clarified - I had already adjusted the variables in the create script to reflect my environment. They should be good.
William, all the best for 2023. and thanks for all your shared knowledge. I come accros the following error when using your script
create_pi_ova.sh... with the following error: .
/create_pi_ova.sh: line 12: unexpected EOF while looking for matching `"'
./create_pi_ova.sh: line 14: syntax error: unexpected end of file
any idea for a fix? i am using ubuntu and have vcenter running
William Lam says
Can you try removing both .bak entries, the script was created on MacOS which doesn't use GNU sed ... that would be the only thing that stands out to me