How to create a Freebsd VM inside SmartOS

SmartOS (http://smartos.org/) needs no introduction: essentially a type 1 hypervisor, running headless, with Illumos as the kernel. (http://wiki.illumos.org/display/illumos/About+illumos). OpenIndiana and several other distribution are also using Illumos as the kernel.

Bryan Cantrill has given a good talk here: http://smartos.org/2011/12/15/fork-yeah-the-rise-and-development-of-illumos-2/

To create a FreeBSD VM inside SmartOS, here are the detailed instructions:

http://wiki.smartos.org/display/DOC/How+to+create+a+KVM+VM+%28+Hypervisor+virtualized+machine+%29+in+SmartOS

After inserting the CD (with SmartOS image burned in), bootup, and at the command line, search for the UUID for FreeBSD:

imgadm avail |grep freebsd

imgadm import <UUID>

(the <UUID> come from imgadm list), this will essentially download the entire image from the web.

Downloading the image from the web is slow, so after some time has passed:

vmadm list

UUID NAME VERSION OS PUBLISHED
df8d2ee6-d87f-11e2-b257-2f02c6f6ce80 freebsd 1.0.0 bsd 2013-06-19T01:30:49Z

d34c301e-10c3-11e4-9b79-5f67ca448df0 base64 14.2.0 smartos 2014-07-21T10:43:17Z

The FreeBSD image is downloaded. So next is to create a manifest file with all the necessary attributes (as adapted from here: http://wiki.smartos.org/display/DOC/How+to+create+a+KVMVM+%28+Hypervisor+virtualized+machine+%29+in+SmartOS).

More important, the corresponding image’s manifest as when it was created can be read off here:

https://images.joyent.com/images/df8d2ee6-d87f-11e2-b257-2f02c6f6ce80

Notice the matching UUID. Notice also the “virtio” for disk, and NIC. Changing the value to other value (eg, “ide” for disk, or “e1000” for NIC card) will gives error when booting up the VM OS.

File named as “freebsd.json”:

{

"alias": "freebsd9",
"hostname": "freebsd9",
"brand": "kvm",
"resolvers": [

    "208.67.220.220",
    "8.8.8.8",
    "8.8.4.4"
  ],
"ram": "512",
"vcpus": "1",
"default-gateway": "192.168.88.1",
"nics": [
    {
      "nic_tag": "admin",
      "ip": "192.168.88.176",
      "netmask": "255.255.0.0",
      "gateway": "192.168.88.1",
      "model": "virtio",
      "primary": true
    }
  ],
"disks": [
    {
      "image_uuid": "df8d2ee6-d87f-11e2-b257-2f02c6f6ce80",
      "boot": true,
      "model": "virtio",
      "image_size": 10240
    }
  ]
}

Finally:

vmadm create -f freebsd.json

And from the response, “Successfully created VM 74787fa5-509a-4c5d-91eb-dc07dc10662e”:

vmadm info 74787fa5-509a-4c5d-91eb-dc07dc10662e

This will generate a massive amount of display about the attributes of the 747xxxx UUID image.

In particular:

vmadm info 74787fa5-509a-4c5d-91eb-dc07dc10662e vnc
{
"vnc": {
"host": "192.168.88.173",
"port": 38032,
"display": 32132
}

Using the above information, we can use VNC to log in into that port, and see all the console messages (and graphical display as well). In this case, the SmartOS hypervisor is also providing some VNC server services.

And this will allow you to login via console port (serial port) as well:

vmadm console 74787fa5-509a-4c5d-91eb-dc07dc10662e

Reboot the VM machine:

vmadm reboot 74787fa5-509a-4c5d-91eb-dc07dc10662e

Other subcommands for vmadm are:

vmadm
Usage: /usr/sbin/vmadm <command> [options]

create [-f <filename>]
create-snapshot <uuid> <snapname>
console <uuid>
delete <uuid>

delete-snapshot <uuid> <snapname>

get <uuid>
info <uuid> [type,...]
install <uuid>
list [-p] [-H] [-o field,...] [-s field,...] [field=value ...]
lookup [-j|-1] [-o field,...] [field=value ...]
reboot <uuid> [-F]
receive [-f <filename>]
reprovision [-f <filename>]
rollback-snapshot <uuid> <snapname>
send <uuid> [target]
start <uuid> [option=value ...]
stop <uuid> [-F]
sysrq <uuid> <nmi|screenshot>
update <uuid> [-f <filename>]
-or- update <uuid> property=value [property=value ...]
validate create [-f <filename>]
validate update <brand> [-f <filename>]

Reference:

Basic knowledge:

http://wiki.smartos.org/display/DOC/How+to+create+a+Virtual+Machine+in+SmartOS

http://wiki.smartos.org/display/DOC/How+to+create+a+KVM+VM+%28+Hypervisor+virtualized+machine+%29+in+SmartOS

http://wiki.smartos.org/display/DOC/Building+SmartOS+on+SmartOS

http://blog.smartcore.net.au/smartos-fundamentals/

http://wiki.joyent.com/wiki/display/sdc/How+to+Create+a+Seed+Virtual+Machine+Image

Debugging techniques of Illumos (through VirtualBox, or can be easily modified to QEMU) is given here:

https://tthtlc.wordpress.com/2012/02/18/illumos-startup-analysisdebugging-using-virtualbox/

https://plus.google.com/116279478726976353287/posts/iVHeK77rP4Q

Lots of help from the community (http://webchat.freenode.net/?channels=smartos):

http://echelog.com/logs/browse/smartos/1411336800

http://echelog.com/logs/browse/smartos/1411077600

http://echelog.com/logs/browse/smartos/1411336800

One of my earlier bugs in manifest (which does not matches that from Joyent in NIC and disk attribute): http://pastebin.com/CvA5tum3

http://wiki.smartos.org/download/attachments/755905/nlosug.pdf?version=1&modificationDate=1341336501000

Advertisements

One response to this post.

  1. In my journey to fully understand SmartOS there is nothing more important than this:

    http://wiki.smartos.org/display/DOC/Installing+Joyent+SmartOS+onto+a+Bootable+Disk+Partition

    In short: just boot it off the CD all the time, use the whole machine (and thus the entire harddisk as well) to boot, and ensure VMX (Intel) is enabled (SVM seemed to be in development stage, and mine AMD-SVM is not working). Anything you do in the default global zone is non-persistent, so create a local zone (via “imgadm avail” and “imgadm import”) if you want to do any persistent stuff.

    This is really non-conventional stuff.

    http://smartos.org/2011/08/16/ryans-rough-guide-to-the-smartos-iso

    Reply

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: