Saturday, November 4, 2017

Create a Ubuntu Core VM with VirtualBox

There are many ways to get started with Ubuntu Core. One of them is to create an SD card for a Raspberry Pi, or similar small single-board computer. Another is to use KVM on Linux. However, if you are on Windows or OS X then the easiest way is to use VirtualBox. This guide is for OS X and will work on Linux or Windows, however the commands will slightly differ.

To get started, download the image of (ubuntu-core-16-amd64.img.xz) Core 16 from the official site here.

curl "http://releases.ubuntu.com/ubuntu-core/16/ubuntu-core-16-amd64.img.xz" -o "ubuntu-core-16-amd64.img.xz"

Since OS X can't natively extract an xz archive, you can use a program such as The Unarchiver to extract the image file. Then in the same directory as the img file ubuntu-core-16-amd64.img, use VBoxManage to convert it into a VirtualBox hard disk image file (.vdi)

VBoxManage convertdd ubuntu-core-16-amd64.img ubuntu-core-16-amd64.vdi --format VDI

After converting the img file to vdi format, it will need to be expanded in order to install any snaps or work with any development. Using VBoxManage again run the command

VBoxManage modifyhd ubuntu-core-16-amd64.vdi --resize 20480

This will increase the usable size of the disk to 20GB, but will keep the actual size smaller because it will dynamically increase based on usage. Next step is to create a VM inside of VirtualBox, follow the same steps you would to create any new VM. But when it comes time for the hard disk, instead of creating a new disk select "Use an existing hard disk file" and locate the vdi image created in the previous step.


Power on the VM to complete the setup by logging into your Ubuntu SSO account and select the SSH key you'll use to connect to the core instance. Enjoy!

No comments:

Post a Comment