Back
2 min read

Snappy Ubuntu Core on SmartOS hypervisor

Snappy Ubuntu Core has been announced two days ago. I was counting that sooner or later there will be some alternative to Project Atomic and here we are. What I found a bit surprising was the immediate compatibility with Microsoft Azure. I also found this statement:

Microsoft loves Linux[…]

Creepy.

All is fine and whatever, but there’s not many places you can play with Snappy on. Or are there? How about SmartOS?
Well, Canonical delivers KVM image that may be converted and deployed as an VM.

Converting image

KVM image that is delivered needs to be converted to RAW image – this will allow later on using simply dd for deploying it as a VM. Problem is, that Linux box is needed for this task as qemu on SmartOS is outdated and is unable to convert images. You have two choices – either download image converted and gziped by me (skip to the next section in such case) or follow instructions provided below:

wget -c http://cdimage.ubuntu.com/ubuntu-core/preview/ubuntu-core-alpha-01.img  
qemu-img convert -O raw ubuntu-core-alpha-01.img ubuntu-core-alpha-01.raw  
pigz ubuntu-core-alpha-01.raw  

Once that is done, be sure to copy/upload this file to your SmartOS hypervisor.

Deploying on SmartOS

Steps on SmartOS are quite self-explanatory. First of all, gather image. If you haven’t generated one yourself, you may use wget command provided below. (You may want to read a bit more about certain parts of my configuration in my previous post about running Gentoo VM on SmartOS).

And here’s my snappy.json file for the reference:

{
  "brand": "kvm",
  "autoboot": false,
  "ram": "512",
  "vcpus": 2,
  "alias": "19-snappy",
  "resolvers": ["8.8.8.8", "8.8.4.4"],
  "nics": [
    {
      "nic_tag": "dmz0",
      "ip": "192.168.0.19",
      "netmask": "255.255.255.0",
      "gateway": "192.168.0.1",
      "model": "virtio",
      "primary": true
    },
    {
     "interface": "lan0",
     "nic_tag": "lan",
     "ip": "10.0.0.19",
     "netmask": "255.255.255.0",
     "model": "virtio"
    }
  ],
  "disks": [
    {
      "boot": true,
      "model": "virtio",
      "size": 20480
    }
  ]
}

Once converted image is in place and json file for the VM template is prepared let’s make some party with these two:

vmadm create -f /opt/templates/snappy.json
Successfully created VM d0c443e8-dbdd-4297-9946-cdd2ea0c5a6e

Creating VM will also automatically boot it. It’s necessary to have this step in place to properly determine which block device should be used.
Usually I’m exporting UUIDs to some human-readable format:

export snappy=d0c443e8-dbdd-4297-9946-cdd2ea0c5a6e

Now is time to gather information about block device that Snappy will be deployed to:

vmadm info $snappy block

[...]
"file": "/dev/zvol/rdsk/zones/d0c443e8-dbdd-4297-9946-cdd2ea0c5a6e-disk0"
[...]

Note (or export) the PATH to some convenient place and stop the VM:

vmadm stop -f $snappy

Next command can take a while, so it might be a good idea to put into nohup or screen session:

dd if=/opt/iso/ubuntu-core-alpha-01.raw of=/dev/zvol/rdsk/zones/d0c443e8-dbdd-4297-9946-cdd2ea0c5a6e-disk0 bs=1M

That’s it. VM is ready to roll:

vmadm start $snappy
Successfully started VM d0c443e8-dbdd-4297-9946-cdd2ea0c5a6e

That’s it. You may run vmadm console $snappy or connect via SSH if you set up NAT for this port to this VM.

vmadm console $snappy

Ubuntu Vivid Vervet (development branch) localhost.localdomain ttyS0

localhost login:

Be sure to check out Snappy Ubuntu Core page with instructions on what to do next.

In case of further questions or suggestions, don’t hesitate to spam me on twitter! (: