/ SmartOS

Installation of MIBE

Provisioning SmartOS zones by using one of the available base images is easy and fast. By using a sane configuration management solution the resulting machine should also be the same every time.

But if you need the same machine over and over again or maybe need to setup hundreds of zones that should all be alike there is a faster method of getting it done.

By creating an own image for a specific type of machine there is no real need to install additional packages using your configuration management tool of choice. This cuts down machine initialization time, almost to the speed of machine provisioning.
It also saves disk space as all cloned machines share the same underlying filesystem. Only changes that differ from the underlying clone, will consume additional space.

There is currently one automated solution to build those SmartOS images - MIBE.
It will create a new image based off a simple template folder and even create a fully usable manifest for direct installation via imgadm.
Mibe will only work for SmartOS zones. There currently is no support for KVM. Creating a Linux image is still a manual procedure.

MIBE is a tool created inside Joyent to help their engineering team build their own machine images. (it is not a tool Joyent gives professional support for)

I'll give instructions on how to prepare a SmartOS box to build images using MIBE. As MIBE needs to be run inside the SmartOS global zone, access to the global zone as root is needed to actually install all requirements and snapshot the zone for imaging.

Instructions on how to customize a template in order to build a custom image follows.

Preparing the SmartOS box

We'll need to fetch MIBE and ensure it is placed in the appropriate location in the global zone.
There are two major solutions to this:

  1. We can just fetch the tarball from github and extract that
    this will result in a working MIBE, but we can't git push/pull our templates
  2. Bootstrap pkgsrc into the global zone to get access to git

After we have MIBE installed we need to prepare a template zone. This template zone will be used by MIBE to build our images. It is mostly needed due to the network and routing configuration, so that MIBE is able to fetch packages from inside the zone that will be our resulting image in the future.

This template zone does not need to be created over and over again.
A single template zone can build all our images - over and over again.

With all this in place the SmartOS box should be ready to roll out images.

Quick route: installing from tarball

  1. Fetch the compressed tarball from github
  2. Extract it to /opt
  3. Rename the resulting folder /opt/mibe-master to /opt/mibe

There currently is a tiny issue in MIBE where it tries to exeute pkgin in the global zone instead of the template zone.
While this is open it will refuse to work without pkgsrc bootstrapped in the global zone.

Because of that I'll fetch from my forked repository instead.

$ wget --no-check-certificate https://github.com/MerlinDMC/mibe/archive/master.tar.gz -O - | gzcat | tar -xf - -C /opt mibe-master && mv /opt/mibe{-master,}

Developer friendly: bootstrap pkgsrc and git clone

  1. Select and fetch the pkgsrc bootstrap package (a list of available bootstrap packages can be found here)
  2. Update the package database
  3. Install the git commandline program
  4. Clone the MIBE repository

I'm using the bootstrap-2014Q2-tools.tar.gz variant here. This is a limited set of software packages meant to be used for administration tools and is located at /opt/tools rather than the normal /opt/local.

$ wget --no-check-certificate http://pkgsrc.joyent.com/packages/SmartOS/bootstrap/bootstrap-2014Q2-tools.tar.gz -O - | gzcat | tar -xf - -C /
$ /opt/tools/bin/pkgin up
$ /opt/tools/bin/pkgin in git-base
$ /opt/tools/bin/git clone git://github.com/MerlinDMC/mibe.git /opt/mibe

Creating the MIBE template zone

I'll select the latest base64 image available for this template zone. This image needs to be imported via imgadm and a simple json for vmadm will create our zone with a single nic using dhcp.
A static IP could be used as well - change to suite the environment if needed.

$ BASE64_IMAGE_UUID=$(imgadm avail | awk '/base64/ { print $1 }' | tail -1)
$ imgadm import $BASE64_IMAGE_UUID
$ vmadm create << EOF
  "brand": "joyent",
  "image_uuid": "$BASE64_IMAGE_UUID",
  "alias": "mibe template zone",
  "hostname": "mibe",
  "dns_domain": "l.l0cal.net",
  "resolvers": [
  "max_physical_memory": 1024,
  "quota": 20,
  "nics": [
      "nic_tag": "admin",
      "ip": "dhcp",
      "primary": "true"

This should result in some "good" response from vmadm and we should see the template zone running in vmadm list.

$ vmadm list
UUID                                  TYPE  RAM      STATE             ALIAS
d0950a6d-11ab-4194-81c7-9e7629d84207  OS    1024     running           mibe template zone

At this point the SmartOS box is good to go and can start building images.