一个建立ZONE的简单步骤刚刚在自己机器上测试通过:
# zonecfg
usage: zonecfg help
zonecfg -z <zone> (interactive)
zonecfg -z <zone> <command>
zonecfg -z <zone> -f <command-file>
Commands:
add <resource-type>
(global scope)
add <property-name> <property-value>
(resource scope)
cancel
clear <property-name>
commit
create [-F] [ -a <path> | -b | -t <template> ]
delete [-F]
end
exit [-F]
export [-f output-file]
help [commands] [syntax] [usage] [<command-name>]
info [<resource-type> [property-name=property-value]*]
remove [-F] <resource-type> [ <property-name>=<property-value> ]*
(global scope)
remove <property-name> <property-value>
(resource scope)
revert [-F]
select <resource-type> { <property-name>=<property-value> }
set <property-name>=<property-value>
verify
# zonecfg -z test-zone
test-zone: No such zone configured
Use 'create' to begin configuring a new zone.
zonecfg:test-zone> create
zonecfg:test-zone> set zonepath=/export/home/test-zone
zonecfg:test-zone> set pool=pool_default
zonecfg:test-zone> add inherit-pkg-dir
zonecfg:test-zone:inherit-pkg-dir> ?
The 'inherit-pkg-dir' resource scope is used to configure a directory
inherited from the global zone into a non-global zone in read-only mode.
Valid commands:
set dir=<path>
And from any resource scope, you can:
end (to conclude this operation)
cancel (to cancel this operation)
exit (to exit the zonecfg utility)
zonecfg:test-zone:inherit-pkg-dir> set dir=/opt
zonecfg:test-zone:inherit-pkg-dir> end
zonecfg:test-zone> add net
zonecfg:test-zone:net> ?
The 'net' resource scope is used to configure a network interface.
Valid commands:
set address=<IP-address>
set physical=<interface>
See ifconfig(1M) for details of the <interface> string.
set defrouter=<IP-address>
set address and set defrouter are valid if the ip-type property is set to shared, otherwise they must not be set.
And from any resource scope, you can:
end (to conclude this operation)
cancel (to cancel this operation)
exit (to exit the zonecfg utility)
zonecfg:test-zone:net> set physical=pcn0
zonecfg:test-zone:net> set address=192.168.0.221
zonecfg:test-zone:net> end
zonecfg:test-zone> verify
zonecfg:test-zone> commit
zonecfg:test-zone> exit
# zonecfg -z test-zone info
zonename: test-zone
zonepath: /export/home/test-zone
brand: native
autoboot: false
bootargs:
pool: pool_default
limitpriv:
scheduling-class:
ip-type: shared
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
inherit-pkg-dir:
dir: /opt
net:
address: 192.168.0.221
physical: pcn0
defrouter not specified
# zoneadm -z test-zone install
zoneadm: zone 'test-zone': WARNING: pools facility not active; zone will not be bound to pool 'pool_default'.
Preparing to install zone <test-zone>.
Creating list of files to copy from the global zone.
Copying <2894> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1245> packages on the zone.
Initialized <1245> packages on zone.
Zone <test-zone> is initialized.
The file </export/home/test-zone/root/var/sadm/system/logs/install_log> contains a log of the zone installation.
#
# zoneadm list -vc
ID NAME STATUS PATH BRAND IP
0 global running / native shared
- test-zone installed /export/home/test-zone native shared
# zoneadm -z test-zone boot
zoneadm: zone 'test-zone': WARNING: pools facility not active; zone will not be bound to pool 'pool_default'.
zoneadm: zone 'test-zone': WARNING: Pools facility not active; zone will not be bound to pool
# zoneadm list -v
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 test-zone running /export/home/test-zone native shared
# zoneadm list -vc
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 test-zone running /export/home/test-zone native shared
# zlogin test-zone
[Connected to zone 'test-zone' pts/6]
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
# ifconfig -a
lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
inet 127.0.0.1 netmask ff000000
# df -h
Filesystem size used avail capacity Mounted on
/ 44G 7.1G 37G 17% /
/dev 44G 7.1G 37G 17% /dev
/lib 5.6G 4.9G 655M 89% /lib
/opt 5.6G 4.9G 655M 89% /opt
/platform 5.6G 4.9G 655M 89% /platform
/sbin 5.6G 4.9G 655M 89% /sbin
/usr 5.6G 4.9G 655M 89% /usr
proc 0K 0K 0K 0% /proc
ctfs 0K 0K 0K 0% /system/contract
mnttab 0K 0K 0K 0% /etc/mnttab
objfs 0K 0K 0K 0% /system/object
swap 2.1G 272K 2.1G 1% /etc/svc/volatile
/usr/lib/libc/libc_hwcap1.so.1
5.6G 4.9G 655M 89% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 2.1G 4K 2.1G 1% /tmp
swap 2.1G 0K 2.1G 0% /var/run
# id
uid=0(root) gid=0(root)
# hostname
test-zone