HomePage » SolarisZone
Solaris Zone
This is based on OpenSolaris:1. Setup a path / zfs for use with this zone, I'll call it "vm1".
zfs create rpool/vm1 zfs set quota=12G rpool/vm1 chmod 700 /rpool/vm1
2. Enable resource pool and save this setting
pooladm -e pooladm -s
3. Create a resource pool
# Create a processor set with min/max 1cpu poolcfg -c 'create pset vm1-pset (uint pset.min=1; uint pset.max=1)' # Create pool and associate it with the above processor set poolcfg -c 'create pool vm1-pool' poolcfg -c 'associate pool vm1-pool (pset vm1-pset)' # Activate and save pooladm -c pooladm -s # Display config pooladm
4. Create the zone
zonecfg -z vm1 zonecfg:vm1> create zonecfg:vm1> set zonepath=/rpool/vm1 zonecfg:vm1> set autoboot=true #boot with host zonecfg:vm1> add net zonecfg:vm1:net> set address=192.168.1.101/24 zonecfg:vm1:net> set physical=iprb0 # vm1 will be using iprb0:1 zonecfg:vm1:net> set defrouter=192.168.1.254 zonecfg:vm1:net> end zonecfg:vm1> set pool=vm1-pool # associate this vm with this resource pool zonecfg:vm1> verify # good if returns nothing zonecfg:vm1> commit zonecfg:vm1> exit
5. Install the zone
zoneadm -z vm1 install zoneadm -z vm1 boot zlogin -C vm1 zoneadm -z vm1 reboot zoneadm list -v root@knote:~# zoneadm list -v ID NAME STATUS PATH BRAND IP 0 global running / native shared 2 vm1 running /rpool/zone1 ipkg shared zlogin vm1
6. Get out of zlogin - Use the escape code ~.
vm1 console login: ~. [Connection to zone 'vm1' console closed]
7. Install package
pkg search top pkg install SUNWtop pkg install SUNWapch22
Cloning a zone
Export the config from the source zone. Then edit it to reflect the storage location and IP of the new zone
zonecfg -z vm1 export > vm2.cfg vi vm2.cfg
Create the target zone with the edited config
zonecfg -z vm2 -f vm2.cfg
Shutdown the source zone and clone it to the target
zoneadm -z vm1 halt zoneadm -z vm2 clone vm1
List zones
zoneadm list -vi
Boot up both zones, then login to the new zone and edit the various settings.
zoneadm -z vm1 boot zoneadm -z vm2 boot zlogin -C vm2
Rebooting
If the host needs a reboot, shutdown all zones with the halt commandzoneadm -z <zone name> halt
If only the zone needs a reboot, use the reboot command
zoneadm -z <zone name> reboot