Create and run a Baserock Virtual Machine

Currently this guide applies only for x86 machines

Introduction

When creating a virtual machine for developing with Baserock, you should note the following:

  • If it isn't enabled already then you will need to enable virtualisation in your BIOS settings (VT-x).
  • Apart from choosing whether your CPU is 32-bit or 64-bit, don't change the settings from the defaults, we have had reports of kernel panics from people who have changed these settings.
  • The root disk should be an IDE hard disk, not virtio. For now, Baserock hardcodes the root filesystem to be on partition /dev/sda1 to avoid having an initramfs.
  • You should have a second disk attached to the VM for storing all your own files. This allows you replace the root disk with a different version of Baserock, but keep your own files. Make the second disk be at least 30 gigabytes and preferably 100 gigabytes in size.
  • You probably want to have at least 2 gigabytes of memory for development (linking is especially hungry for memory) and two cpu cores in the VM (compiling is CPU hungry). 2 gigabytes will be sufficient for doing C programming for embedded, or Python/Ruby/Javascript programming for cloud. Languages with more memory hungry tools - C++, Java, Haskell - you want at least 4GB, and if you have a system that can use it, 8 or more. More memory and more cores is always nice.

Download the VM image

Download the x86 64-bit raw build disk image from the Download page. (Not the base image, which does not contain morph)

The instructions below assume you saved the downloaded raw image as baserock-current-build-x86_64.img.gz. If you downloaded the 32-bit image, or you saved the image with a different name, you will need to adapt the instructions below accordingly.

Using Virt-Manager

This is the easiest option, especially for anyone who has never used a VM before.

First, extract the build image to the desired location.

Next, make sure you have virtualisation enabled in BIOS (vt-x).

Now, install and configure KVM:

# Install KVM
sudo apt-get install qemu-kvm

sudo adduser `id -un` kvm

and install Virt-Manager:

# Install Virt-Manager
sudo apt-get install virt-manager

Open Virt-Manager. Click 'create a new VM' (the sparkly computer in the top left). Name your VM whatever you like, and pick the 'import existing disk image' option. Now, browse to the baserock build image you just extracted-- after you click 'browse', you'll need to click 'browse local' in the bottom left. Don't worry about the other settings; go forward and give the VM a minimum of 2 CPUs and 2000MB RAM. Go forward again, and don't worry about advanced options, but make sure to check the 'customise configuration before install' box before you click finish.

Now you need to attach a second disk to the VM, to store your own files. Click the 'add hardware' button on the bottom left. Go to 'storage', and change the value to 30GB. The rest of the defaults are fine.

Finally, click 'begin installation' (the green tick on the top left). If all goes to plan, you should get a message saying 'Thank you for trying baserock. Baserock login:'

Now return to the 'Quick start' page to use your baserock VM.

Using Ubuntu or Debian with KVM

Copy or move the downloaded raw disk image to the directory where you would like to store your VM images.

Bring up a shell prompt, navigate there, and do the following:

# Install KVM
sudo apt-get install qemu-kvm

sudo adduser `id -un` kvm

Log out and in again.

# unzip the downloaded rawimage
gunzip baserock-current-build-system-x86_64.img.gz

# create a second hard drive for your own files
fallocate -l $((30*1024*1024*1024)) baserock_src.img

# Start the virtual machine
kvm -hda baserock-current-build-x86_64.img -hdb baserock_src.img -net nic -net user,hostfwd=tcp::5555-:22 -m 2048

A window will open in which the Baserock VM will boot to a login prompt.

/dev/hdb in the VM will be a blank 30 gigabyte hard disc.

Your Baserock VM is now running: return to the 'Quick start' page to carry on using it.

Using VirtualBox on Mac OS X, Windows, and other Unices

Install VirtualBox for your operating system and make sure its command line tools are in your path: in a terminal session, type

VBoxManage --version

On Windows, if you don't already have it, install the gzip commandline tools. These come as standard with Visual Studio 2013 or better, or from msysgit.

Copy or move the downloaded raw disk image to the directory where you would like to store your VM images e.g.

  • in Mac OS: /Users/yourusername/vm-images
  • in Windows: C:\Users\yourusername\VirtualBox VMs
  • in Linux: ~/VirtualBox

Start a Terminal session in that directory, and run the following commands:

# unzip the downloaded image
gzip -d baserock-current-build-system-x86_64.img.gz

# Convert the raw image to VDI format
VBoxManage convertdd baserock-current-build-system-x86_64.img baserock-current-build-system-x86_64.vdi --format VDI

# Create a blank vm (you can use --basefolder option to choose to put it
# somewhere specific rather than in the default Virtualbox VMs folder)
VBoxManage createvm --name Baserock --ostype Linux_64 --register

# Set up memory, networking and other hardware. The `bridegadapter1` argument must be an active network interface
VBoxManage modifyvm Baserock --ioapic on --memory 2048 --nic1 bridged --bridgeadapter1 en0

# If your host machine cpu has multiple cores, now would be a good time to
# configure your VM to use them - for a machine with 4 cores
VBoxManage modifyvm Baserock --cpus 4

# Add a SATA controller:
VBoxManage storagectl Baserock --name "SATA Controller" --add sata --bootable on --portcount 2

# Attach the hard disc to the image file you downloaded
VBoxManage storageattach Baserock --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium baserock-current-build-system-x86_64.vdi

# Create a second 30 gig hard disc:
VBoxManage createhd --filename baserock_src.vdi --size $((30*1024))

# Attach the second hard disc
VBoxManage storageattach Baserock --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium baserock_src.vdi

# Start it up:
VBoxManage startvm Baserock

Your Baserock VM is now running: return to the 'Quick start' page to carry on using it.

Using QEMU on Mac OS X

This assumes you have installed QEMU - both MacPorts (port install qemu) and Homebrew (brew install qemu) have QEMU packages. Mac OS X doesn't support sparse files, so you should create a QCOW2 image for use with the VM.

Copy or move the downloaded raw disk image to the directory where you would like to store your VM images (e.g. /Users/yourusername/vm-images)

Start a Terminal session in that directory, navigate there, and do the following:

gunzip baserock-current-build-system-x86_64.img.gz

qemu-img create -f qcow2 baserock_src.img 30g

qemu-system-x86_64 -hda baserock-current-build-x86_64.img -hdb baserock_src.img -net nic -net user,hostfwd=tcp::5555-:22 -m 1024

A window will open in which Baserock will boot to a login prompt.

The steps in 'Setting up a serial console' below should not be necessary.

Your VM is now running: return to the 'Quick start' page to see what to do next.

For general instructions for how to set up virtualization, see the list below (and please add a link to your favorite operating system's instructions):