Welcome to Machine Unix

Search Below

Beginning with SmartOS

If you happened to have a copy of the latest release of VMware Fusion, you can  start with SmartOS in your Mac Mountain Lion right now.

The following post is intended to be a very simple introductionary tutorial for SmartOS. It is really to fun to play with and it will show how powerful it can be if you actually had the iron instead.

So what is SmartOS? SmartOS is a hypervisor and a live image based on Illumos. It is Joyent’s operating system and it is a technology that contains KVM, ZFS, Zones ( Operating System Virtualization ), Networking Stack, and Analytics tools like Dtrace. It is a memory based installation so that one can take advantage of mobilization, low footprint etc.

Ok now we explained what SmartOS is, then what is a SmartMachine? It is the Virtual Machine that can be run on top of SmartOS. A SmartMachine is an Operating System Virtualization.

I do recommend to run SmartOS in a real iron instead of in your Mac but as a learning experience, I think it is a good start. I should note that we will be doing Virtualization within virtualization ( Vmware + SmartOS ) which defeats the whole virtualization purpose but as I mentioned it is a place to start.

Lets get our hands dirty. You will need the following two:

1) Download the free trial of VMware Fusion 5.

2) Download the latest SmartOS release from this location, for the purpose of this tutorial, I recommend for you to download the vmware image.

Once you download the Vmware image, then unzip the tarball and import it into Fusion by doubleclicking the resulting .vmwarevm image.

Next click upgrade, and then click “I copied it”. The following grub image installer will take place.

GrubInstaller

At this point, I recommend for you to shutdown  the machine so that you can configure your VirtualMachine to take advantage of VT-x/EPT extensions and networking. In order to do that, click “Virtual Machine” -> “Settings” -> “Processors and Memory”. Depending on your mac hardware you can set how many cores you can use etc. In this example I am using 2 and increasing the Memory to 2048 M. In the Advanced Menu options, make sure you click “Enable hypervisior applications in this virtual machine”

SmartOS_-Processors-Memory1

Next Click “Network Adapter” from your Removable Devices and

SmartOS_-Settings

set Bridged Networking to “Wi-Fi” if your network adapter is used by your wifi:

SmartOS_-Network-Adapter

Next Click the Start Button, then the installer will start and it will ask you setup questions. I used configuration settings like the following one:

SmartOSConf

After that it will tell you that the system configuration is finished and it’ll reboot. When it finishes, you will see the following:

boot

Now. you can ssh into the hypervisor or you can continue from vmware image console. I used ssh.

[drende@lem ~]$ ssh root@192.168.1.198
The authenticity of host ‘192.168.1.198 (192.168.1.198)’ can’t be established.
RSA key fingerprint is 6a:25:01:ff:f7:15:44:8a:c4:fe:fb:7e:1b:40:15:0d.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.1.198’ (RSA) to the list of known hosts.
Password:
Last login: Sat Sep 1 03:49:00 2012 from 192.168.1.121
– SmartOS Live Image v0.147+ build: 20120823T215330Z
[root@00-0c-29-6c-22-8a ~]# ping www.google.com
www.google.com is alive
[root@00-0c-29-6c-22-8a ~]#

Now that the hypervisor is installed, let’s utilize it. I will demonstrate two examples here, first we are going to create a SmartMachine, then we are going to create a Linux KVM. The kvm machine will be a Centos Machine.

1 – Create a SmartMachine

Before we dive into this, I strongly suggest that you make yourself familiar with smartos.org website and read about terminology. We will need to use predefined Joyent datasets to provision each machine and I will follow up with smartos.org entry from here.

1) Check to see if sources.list file exits. It should, if not you can create one:

[root@00-0c-29-6c-22-8a ~]# cat /var/db/imgadm/sources.list

https://datasets.joyent.com/datasets

2) List available datasets and choose which dataset you would like to use:

[root@00-0c-29-6c-22-8a ~]# imgadm update
updating local images database…
Get https://datasets.joyent.com/datasets…
done
[root@00-0c-29-6c-22-8a ~]# imgadm avail
UUID OS PUBLISHED URN
6bf31ce2-f384-11e1-a338-e39c2fe4ab59 smartos 2012-08-31 sdc:sdc:mongodb:1.3.2
a0f8cf30-f2ea-11e1-8a51-5793736be67c smartos 2012-08-30 sdc:sdc:standard64:1.0.7
3390ca7c-f2e7-11e1-8818-c36e0b12e58b smartos 2012-08-30 sdc:sdc:standard:1.0.7

I am going to use “sdc:sdc:base:1.7.1 ” dataset to provision my smartmachine. This may take a bit depending on your internet connection.

[root@00-0c-29-6c-22-8a ~]# imgadm import 3766d58c-d777-11e1-89c1-4fa1b8ed5c1e
3766d58c-d777-11e1-89c1-4fa1b8ed5c1e doesnt exist. continuing with install
3766d58c-d777-11e1-89c1-4fa1b8ed5c1e successfully installed
image 3766d58c-d777-11e1-89c1-4fa1b8ed5c1e successfully imported

So what we did was to import a dataset called “base:1.7.1″ and we will provision a SmartMachine based on this dataset. To do this, we’ll need to use a definition file by using the dataset UUID we just imported:

[root@00-0c-29-6c-22-8a ~]# cat /tmp/zonedef

{
“brand”: “joyent”,
“dataset_uuid”: “3766d58c-d777-11e1-89c1-4fa1b8ed5c1e “,
“nics”: [
{
“nic_tag”: “admin”,
“ip”: “192.168.1.197”,
“netmask”: “255.255.255.0”,
“gateway”: “192.168.1.1”
}
]
}

