Home Contact Download

asyd.net

Welcome to Bruno Bonfils's (aka asyd homepage).

Create a zone

Zone configuration

Simple Zone

$ mkdir /zones
$ mkdir /zones/zone1
$ chmod 700 /zones/zone1
$ zonecfg -z zone1
zonecfg> create zone1
zonecfg:zone1> set zonepath=/zones/zone1
zonecfg:zone1> add net
zonecfg:zone1:net> set physical=hme0
zonecfg:zone1:net> set address=192.168.99.42
zonecfg:zone1:net> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit

Zone Initialization

If you want use a sysidcfg file, just copy it in <zonepath>/root/etc/

$ zoneadm -z zone1 install
$ zoneadm -z zone1 boot
$ zlogin -C zone1

Zones extra resources

Using a raw device

zonecfg:squid> add fs
zonecfg:squid:fs> set dir=/var/spool/squid
zonecfg:squid:fs> set special=/dev/md/dsk/d0
zonecfg:squid:fs> set raw=/dev/md/rdsk/d0
zonecfg:squid:fs> set type=ufs

lofs

Loopback fs allow mount global zone's FS from non global zones in read write.

$ zonzonecfg -z zone1
zonecfg:zone1> add fs
# dir is the directory in global zone
zonecfg:zone1:fs> set dir=/usr/pkg
# special is the mountpoint inside the non global zone
zonecfg:zone1:fs> set special=/usr/pkg
zonecfg:zone1:fs> set type=lofs
zonecfg:zone1:fs> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit

Zones administration

Start and stop

# zoneadm -z zone1 boot

Console

# zlogin zone1

The first time you login into a zone, you'll see an initialization counter.

zlogin bindkeys

  • ~. : exit. Since this bindkey is ever used by ssh, I recommand to use zlogin -e \`

Delete a zone

Uninstall zoneadm -z <zone> uninstall
Delete zonecfg -z <zone> delete

Configuration changes

# zonecfg -z zone1
zonecfg:zone1> select net physical=hme0
zonecfg:zone1:net> set address=192.168.99.45
zonecfg:zone1:net> end
zonecfg:zone1:> verify
zonecfg:zone1:> commit

Templates

Create a new template

At this time, the only way i find is to create the xml file by hand (in /etc/zones). I tried to create a template via zonecfg, but I can't save it because the zonepath is invalid. But it's possible to set it to a default value, like the zones root (/export/zone for example)

All inherited-pkg-dir directories will be mount as read-only inside non-global zones.

default.xml

<!DOCTYPE zone PUBLIC "-//Sun Microsystems Inc//DTD Zones//EN" "file:///usr/share/lib/xml/dtd/zonecfg.dtd.1">
<zone name="default" zonepath="" autoboot="false">
  <inherited-pkg-dir directory="/lib"/>
  <inherited-pkg-dir directory="/platform"/>
  <inherited-pkg-dir directory="/sbin"/>
  <inherited-pkg-dir directory="/usr"/>
  <inherited-pkg-dir directory="/usr/pkg"/>
</zone>

Using a template

zonecfg -z ol
zonecfg:ol> create -t default
zonecfg:ol> set autoboot=true
zonecfg:ol> set zonepath=/zones/ol
zonecfg:ol> add net 
zonecfg:ol:net> set physical=hme0
zonecfg:ol:net> set address=192.168.99.45
zonecfg:ol:net> end
zonecfg:ol> verify
zonecfg:ol> commit

See Also