Adding datasets to running zones

Sometimes you need to have a new ZFS dataset in your zone because, you want to install a new application or a new instance of an application in it which needs some storage to work . Sometimes you just need it to dump a lot of data into a new dataset as some kind of ephemeral scratch space. Before Solaris 11.4 you needed to reboot your zone in order to add a new dataset. However with the newest iteration of the operating environment, you can do it live. With Solaris 11.4 you have Live Zone Reconfiguration for ZFS datasets.

An example

At first we obviously have to create a new ZFS dataset that we can add to a zone. The addition of the filesystem

# zfs create rpool/tz1-newset


The next commands add a new dataset to the zone configuration and add it to the running configuration.

# zonecfg -z tz1 add dataset rpool/tz1-newset
# zoneadm -z tz1 apply
zone 'tz1': Checking: Adding dataset name=rpool/tz1-newset
zone 'tz1': Applying the changes


Let’s check for the filesystem.

# zlogin tz1
tz1 # zfs list tz1-newset 
cannot open ‚tz1-newset‘: filesystem does not exist


Right after the login, you won’t see the dataset. Just because you added it in the zone configuration doesn’t mean that it is ready to use. You have to import it first inside the zone.

tz1 # zpool import tz1-newset
tz1 # zfs list tz1-newset
 NAME         USED  AVAIL     REFER  MOUNTPOINT
  tz1-newset   2M     2G    2M       /tz1-newset


Now it’s available for use. When you want to remove if from the zone, you have to export it first.

tz1 # zpool export tz1-newset
# zonecfg -z tz1 remove dataset rpool/tz1-newset
# zoneadm -z tz1 apply
zone 'tz1': Checking: Removing dataset name=rpool/tz1-newset
zone 'tz1': Applying the changes