The command to create the virtual machine is called vmadm.

[root@00-0c-29-6c-22-8a ~]# vmadm create -f /tmp/zonedef
Successfully created d74be495-2079-4c5e-b2b8-14ebcec1c643

So let’s check what we have in the hypervisor:

[root@00-0c-29-6c-22-8a ~]# zoneadm list -civ
ID NAME STATUS PATH BRAND IP
0 global running / liveimg shared
2 d74be495-2079-4c5e-b2b8-14ebcec1c643 running /zones/d74be495-2079-4c5e-b2b8-14ebcec1c643 joyent excl
[root@00-0c-29-6c-22-8a ~]#

Great, above command shows that our zone with ID 2 is installed an running and it resides under  /zones. The document suggests that we do a zlogin with the UUID ( a command to login a zone from a Global Zone ):

[root@00-0c-29-6c-22-8a ~]# zlogin d74be495-2079-4c5e-b2b8-14ebcec1c643
[Connected to zone ‘d74be495-2079-4c5e-b2b8-14ebcec1c643’ pts/2]
__ . .
_| |_ | .-. . . .-. :–. |-
|_ _| ;| || |(.-‘ | | |
|__| `–‘ `-‘ `;-| `-‘ ‘ ‘ `-‘
/ ; SmartMachine (base 1.7.1)
`-‘ http://wiki.joyent.com/display/jpc2/SmartMachine+Base

[root@d74be495-2079-4c5e-b2b8-14ebcec1c643 ~]#

Let’s check the uname and ip address:

[root@d74be495-2079-4c5e-b2b8-14ebcec1c643 ~]# uname -a
SunOS d74be495-2079-4c5e-b2b8-14ebcec1c643.local 5.11 joyent_20120823T215330Z i86pc i386 i86pc Solaris
[root@d74be495-2079-4c5e-b2b8-14ebcec1c643 ~]# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
net0: flags=40001000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4,L3PROTECT> mtu 1500 index 2
inet 192.168.1.197 netmask ffffff00 broadcast 192.168.1.255
ether c2:9c:be:c:3f:69
lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> mtu 8252 index 1
inet6 ::1/128

Great, so we effectively created the a SmartMachine and logged in via a command called zlogin. You can also use ssh by using the IP address.

2 – Create a Virtual Machine

We use exact same steps above with minor changes:

1  – List available datasets:

….

a77907fc-123b-11e1-86d8-2bb3c7c6aaf2 linux   2011-11-18 sdc:sdc:centos6:0.1.0

….

2 – Import the Centos dataset:

[root@00-0c-29-6c-22-8a ~]# imgadm import a77907fc-123b-11e1-86d8-2bb3c7c6aaf2
a77907fc-123b-11e1-86d8-2bb3c7c6aaf2 doesnt exist. continuing with install

a77907fc-123b-11e1-86d8-2bb3c7c6aaf2 successfully installed
image a77907fc-123b-11e1-86d8-2bb3c7c6aaf2 successfully imported

3 – The vmzone definition file is different than the previous one, take a look:

[root@00-0c-29-6c-22-8a ~]# cat /tmp/myvmspec

{
“brand”: “kvm”,
“resolvers”: [
“208.67.222.222”,
“8.8.4.4”
],
“default-gateway”: “192.168.1.1”,
“ram”: “512”,
“vcpus”: “1”,
“nics”: [
{
“nic_tag”: “admin”,
“ip”: “192.168.1.177”,
“netmask”: “255.255.255.0”,
“gateway”: “192.168.1.1”,
“model”: “virtio”,
“primary”: true
}
],
“disks”: [
{
“image_uuid”: “a77907fc-123b-11e1-86d8-2bb3c7c6aaf2”,
“boot”: true,
“model”: “virtio”,
“size”: 10240
}
]

Some explanation is due here. First notice the brand definition, it is replaced with kvm here because we are working on a Linux KVM. Second, we added a virtio driver definition. It is necessary to include it here. We also defined what should be the disk size of the Virtual Machine, which is 10G.

4 – Let’s create the machine based on this definition file:

[root@00-0c-29-6c-22-8a ~]# vmadm create -f /tmp/myvmspec
Successfully created a4e9d571-80af-4b98-a8e0-9ebb3935782e

Very nice, It looks like the VM is created. But how do we actually login to this machine ? It does not work with a zlogin command because this is basically a QEMU process:

[root@00-0c-29-6c-22-8a ~]# ps -ef | grep qem | grep -v grep
root 4409 4359 2 05:35:33 ? 0:54 /smartdc/bin/qemu-system-x86_64 -m 512 -name a4e9d571-80af-4b98-a8e0-9ebb393578

So we will use a vnc console/client instead. We will need to have the port number of the machine and we can get it from using vmadm info:

root 3718 1 0 04:57:50 ? 0:00 zsched
[root@00-0c-29-6c-22-8a ~]# vmadm info a4e9d571-80af-4b98-a8e0-9ebb3935782e vnc
{
“vnc”: {
“host”: “192.168.1.198”,
“port”: 59602,
“display”: 53702
}
}

By using a client like Chicken of the VNC or JollyFast VNC add the IP address 192.168.1.198 and Display information from above:

VNC-Login

When you click connect, you will be prompted to the login screen. I went ahead and logged in as root:

centoslogin

Notice the output of /etc/redhat-release, you have just installed Centos VM on top of SmartOS.

The aim of this tutorial was to show how SmartOS is easy to use and how powerful it can get. I hope you enjoyed reading it. Most of the credit goes  to smartos.org in this tutorial and I just showed you to do the same thing in your Vmware Fusion Software. Let me know what you think and give me any type of feedback.