The zonecfg command is used to configure the zone. We can add and remove a resource from the solaris zone using zonecfg. Any change to zonecfg needs a reboot, but sometimes it is a requirement to dynamically add new resources to the zone without rebooting the zone. Also, we need to make sure that the addition of new resources to the zone are persistent across reboots.
I will briefly explain how to dynamically add an IP address and a UFS filesystem to a running zone and then to make the changes persistent across a reboot.
Adding an IP Address to Running Zone
In a normal scenario, the network interfaces are plumbed automatically when the zone transitions from installed state to ready state.
If I need to add a new IP address to the running zone, I need to do the plumbing of the interfaces manually in the global zone as follows:
global-zone # ifconfig ce52000:2 plumb global-zone # ifconfig ce52000:2 inet 10.111.111.10 netmask 255.255.255.0 broadcast 10.111.111.255 zone testzone01 up
Now do a zloging to the zone from the global zone and see for yourself, the interface will be there. In order to make this change permanent to the zone, we need to add it to the zone configuration using zonecfg as follows:
global-zone # zonecfg -z testzone01 zonecfg:testzone01> add net zonecfg:testzone01:net> set address=10.111.111.10 zonecfg:testzone01:net> set physical=ce52000 zonecfg:testzone01:net> end zonecfg:testzone01> verify zonecfg:testzone01> commit zonecfg:testzone01> exit
Adding a Filesystem to a Running Zone
In order to add filesystem /zones/testzone01/mnt/data (/dev/md/dsk/d112) available to the zone on the fly do the following:
global-zone # mount /dev/md/dsk/d112 /zones/testzone01/boot/root/data
To make the changes persistent:
global-zone # zonecfg -z testzone01 zonecfg:testzone01> add fs zonecfg:testzone01:fs> set dir=/data zonecfg:testzone01:fs> set special=/zones/testzone01/mnt/data zonecfg:testzone01:fs> type=lofs zonecfg:testzone01:fs> end zonecfg:testzone01> verify zonecfg:testzone01> commit zonecfg:testzone01> exit
Note – The use of the ‘special’ parameter allows the local zone to mount global system resources under seperate directories. ‘special’ specifies the block special device name or directory from the global zone to mount.