Skip to content

Instantly share code, notes, and snippets.

@wolfeidau
Last active December 9, 2015 20:08
Show Gist options
  • Save wolfeidau/4321681 to your computer and use it in GitHub Desktop.
Save wolfeidau/4321681 to your computer and use it in GitHub Desktop.
Getting started with Development on SmartOS

Introduction

The objective of this post is to get people up and running with SmartOS with enough development tools to do some C/C++ and NodeJS development and take advantage of some amazing tools available only on this platform.

In my case the killer app available on SmartOS is DTrace, which enables me to peak inside a running nodejs application and observe various aspects of it's operation.

Install SmartOS

In my case I normally use the VMWare version of dtrace, this can be downloaded from SmartOS Download Page.

Once downloaded this just needs to be copied to your Documents/Virtual Machines folder and launched by double clicking on the file.

Once booted it will ask you a few questions, most of which are pretty self explanitory.

Setting up a Zone

To really use SmartOS you need a place to install your software and tools, in the case of SmartOS the "root" zone is just a sparse image with enough tools to boot and core administration, if you want to install any user software this should be done in a zone.

SmartOS serves a nicely packaged repository of images ready for you to quickly bootstap zone, note all commands listed must be run as root.

Update the image repository list.

imgadm update

List the available images, as you can see there are quite a few to choose from, I recommend using a base64 image, this can be located using the second command.

imgadm list
imgadm avail | grep 'base64' | tail -1

Using the first token, which is a UUID import that image.

imgadm import fdea06b0-3f24-11e2-ac50-0b645575ce9d

Create a zone definition file as follows, using the previously utilised UUID in the dataset_uuid field.

{
  "brand": "joyent",
  "ram": 2048,
  "vcpus": 2,
    "dataset_uuid": "fdea06b0-3f24-11e2-ac50-0b645575ce9d",
    "nics": [
    {
      "nic_tag": "admin",
      "ip": "dhcp"
    }
  ]
}

Use vmadm to create the zone, not you will need the UUID outputed to log in once it is up and running. This UUID is different to the pervious one used to identify the dataset, this one identifies the zone and can be seen by running zoneadm.

vmadm create -f node.json
vmadm list

Use zlogin to access the console of the zone, once in I normally just create a user and assign it sudo like privledges.

zlogin 6c04902e-a6b0-4eb2-aa87-e6b422e23475
useradd -m -P 'Primary Administrator' -s /bin/bash markw

Set a password for your user.

passwd markw

Once logged in via SSH you may want to su to the root.

pfexec su -

Setting Up the Packages

To start with you need update the repository files and check for upgrades, again all these commands must be run as root.

pkgin update
pkgin upgrade
pkgin full-upgrade

Now we get some tools.

pkgin install zsh tmux p5-ack scmgit

Now we get some development tools.

pkgin install automake autoconf gdb gcc47 gmake

Install node-gyp to enable native builds.

npm install -g node-gyp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment