How to create a Zone in Solaris 10

How to check zones in the Global Zone


  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                                        native   shared
   1  bpass          running    /zones/bpass                native   shared

The directory where the zone will be running need 700 permission


root@/# cd zones
root@/# mkdir -p /newzone
root@/# chmod 700 newzone

root@/# zonecfg -z newzone
Use 'create' to begin configuring a new zone.
zonecfg:newzone>create
zonecfg:newzone>set zonepath=/zones/newzone
zonecfg:newzone>set autoboot=true
zonecfg:capped-memory>set physical=2g
zonecfg:capped-memory>set swap=4g
zonecfg:capped-memory>set locked=1g
zonecfg:capped-memory>end

If you want to create a Whole zone, you will use shared file system, and you can see when you perform a "zonecfg -z newzone info" the following file systems shared


/lib
/platform
/sbin
/usr

However you can remove them in order to avoid the sharing files and create and Sparse Zone


zonecfg:newzone> remove inherit-pkg-dir dir=/lib
zonecfg:newzone> remove inherit-pkg-dir dir=/platform
zonecfg:newzone> remove inherit-pkg-dir dir=/sbin
zonecfg:newzone> remove inherit-pkg-dir dir=/usr
Now you can add the network device to the zone, adding physical device to the zone
zonecfg:newzone> add net
zonecfg:newzone:net> set address=192.168.200.20
zonecfg:newzone:net> set physical=bge0
zonecfg:newzone:net> set defrouter=192.168.200.1
zonecfg:newzone:net> end


Finally you can configure the file systems if you need add in this case we will use LEGACY.

Suppose that you have a zpool-test with a zfs with legacy mountpoint


NAME                                    USED  AVAIL  REFER  MOUNTPOINT
zpool-test                             1.00T   459G    21K  none
zpool-test/apps                   1.00T   459G  13.6G  legacy

zonecfg:newzone>add fs
zonecfg:newzone:fs> set type=zfs
zonecfg:newzone:fs> set special=zpool-test/apps 
zonecfg:newzone:fs> set dir=/apps
zonecfg:newzone:fs> end

Now you can verify and commit the changes done


zonecfg:newzone>verify
zonecfg:newzone>commit
zonecfg:newzone>exit

root@ #zoneadm -z newzone install

When the zone is installed you can boot the zone


root@ #zoneadm -z newzone boot

 

Now you can access with zlogin with the option -C in order to login to the zone console


#zlogin -C newzone
 [Connected to zone 'newzone' console]
 Select a Language
   0. English
   1. es
   2. fr
 Please make a choice (0 - 2), or press h or ? for help: 0
 Select a Locale
   0. English (C - 7-bit ASCII)
   1. Canada (English) (UTF-8)
   2. Canada-English (ISO8859-1)
   3. U.S.A. (UTF-8)
   4. U.S.A. (en_US.ISO8859-1)
   5. U.S.A. (en_US.ISO8859-15)
   6. Go Back to Previous Screen
 Please make a choice (0 - 6), or press h or ? for help: 0
 ...
  Enter the host name which identifies this system on the network.  The name
   must be unique within your

     Host name for bge0:1 newzone
 ...
 ...
 System identification is completed.
 ...

 rebooting system due to change(s) in /etc/default/init

 [NOTICE: Zone rebooting]
 SunOS Release 5.10 Version
 Copyright 1983-2005 Sun Microsystems, Inc.  All rights reserved.
 Use is subject to license terms.
 Hostname: newzone
 newzone console login: root
 Password:
 Feb 17 15:15:30 newzone login: ROOT LOGIN /dev/console
 Sun Microsystems Inc.   SunOS 5.10     October 2007
 #

Regards
Roger

Comments