Go to main content

Creating and Using Oracle® Solaris Zones

Exit Print View

Updated: August 2019
 
 

How to Modify Zone Resources and Properties

Before You Begin

If you plan to modify zone properties in live mode, ensure that the properties are supported for configuration in this mode. Otherwise, unexpected results might occur.

  1. Become a zone administrator.

    For more information, see Using Rights Profiles to Install and Manage Zones.

  2. (Optional) If you plan to configure in live mode, check that the zone is running.
    global$ zoneadm list -cv
  3. (Optional) Display the current settings of the zone.
    global$ zonecfg -z zonename info

    Through this step, you can identify the property or resource you want to change.

  4. Switch to interactive configuration.
    global$ zonecfg -z zonename [-r]

    Use the –r option to reconfigure in live mode.

  5. Select the resource type to be changed.
    zonecfg:zonename> select resource [identifier]

    A zone might have multiple settings for the same resource type, as illustrated in Adding File Systems for Zone Use. Make sure you are modifying the correct resource type.

  6. Modify the setting.

    The subcommands you use depend on what type of modification you want to make.

    • To replace a current setting with a new setting:
      zonecfg:zonename:resource> remove (value-pair1[,value-pair2,…])
      zonecfg:zonename:resource> add (value-pair1[,value-pair2,…])
    • To reset a property to the default value:
      zonecfg:zonename:resource> clear property
    • To remove the resource:
      zonecfg:zonename:resource> delete

      Caution

      Caution  -  The deletion occurs instantaneously on both in-memory and stable storage and is irreversible.


  7. If you are within a resource scope, end the modification of the resource.
    zonecfg:zonename:resource> end
  8. Return to the global zone.
    zonecfg:zonename> exit

    If you are modifying properties in live mode, the changes take effect immediately when you exit. However, these changes are active only up to the next zone reboot. If you reboot the zone, the previous settings in storage are restored.

  9. If you are modifying properties in default mode, apply the changes.

    Choose one of the following methods:

    • Issue the zoneadm apply command.

      You can use this command only if the zone is in a running state. With this command, no zone reboot is required.


      Caution

      Caution  -  Running this command after configuring in live mode will cancel the changes you just made. See caution in About Configuring Zone Properties.


      global$ zoneadm -z zonename apply
      Checking: Adding resource property=setting
      Applying the changes.
    • Reboot the zone.
      global$ zoneadm -z zonename reboot
Example 7  Changing the Settings of a Resource Control

A resource control is represented in zone configuration as rctl. In this example, multiple resource controls are configured in a zone and you are modifying zone.cpu-shares. The change is applied to the zone without rebooting through the zoneadm apply command.

global$ zonecfg -zoneA
zonecfg:zoneA> info
...
rctl 1
      name: zone.max-locked-memory
      value: (priv=privileged,limit=524288000,action=deny)
rctl 2
      name: zone.cpu-shares
      value: (priv=privileged,limit=20,action=none)
...
zonecfg:zoneA> select rctl 2
zonecfg:zoneA:rctl> info
rctl 3
      name: zone.cpu-shares
      value: (priv=privileged,limit=20,action=none)
zonecfg:zoneA:rctl> remove value (priv=privileged,limit=20,action=none)
zonecfg:zoneA:rctl> add value (priv=privileged,limit=30,action=none)
zonecfg:zoneA:rctl> info
rctl 2
      name: zone.cpu-shares
      value: (priv=privileged,limit=30,action=none)Value of limit is changed.
zonecfg:zoneA:rctl> end
zonecfg:zoneA> exit
global$ zoneadm -z zoneA apply
Checking: Adding rctl value (priv=privileged,limit=30,action=none)
Applying the changes.
Example 8  Reverting a Zone's autoboot Property to the Default Setting

By default, a zone does not boot whenever the host system is rebooted. In this example, you are resetting zoneA's autoboot property to the default setting. The change takes effect after the zone is rebooted.

global$ zonecfg -z zoneA
zonecfg:zoneA> info autoboot
autoboot: true
zonecfg:zoneA> clear autoboot
zonecfg:zoneA> info autoboot
autoboot: false
zonecfg:zoneA> exit
global$ zoneadm -z zoneA reboot
Example 9  Canceling a Modification and Restoring Saved Settings

This example shows how to discard changes you just made and revert to the settings currently in storage.

global$ zonecfg -z zoneA
zonecfg:zoneA> info
zonename: zoneA
brand: solaris
autoboot: true
...
dedicated-cpu:
      ncpus: 1-2
      importance: 10
...
zonecfg:zoneA> remove dedicated-cpu
zonecfg:zoneA> info
zonename: zoneA
brand: solaris
autoboot: true
...
Dedicated-cpu no longer listed.
...
zonecfg:zoneA> reload
Are you sure you want to reload (y[n])? y
zonecfg:zoneA> info
zonename: zoneA
brand: solaris
autoboot: true
...
dedicated-cpu:Dedicated-cpu is restored.
      ncpus: 1-2
      importance: 10
...
zonecfg:zoneA> exit
global$ zoneadm -z zoneA reboot
Example 10  Temporarily Modifying a Configured Property by Using live Mode

This example shows the processes in live mode configuration. In this scenario, zoneA has a second anet resource configuration that you want to remove. In the solaris brand, anet is a resource that can be reconfigured in live mode.

The example begins by verifying that zoneA is running so that live mode can be used.

global$ zoneadm list -cv
ID NAME     STATUS      PATH                  BRAND     IP
0  global   running     /                     solaris   shared
1  zoneA    running     /export/zones/zoneA   solaris   exclusive
-  zoneB    installed   /system/zones/zoneB   solaris   exclusive

global$ zonecfg -z zoneA info
...
anet 0
      name: net0
      configure-allowed-address: true
      auto-mac-address: 2:8:20:af:4c:0
anet 1
      name: net1
      configure-allowed-address: true
      auto-mac-address: 2:8:20:1:9b:31
...
global$ zonecfg -z zoneA -r
zonecfg:zoneA> remove anet linkname=net1
zonecfg:zoneA> info
...
anet 0
      name: net0
      configure-allowed-address: true
      auto-mac-address: 2:8:20:af:4c:0
...anet 1 no longer listed.

zonecfg:zoneA> exit
Checking: Removing anet linkname=net1
Applying the changes

From the global zone, you can display the temporary changes as follows:

global$ zonecfg -z zoneA -r info

Rebooting the zone cancels the temporary changes. To cancel without rebooting, use the zoneadm apply command:

global$ zoneadm -z zoneA apply
Checking: Adding anet linkname=net1
Applying the changes

global$ zonecfg -z zoneA info
...
anet 0
      name: net0
      configure-allowed-address: true
      auto-mac-address: 2:8:20:af:4c:0
anet 1anet 1 is restored.
      name: net1
      configure-allowed-address: true
      auto-mac-address: 2:8:20:1:9b:31
...