Given a Balena app that can be downloaded as an image and flashed to a device using a USB stick, how can it be used to create a virtual machine? The idea is that it could be distributed to others as an alternative to shipping a physical device.
How do I create VMware or VirtualBox virtual machine from Balena app image?
1.3k Views Asked by James Gentes At
1
There are 1 best solutions below
Related Questions in VIRTUALBOX
- Only 32 bit available in Oracle VM - Hadoop Installation
- How to access Guest's port 3000 from Host?
- vagrant, docker, shared volume not ready on initial provisioning
- scp between two virtual machines in virtualbox
- homestead up not working after vagrant up
- Win7 Virtualbox is giving this error when trying to launch a vm: Error loading 'crypt32.dll': 1790
- VirtualBox: VERR_VMX_MSR_VMXON_DISABLED
- Virtual Box MySQL Server VM constantly timing out
- Docker inside Windows guest virtual machine
- Guest CentOS in virtualbox failed to load GNOME Power manager
- VirtualBox machine - Set to access LAN only
- Virtualbox on Genymotion show an Error when i tried to install it
- Oracle VirtualBox terminated unexpectedly, with exit code -1073741819 (0xc0000005)
- How to change default Nginx setting on Homestead Laravel Virtualbox VM
- is sharding same as distributed database in mongoDB?
Related Questions in VMWARE
- how to set network configuration for vm in esx host through command?
- How do I modify an existing vm template's only ethernet adapter's IP address with pyvmomi
- An Import-Package could not be resolved Error in Deploying Flex UI project
- Issue Building PowerCLI Mass OVF Export Tool
- Why does ioctl(sd, SIOCETHTOOL,&ifreq) on a virtual server running on VMware does not return the hardware address
- How to get server information from VMware
- Is it possible to simulate Linux on USB devices using VMware?
- The type or namespace name 'VimApi' could not be found (are you missing a using directive or an assembly reference?)
- cannot connect to internet from virtual machine
- install errors on astrisknow 6.12-64bit on vmware workstation 8
- How to put file in yum repository?
- Rdrand instrucrtion SIGILL
- VMware encryption library issue
- Getting error while converting VMX to OVF format
- One way communication between vm's?
Related Questions in BALENA
- BalenaOS use Raspberry Pi Compute Module 4 IO board's Real-Time Clock inside container
- Balena API device registration returns "API key must be used for registering"
- Is HTTPS secure if I always send the same message?
- Building with balena-cli (balena build) on travis-ci
- Python ctypes can not locat existing lib in Docker on Balena
- balena does it automatically restart the service
- Issues with installing librealsense with Balena. Unable to locate file after make install?
- How do I create VMware or VirtualBox virtual machine from Balena app image?
- Run install python packages on Dockerfile
- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-xtrlkujj/pyaudio/
- Balena-Enginer (docker) error while copying file to container
- Network Manager fix for Debian Buster
- ERROR: Could not build wheels for netifaces, which is required to install pyproject.toml-based projects
- Curl container command into c#
- Grpc server and client work locally but not on different containers python - StatusCode.UNAVAILABLE
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
There are two main parts to achieving this:
Download an Intel-NUC based Balena device image
Install a very specific version of Docker that still supports AUFS
Windows: https://docs.docker.com/docker-for-windows/release-notes/#docker-community-edition-18061-ce-win73-2018-08-29
Mac: https://docs.docker.com/docker-for-mac/release-notes/#docker-community-edition-18061-ce-mac73-2018-08-29
Open the Docker Desktop settings panel and tick the checkbox
Expose daemon on tcp://localhost:2375 without TLS. Also go to the Shared Drives settings and be sure to share the C drive else you'll get adrive not sharederror when runningbalena preload.Pre-load the Balena image with your app (optional)
Docker must be running properly for the next step to work.
balena preload <img name>.img --app <app #> --splash-image logo.pngConvert the .IMG file to .VMDK
The image needs to be mounted in the virtual machine, similar to plugging in a USB drive, however you can't mount the .img file directly. Unfortunately VMware doesn't have a utility for this (please comment if so) but VirtualBox does.
It must be converted to a .vmdk (virtual disk) using the
VBoxManage convertddcommand.VBoxManage convertdd <img name>.img <img name>.vmdk --format VMDKCreate a VMware virtual machine image
Note: This appears to require VMware Workstation 15 for VMDK compatibility, however there could be ways to get it working with earlier versions if you're ambitious.. perhaps changing the VMDK file type?
You have to modify the VMDK file type from 5 (streamOptimized) to 2 (monolithicFlat). It doesn't matter here, but types 0, 1, and 3 would also work. This is not needed for VirtualBox.
vmware-vdiskmanager -r <source>.vmdk -t 2 <target>.vmdkThis creates a
-flat.vmdkfile that's 4x the size of the original. Note: We're going to attach the 1kb .vmdk file that references that -flat file, not the -flat file itself.Open VMware Workstation (you'll need a license or trial version) and create a new Virtual Machine. Use Custom (advanced) otherwise you won't get the option to specify disk controller type or select an existing disk.
Select a Disk Type- choose SATA as SCSI doesn't support AHCI and it will not boot properly.Select a Disk- choose 'Use an existing virtual disk'Click finish, then edit the virtual machine settings. You need to add a Click
Addon the Hardware tab and selectHard Disk.Note: It is critical that the original Balena VMDK is set to SATA 0:0 otherwise it will not boot properly. It should be already configured as such, but you can click the Advanced button to double check.
If the virtual machine does not boot (ie. gets stuck at a network boot prompt) go to the Settings of the virtual machine > Options tab > Advanced > Firmware type and make sure it is set for UEFI (not BIOS). This should fix the problem.
Click the
Optionstab and go toAdvanced- change the Firmware type fromBIOStoUEFI. If this is not done it will not boot to the Balena VMDK.Skip the next section.
Create a VirtualBox virtual machine image
You should now have a virtual machine created. Edit the settings:
Enable I/O APIC(will not boot otherwise)Enable EFIController: SATAController: SATAand add a new hard diskController: SATANATwhich is what you wantProvision the virtual machine with the Balena image
Now you should have the original VMDK attached for boot and a new virtual disk to provision with the Balena image. Start the virtual machine and open up the Balena dashboard to see it come online (https://dashboard.balena-cloud.com) Once it appears, you should name it something meaningful.
Note: If you see Network PXE as the bootloader and it just hangs, it means you likely haven't changed BIOS setting to UEFI.
The device will enter a Post-Provisioning state. Do not interrupt this process - it will take a few minutes and the virtual machine will power off. Be sure to let it power off on it's own. If it does not turn off, or if you accidentally turn it off, delete the device from Balena and start the virtual machine again - it should provision a new device.
Important: Once it is powered off, go to the virtual machine settings and remove the Balena VMDK disk, otherwise you will re-flash a new image every time you boot. This is the equivalent of removing the USB stick from the device. You should only have one virtual disk attached to
Controller: SATA.At this point you have a virtual machine image that is the equivalent of a physical device. Now the image can be packaged as a virtual appliance so that it can be easily distributed (and users can just double click on and load into VirtualBox or VMware).
Create a virtual appliance from a Balena image
Open VirtualBox or VMware (the process is the same):
File > ExportClick
Exportand that's it!One thing to note: If you send this appliance to 10 people, there will still only be 1 device in Balena, so you may want to create 10 separate appliances instead, which then provision 10 separate devices in Balena.