WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Resources
    • Nested Virtualization
  • VMware Nostalgia
  • Apple
You are here: Home / Automation / How to build a customizable Raspberry Pi OS Virtual Appliance (OVA)?

How to build a customizable Raspberry Pi OS Virtual Appliance (OVA)?

11.16.2020 by William Lam // 13 Comments

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.

Prerequisite:

  • OVFTool
  • 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:

/root/cleanup.sh

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.

./create_pi_ova.sh

More from my site

  • Packer reference for PhotonOS Arm NFS Virtual Appliance using OVF properties for ESXi-Arm
  • How to run Raspberry Pi OS as a VM on ESXi-Arm
  • Quick Tip - Certificate is not trusted when importing signed OVF/OVA into vCenter Server
  • Auditing vSphere Datastore activities (Download, Upload, Copy, Move, Rename and Delete)
  • Cluster API BYOH Provider on Photon OS (Arm) with Tanzu Community Edition (TCE) and ESXi-Arm

Categories // Automation, ESXi-Arm Tags // Arm, ova, ovf, Raspberry Pi, Raspberry Pi OS

Comments

  1. *protectedPhillip says

    12/31/2020 at 9:03 pm

    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: `.'

    Reply
  2. *protectedKostas Gotsis says

    01/05/2021 at 8:22 am

    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:-)

    Reply
    • William Lam says

      01/05/2021 at 9:48 am

      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

      Reply
      • *protectedPhillip says

        01/05/2021 at 5:42 pm

        Yep. That was the issue. Works in Ubuntu correctly without the -i parameter. Thanks!

        Reply
      • *protectedKostas Gotsis says

        01/13/2021 at 6:46 am

        You can also remove the space between the -i and .bakx. Try "sed -i.bak1..." and you can have your backup too

        Reply
  3. *protectedmorph says

    02/08/2021 at 10:43 pm

    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.

    Reply
  4. *protectedKonstantinos says

    10/20/2021 at 11:33 am

    Hi William,
    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.

    Reply
    • William Lam says

      10/20/2021 at 1:25 pm

      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?

      Reply
  5. *protectedGneeChee says

    08/18/2022 at 6:48 pm

    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

    Any suggestions?

    Reply
    • *protectedGneeChee says

      08/18/2022 at 7:10 pm

      sorry - should have clarified - I had already adjusted the variables in the create script to reflect my environment. They should be good.

      Reply
  6. *protectedDaan says

    01/05/2023 at 1:24 pm

    William, all the best for 2023. and thanks for all your shared knowledge. I come accros the following error when using your script

    Reply
    • *protectedDaan says

      01/05/2023 at 1:26 pm

      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

      Reply
      • William Lam says

        01/05/2023 at 3:43 pm

        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

        Reply

Thanks for the comment!Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025
  • Quick Tip - Validating Broadcom Download Token  05/01/2025
  • Supported chipsets for the USB Network Native Driver for ESXi Fling 04/23/2025
  • vCenter Identity Federation with Authelia 04/16/2025
  • vCenter Server Identity Federation with Kanidm 04/10/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...