Thursday, October 18, 2007

Creating a New Zone in Nexenta

In the spirit of maintaining and re-factoring this blog, the following instructions have been extracted from previous entries related to building Eclipse and setting up Subversion on Nexenta.

These instructions were originally take from an article on the main Nexenta site.
I generally choose to install large new components (like web servers or source control systems or IDEs whose build-process takes longer than an hour) in their own zone so that I can figure out their dependencies and so that they do not interfere with any of the existing software in my root zone (or so that my root zone does not interfere with the intended operation of the new component). Mainly, I am just tired of re-installing Nexenta because some packages have caused destruction when I have built them in the past (what in the world did the JDK 1.4 and JDK 5 solaris packages do to my /usr/bin simlink!?) It is easier to re-install a zone than it is to re-install the whole OS. Also, by using zones, I can pretend that my scm and database and web servers all exist on different computers on my home network, and that makes me feel like a bigshot.
I did notice one unfortunate side effect to installing a zone for the first time -- for some reason, in / and in the directories off /, there is only 5GB out of 65GB of space available for files. In /export/home/, however all 65GB are available. So my convention is just to install all my zones and all my 3rd-party software off /export/home and to leave that 5GB of space off / just for core OS packages. I think that is reasonable. If you do not find that to be reasonable, then you might want to re-consider using Nexenta zones for now if you cannot find an acceptable way around this issue.
Creating a zone is not quite as straightforward as in the original article and you can see why that is in threads on the Nexenta forum.
These instructions can be performed from a terminal.
  • timezra@nexentaos:~$ sudo zonecfg -z my_zone
    my_zone: No such zone configured
    Use 'create' to begin configuring a new zone.
  • zonecfg:my_zone> create
  • zonecfg:my_zone> set zonepath=/export/home/zones/my_zone
  • zonecfg:my_zone> set autoboot=false
  • zonecfg:my_zone> add net
  • zonecfg:my_zone:net> set address= (or whatever ip address makes sense on your local network)
  • zonecfg:my_zone:net> set physical=sfe0
  • zonecfg:my_zone:net> end
  • zonecfg:my_zone> remove inherit-pkg-dir dir=/lib
  • zonecfg:my_zone> remove inherit-pkg-dir dir=/platform
  • zonecfg:my_zone> remove inherit-pkg-dir dir=/sbin
  • zonecfg:my_zone> remove inherit-pkg-dir dir=/usr
  • zonecfg:my_zone> verify
  • zonecfg:my_zone> commit
  • zonecfg:my_zone> ^D
  • timezra@nexentaos:~$ zoneadm list -vc (this will tell you if my_zone is configured)
  • timezra@nexentaos:~$ sudo vi /usr/lib/nexenta-zones/elatte-unstable.bootstrap
  • Replace the reference to jkaudio-toolsva8233 in work_out_debs() with sunwvia823x
  • timezra@nexentaos:~$ sudo zoneadm -z my_zone install
  • find the directory in / with a name like a UUID
  • timezra@nexentaos:~$ sudo mv /<UUID>/root /export/home/zones/my_zone/root
  • timezra@nexentaos:~$ sudo rmdir <UUID>
  • timezra@nexentaos:~$ sudo zoneadm -z my_zone boot
  • timezra@nexentaos:~$ zoneadm list -vc (my_zone should now be running)
  • timezra@nexentaos:~$ sudo zlogin my_zone
    [Connected to zone 'my_zone' pts/2]
Congratulations, you are now logged into my_zone!

No comments: