Configuring the dataset Property on solaris Zones

Non-global zones use the ZFS file system as their Oracle Solaris hosts do. Although ZFS is supported as an fs type, you typically use the dataset property instead of the fs property when configuring non-global zones' datasets. The dataset property enables you to have control over the dataset from within the zone, where you can access the dataset and configure ZFS properties as needed.

You can add, export, and remove datasets from non-global zones while the zones are running. You can change a snapshot of the zone by using live mode, or modify the zone in default mode, which affects the zone that is running on the system. For a fuller explanation, see About Configuring Zone Properties. The zonecfg(8) man page describes the ‐r option for configuring a zone in live mode.

The following examples show how to add a dataset, remove a dataset, and remove a dataset by exporting it. Export operations precede migrating a zone.

Example 3-8 Adding a Dataset to a Zone

Suppose that you created a ZFS pool called rpool/zonefs. To add this pool to the non-global zone using the default mode, you would do the following steps:

global$ zonecfg -z zoneA
zonecfg:zoneA> add dataset
zonecfg:zoneA:fs> set name=rpool/zonefs
zonecfg:zoneA:fs> end
zonecfg:zoneA> exit
global$ zonecfg -z zoneA info
...
dataset
      name: rpool/zonefs
      alias: zonefs
...

Apply the changes.

global$ zoneadm -z zoneA apply

You can now run zfs subcommands on the dataset.

Example 3-9 Removing a Dataset From a Running Zone

  1. The administrator starts by viewing the dataset information of a running zone from the global zone.

    global$ pfbash zonecfg -z ZoneA -r info dataset
    ...
    dataset:
            name: rpool/export/zonefs1
            alias: zonefs1
    dataset:
            name: rpool/export/zonefs2
            alias: zonefs2
    ...
  2. The administrator then removes the zonefs1 dataset from the zone snapshot.

    global$ zonecfg -z ZoneA -r
    zonecfg:ZoneA> remove dataset name=rpool/export/zonefs1
    zonecfg:ZoneA> info dataset
    dataset 0:
            name: rpool/export/zonefs2
            alias: zonefs2
    ...
    zonecfg:ZoneA> commit
    zone 'ZoneA': Checking: Removing dataset name=rpool/export/zonefs1
    zone 'ZoneA': Applying the changes
    zonecfg:ZoneA> exit
  3. The administrator verifies that the dataset is removed.

    global$ zonecfg -z ZoneA -r info dataset
    dataset:
            name: rpool/export/zonefs2
            alias: zonefs2

When ZoneA is rebooted, or when you use the zoneadm apply command, the dataset is restored to the zone. The ‐r option is for temporary changes only.

Example 3-10 Exporting a Dataset From a solaris Zone

In this example, the administrator exports a dataset for migration or move. If the dataset is in use, the export might not succeed. For more information, see Exporting a ZFS Storage Pool in Managing ZFS File Systems in Oracle Solaris 11.4.

The administrator exports the dataset from the snapshot of the zone. At reboot, the dataset is still in the zone.

  1. From the global zone, the administrator displays the zone datasets.

    global$ pfbash zonecfg -z ZoneA info dataset
    ...
    dataset:
            name: rpool/export/zonefs1
            alias: zonefs1
    dataset:
            name: rpool/export/zonefs2
            alias: zonefs2
    ...
  2. From the global zone, the administrator exports the zonefs2 dataset.

    global$ zpool export zonefs2
  3. The list of running zpools does not include the exported dataset.

    global$ zpool list
    NAME     SIZE  ALLOC   FREE   CAP  DEDUP  HEALTH  ALTROOT
    zonefs1  68G   21.5G   46.5G  31%  1.00x  ONLINE  -
    rpool    68G   21.5G   46.5G  31%  1.00x  ONLINE  -