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

2 Comments

Linear

  • David Lange  
    So you created the dataset in the global, import to zone. I'm assuming the default mount option will cause the dataset to be mount after the zone is rebooted?
  • DavidH  
    On Solaris 10 Sparse Zones, we share /export/home across all zones on the same global zone, today. (Using underlying ZFS and UFS filesystems on the global zones.) We always added/removed with restart of the zone.

    With Dynamic Zone Reconfigure:

    If there are 16 zones on a global zone...
    ... can each zone dynamically import a Global Zone's dataset, as read-write?
    ... how about read-only?

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA