Solaris Containers (formally zones) cheat sheet
There are two types of zones global and non-global. The global zone is the server itself and is used as the system-wide configuration and control, there can only be one global zone per system. A maximum of 8192 non-global zones can exist on a system, all non-global zones are isolated from each other.
There are two type types of non-global zones sparse root zone or whole root zones.
whole root zone | Solaris packages are copied to the zone's private file system. Disk space usage is much greater than using a sparse zone |
sparse zone | You can determine how much of the global zone file system you want to be inherited from the global zone. Sparse zones use loopback file systems from global zone. Use the inherit-pkg-dir resource to specify which directories to inherit. |
Zone States
Configured | Configuration has been completed and storage has been committed. Additional configuration is still required. |
Incomplete | Zone is in this state when it is being installed or uninstalled. |
Installed | The zone has a confirmed configuration, zoneadm is used to verify the configuration, Solaris packages have been installed, even through it has been installed, it still has no virtual platform associated with it. |
Ready (active) | Zone's virtual platform is established. The kernel creates the zsched process, the network interfaces are plumbed and filesystems mounted. The system also assigns a zone ID at this state, but no processes are associated with this zone. |
Running (active) | A zone enters this state when the first user process is created. This is the normal state for an operational zone. |
Shutting down + Down (active) | Normal state when a zone is being shutdown. |
Zone Daemons
zoneadm | Each zone will have a zoneadm associated with it and carries out the following actions: allocates the zone ID and starts the zsched process |
zsched | The job of the zsched is to keep track of kernel threads running within the zone. |
List zone name
# zonename |
List all zones
All the configured zone and there status should be listed.
# zoneadm list -cv |
Creating a zone
When creating a zone the zonename must be unique, no longer than 64 characters and is case-sensitive and must begin with a
alpha-numeric character. It can include underbars(_), hyphens (-) and periods (.). The name global and SUNW are reserved
words and cannot be used.
# zonecfg -z testzone |
The zone will now be created in a configured state, ignore the error at the top as this is just reporting that there is no other testzone.
# zoneadm list -cv |
/zones can be a filesystem or directory. Although the zone has been create it does not have resouces yet i.e no ip address.
Install the zone
Copy the necessary files from the global zone and populate the product database for the zone. While the zone is being installed
the state changes to incomplete.
# zoneadm –z testzone install |
Once the zone is installed the state changes again to installed
# zoneadm list –cv |
Ready a zone
When the zone is in the ready state it is associated with a virtual platform, network interfaces are plumbed and filesystems mounted.
There is no "ok>" prompt in a zone.
# zoneadm –z testzone ready |
Booting a zone
When you boot a zone the state changes to running. When booting a zone it automatically readies the state of a zone so you
do not need to ready a zone beforehand.
# zoneadm –z testzone boot |
Login into a zones console
You can login to the zones console, use '~.' to exit out of the console. All console messages will be reported here as per a
normal console, they only difference is there is no "ok>" prompt.
The first time a zone is booted you have to finish off the configuration which asks you set language, terminal type, etc
# zlogin -C testzone |
Adding a network resource to a zone
You need to log into the zone for the changes to take effect
# zonecfg –z testzone |
Mount a LOFS in a zone (ideal for cdrom)
You need to log into the zone for the changes to take effect
# zonecfg -z testzone |
Add a disk/filesystem device to a zone
You need to log into the zone for the changes to take effect
# zonecfg –z testzone create the vfstab file entry and mount the device # df –k # mount # cat /etc/mnttab |
Mount a filesystem from the global zone
You need to log into the zone for the changes to take effect
# zonecfg -z testzone |
Halting a zone
# zoneadm –z testzone halt ID NAME STATUS PATH |
Rebooting a zone
# zoneadm –z testzone reboot ID NAME STATUS PATH |
Uninstalling a zone
# zoneadm –z testzone uninstall -F |
Deleting a zone
# zoneadm –z testzone delete -F |