Reputation: 419
I am trying to simulate a intel a NUC gateway in virtualbox. I am running this virtual box in amazon EC2 instance . I could not able to view GUI of my desktop due to poor connectivity. Hence started using command line to create Virtual machine. Below are my steps:
Created an application in resin.io and picked up intel nuc board as application and downloaded the image
converted the .img to .vmdk image and kept this image in my ec2 instance
Now I created my virtual machine in EC2 using command line arguments and when i try to import this image .. I am struck up.. I am not getting the relevant commands
Upvotes: 3
Views: 3384
Reputation: 196
(see edit below!)
Looks like this is not currently possible with AWS EC2. They have good basic info and detailed step-by-step guide to import virtual machine images, but the resin.io image does not fit their operating systems prerequisits: basically an OS image running on top of EC2 would need to have be one of the listed OS types (Ubuntu, Red Hat, SUSE, etc), but the resin.io image is a custom Linux system, and it's not accepted by the EC2 platform. I've tried to run their import procedures, and all different kinds of attempts were rejected.
Would recommend trying different way of running the virtual machine. If you are just trying a virtual device (I guess based on this blogpost), and you don't need a NUC image, just any virtual device would do, then there are also QEMU-based images available on resin.io now, that should work to run on your local machine too (those won't work on EC2 either, because of the same reason).
Edit:
Re-reading your question, it's a lot less about EC2 itself, and it's more about VirtualBox, my apologies. VBoxManage has extensive documentation. In this case here's a script that would work to set up and start a resin.io NUC image on VirtualBox on the command line.
What's needed: downloaded NUC image from resin.io dashboard, and converted into a VMDK image. Install VirtualBox on the host machine, copy the VMDK there, then modify the settings in the file below (adjusting the available memory, disk storage, and file names as needed).
The script will:
And then your machine is ready to run.
#!/bin/bash
## Fill in these Variables
# the virtualmachine's name
MACHINE=MyMachine2
# memory in MB
MEMORY=2048
# storage in MB
STORAGE=8096
# resin installation media path & filename
RESIN_DISK="resin-MyApplication-1.8.0-1.13.0-eb7236d1bd7e.vmdk"
# Storage disk, by defalt created in the current working directory!
DISKFILE="./${MACHINE}.vdi"
###
## Convert the original image to a Virtualbox image as:
# VBoxManage convertdd resin.img resin.vmdk --format vmdk
# and then use RESIN_DISK="resin.vmdk" above
echo "Createing Machine" && \
VBoxManage createvm --name "$MACHINE" \
--ostype Linux_64 \
--register && \
\
echo "Setting up Machine" && \
VBoxManage modifyvm "$MACHINE" \
--memory $MEMORY \
--ioapic off \
--firmware efi64 \
--rtcuseutc on && \
\
echo "Createing Storage Controller" && \
VBoxManage storagectl "$MACHINE" \
--name SATA \
--add sata && \
\
echo "Creating Main Disk" && \
VBoxManage createmedium disk \
--filename "$DISKFILE" \
--size $STORAGE && \
\
echo "Attaching Main Disk" && \
VBoxManage storageattach "$MACHINE" \
--storagectl SATA \
--port 0 --device 0 --type hdd --medium "$DISKFILE" && \
\
echo "Attaching Resin Install Media" && \
VBoxManage storageattach "$MACHINE" \
--storagectl SATA \
--port 1 --device 0 --type hdd --medium "$RESIN_DISK" && \
\
echo "Starting machine for first time setup" && \
VBoxHeadless --startvm "$MACHINE" && \
\
echo "Removing install media" && \
VBoxManage storageattach "$MACHINE" \
--storagectl SATA \
--port 1 --device 0 --type hdd --medium none && \
\
echo -e "You now can start machine for future use as: \nVBoxHeadless --startvm \"$MACHINE\""
Extra:
As a side note, if you are working on the command line, you can also get the required resin.io image over the command line too!
Install the resin-cli onto your host machine, and use resin login
to log in (using e.g. your API key from the Dashboard / Preferences section at resin.io),
Download a bare OS image for the NUC, for example:
resin os download intel-nuc -o intel-nuc.img
Create a configuration for your application, let's say your application's name is MyApp:
resin config generate --app MyApp -o config-MyApp.json
Then add this configuration to your image:
sudo resin config inject config-MyApp.json --type intel-nuc --drive intel-nuc.img
(For this, you might have to run sudo resin login
so you are able to use sudo with the resin command correctly.)
After this you can do the conversion of intel-nuc.img
to VMDK format, and set up your virtual machine as mentioned above.
Upvotes: 2