{"id":450,"date":"2011-01-11T13:31:17","date_gmt":"2011-01-11T12:31:17","guid":{"rendered":"https:\/\/thebc.ch\/blog\/?p=450"},"modified":"2013-02-01T12:53:26","modified_gmt":"2013-02-01T11:53:26","slug":"solaris-10-zones","status":"publish","type":"post","link":"https:\/\/thebc.ch\/blog\/?p=450","title":{"rendered":"Solaris 10 Zones"},"content":{"rendered":"<div class='toc toc'>\n<h2>Contents<\/h2>\n<ul class='toc-odd level-1'>\n\t<li>\n\t\t<a href=\"#Installation__Setup_of_Zones\">Installation \/ Setup of Zones<\/a>\n\t\t<ul class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Create_the_filesystem_for_the_zone\">Create the filesystem for the zone<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Setup_the_zone\">Setup the zone<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Verify_the_zone_setup\">Verify the zone setup<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Install_the_zone\">Install the zone<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Verify_the_installation_of_the_zone\">Verify the installation of the zone<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Boot_the_zone\">Boot the zone<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Ping_the_zone\">Ping the zone<\/a>\n\t\t\t<\/li>\n\t\t<\/ul>\n\t<li>\n\t\t<a href=\"#Working_with_Zones\">Working with Zones<\/a>\n\t\t<ul class='toc-even level-2'>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Listing_zones\">Listing zones<\/a>\n\t\t\t<\/li>\n\t\t\t<li>\n\t\t\t\t<a href=\"#Login_to_a_zone\">Login to a zone<\/a>\n\t\t\t<\/li>\n\t\t<\/ul>\n\t<li>\n\t\t<a href=\"#Links\">Links<\/a>\n\t<\/li>\n<\/ul>\n<\/ul>\n<\/div>\n<div class='toc-end'>&nbsp;<\/div>\n<span id=\"Installation__Setup_of_Zones\"><h2>Installation \/ Setup of Zones<\/h2><\/span>\n<p><a id=\"Create_the_filesystem_for_the_zone\" name=\"Create_the_filesystem_for_the_zone\"><\/a><\/p>\n<span id=\"Create_the_filesystem_for_the_zone\"><h3>Create the filesystem for the zone<\/h3><\/span>\n<p>The first thing that I do is create a filesystem area for the new zone to reside in. I also mount it under a mount point named \/zone\/1 and I ensure that only the root user has access to it thus:<\/p>\n<pre>$ ls -lap \/zone\r\ntotal 8\r\ndrwxr-xr-x   3 root     other        512 Feb 26 12:42 .\/\r\ndrwxr-xr-x  22 root     root         512 Feb 26 12:42 ..\/\r\ndrwx------   5 root     root         512 Feb 26 13:27 1\/<\/pre>\n<p>&nbsp;<\/p>\n<p><a id=\"Setup_the_zone\" name=\"Setup_the_zone\"><\/a><\/p>\n<span id=\"Setup_the_zone\"><h3>Setup the zone<\/h3><\/span>\n<p>We use zonecfg to create a new zone. Do this from the global zone and as the root user.<\/p>\n<pre>bash-2.05b# zonecfg -z zone1\r\nzone1: No such zone configured\r\nUse 'create' to begin configuring a new zone.\r\nzonecfg:zone1&gt; create\r\nzonecfg:zone1&gt; set zonepath=\/zone\/1\r\nzonecfg:zone1&gt; set autoboot=true\r\nzonecfg:zone1&gt; add net\r\nzonecfg:zone1:net&gt; set address=192.168.35.210\r\nzonecfg:zone1:net&gt; set physical=hme1\r\nzonecfg:zone1:net&gt; end\r\nzonecfg:zone1&gt; info\r\nzonepath: \/zone\/1\r\nautoboot: true\r\npool:\r\ninherit-pkg-dir:\r\n        dir: \/lib\r\ninherit-pkg-dir:\r\n        dir: \/platform\r\ninherit-pkg-dir:\r\n        dir: \/sbin\r\ninherit-pkg-dir:\r\n        dir: \/usr\r\nnet:\r\n        address: 192.168.35.210\r\n       physical: hme1\r\nzonecfg:zone1&gt; verify\r\nzonecfg:zone1&gt; commit\r\nzonecfg:zone1&gt; ^D<\/pre>\n<p>Simple really. The zonecfg tool is interactive and I specified that I want to &#8220;create&#8221; a zone. The filesystem that I created is the new &#8220;zonepath&#8221; and I want this new virtual server to boot along with the global zone when the &#8220;real&#8221; server boots. Who can tell what is &#8220;real&#8221; and what isn&#8217;t? It won&#8217;t matter anymore. I also set the ip address for the zone as well as the interface to bind to. Finally I asked for zonecfg to show me what I just did via the simple &#8220;info&#8221; command. I then used &#8220;verify&#8221; and &#8220;commit&#8221; to ensure that the config is complete. That is all. Nothing fancy.<\/p>\n<p><a id=\"Verify_the_zone_setup\" name=\"Verify_the_zone_setup\"><\/a><\/p>\n<span id=\"Verify_the_zone_setup\"><h3>Verify the zone setup<\/h3><\/span>\n<p>I then used zonecfg and zoneadm to verify that in fact what I had just done was in fact, er, well, done. Really I just like playing with new technology and so will you!<\/p>\n<pre>bash-2.05b# zonecfg -z zone1 info\r\nzonepath: \/zone\/1\r\nautoboot: true\r\npool:\r\ninherit-pkg-dir:\r\n        dir: \/lib\r\ninherit-pkg-dir:\r\n        dir: \/platform\r\ninherit-pkg-dir:\r\n        dir: \/sbin\r\ninherit-pkg-dir:\r\n       dir: \/usr\r\nnet:\r\n        address: 192.168.35.210\r\n        physical: hme1<\/pre>\n<pre>bash-2.05b# zoneadm list -vc\r\n  ID NAME             STATUS         PATH\r\n   0 global           running        \/\r\n   - zone1            configured     \/zone\/1<\/pre>\n<p><a id=\"Install_the_zone\" name=\"Install_the_zone\"><\/a><\/p>\n<span id=\"Install_the_zone\"><h3>Install the zone<\/h3><\/span>\n<p>The next step to perform is to &#8220;install&#8221; the zone.<\/p>\n<pre>bash-2.05b# zoneadm -z zone1 install\r\nPreparing to install zone &lt;zone1&gt;.\r\nCreating list of files to copy from the global zone.\r\nCopying &lt;2521&gt; files to the zone.\r\nInitializing zone product registry.\r\nDetermining zone package initialization order.\r\nPreparing to initialize &lt;808&gt; packages on the zone.\r\nInitializing package &lt;7&gt; of &lt;808&gt;: percent complete: 0%\r\n.\r\n.  &lt; this goes on for some time &gt;\r\n.\r\nInitialized &lt;808&gt; packages on zone.\r\nSuccessfully initialized zone &lt;zone1&gt;.<\/pre>\n<pre>bash-2.05b# df -ak \/zone\/1\r\nFilesystem            kbytes    used   avail capacity  Mounted on\r\n\/dev\/dsk\/c0t1d0s0    1972734   76238 1797860     5%    \/zone\/1<\/pre>\n<p><a id=\"Verify_the_installation_of_the_zone\" name=\"Verify_the_installation_of_the_zone\"><\/a><\/p>\n<span id=\"Verify_the_installation_of_the_zone\"><h3>Verify the installation of the zone<\/h3><\/span>\n<p>Again I use zoneadm to see the results of my actions\u00c2\u00a0:<\/p>\n<pre>bash-2.05b# zoneadm list -vc\r\n  ID NAME             STATUS         PATH\r\n   0 global           running        \/\r\n   - zone1            installed      \/zone\/1<\/pre>\n<p>See that? The STATUS is now &#8220;installed&#8221;.<\/p>\n<p><a id=\"Boot_the_zone\" name=\"Boot_the_zone\"><\/a><\/p>\n<span id=\"Boot_the_zone\"><h3>Boot the zone<\/h3><\/span>\n<p>Now lets boot that new virtual server that we created!<\/p>\n<pre>bash-2.05b# zoneadm -z zone1 boot\r\nbash-2.05b# zoneadm list -vc\r\n  ID NAME             STATUS         PATH\r\n   0 global           running        \/\r\n   2 zone1            running        \/zone\/1<\/pre>\n<p>&nbsp;<\/p>\n<p><a id=\"Ping_the_zone\" name=\"Ping_the_zone\"><\/a><\/p>\n<span id=\"Ping_the_zone\"><h3>Ping the zone<\/h3><\/span>\n<p>I now have a virtual server running? Really? Let&#8217;s ping it\u00c2\u00a0:<\/p>\n<pre>bash-2.05b# ping 192.168.35.210\r\n192.168.35.210 is alive<\/pre>\n<p><a id=\"Working_with_Zones\" name=\"Working_with_Zones\"><\/a><\/p>\n<span id=\"Working_with_Zones\"><h2>Working with Zones<\/h2><\/span>\n<p><a id=\"Listing_zones\" name=\"Listing_zones\"><\/a><\/p>\n<span id=\"Listing_zones\"><h3>Listing zones<\/h3><\/span>\n<ul>\n<li>List all installed zones<\/li>\n<\/ul>\n<pre>root@airlock:\/[70] # zoneadm list -vc\r\n  ID NAME             STATUS         PATH\r\n   0 global           running        \/\r\n   1 mgt              running        \/zone\/mgt\r\n   2 int              running        \/zone\/int\r\n   3 auth             running        \/zone\/auth\r\n   4 mgt_ext          running        \/zone\/mgt_ext\r\n  14 ext              running        \/zone\/ext\r\nroot@airlock:\/[71] #<\/pre>\n<ul>\n<li>List all installed zones<\/li>\n<\/ul>\n<pre>root@airlock:\/[72] # zoneadm list\r\nglobal\r\nmgt\r\nint\r\nauth\r\nmgt_ext\r\next\r\nroot@airlock:\/[73] #<\/pre>\n<p><a id=\"Login_to_a_zone\" name=\"Login_to_a_zone\"><\/a><\/p>\n<span id=\"Login_to_a_zone\"><h3>Login to a zone<\/h3><\/span>\n<pre>usage: zlogin [ -CES ] [ -e cmdchar ] [-l user] zonename [command [args ...] ]<\/pre>\n<pre>root@airlock:\/[74] # zlogin mgt\r\n[Connected to zone 'mgt' pts\/1]\r\nLast login: Wed Dec 27 16:08:30 on pts\/1\r\nSun Microsystems Inc.   SunOS 5.10      Generic January 2005\r\nroot@air-mgt_mgt:\/[4] # exit\r\nlogout\r\n\r\n[Connection to zone 'mgt' pts\/1 closed]\r\nroot@airlock:\/[75] #<\/pre>\n<p><a id=\"Links\" name=\"Links\"><\/a><\/p>\n<span id=\"Links\"><h2>Links<\/h2><\/span>\n<p>Most of this guide was copied from: <a title=\"http:\/\/www.blastwave.org\/articles\/DMC-0002\/index.html\" href=\"http:\/\/www.blastwave.org\/articles\/DMC-0002\/index.html\" rel=\"nofollow\">Get in the Zone<\/a><\/p>\n<p>Another nice Article about Solaris Zones: <a title=\"http:\/\/users.tpg.com.au\/adsln4yb\/zones.html\" href=\"http:\/\/users.tpg.com.au\/adsln4yb\/zones.html\" rel=\"nofollow\">Solaris 10 Zones document written by Brendan Gregg<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installation \/ Setup of Zones Create the filesystem for the zone The first thing that I do is create a filesystem area for the new zone to reside in. I also mount it under a mount point named \/zone\/1 and &hellip; <a href=\"https:\/\/thebc.ch\/blog\/?p=450\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-450","post","type-post","status-publish","format-standard","hentry","category-solaris"],"_links":{"self":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=450"}],"version-history":[{"count":8,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/450\/revisions"}],"predecessor-version":[{"id":2669,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/450\/revisions\/2669"}],"wp:attachment":[{"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thebc.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}