How to Add a ZFS Dataset to a Running Zone

Perform this procedure to add ZFS datasets to a running zone.

Note:

Issue all commands in this procedure from the global zone.
  1. On the global zone, become an administrator.
  2. Display the current dataset information.
    global$ pfbash zonecfg -z zonename info dataset
    dataset:
            name: rpool/export/dataset1
            alias: dataset1
    dataset:
            name: rpool/export/dataset2
            alias: dataset2
  3. Inspect the current live configuration and datasets for the zone.
    global$ zonecfg -z zonename -r
    zonecfg:zonename> info dataset
    dataset 0:
            name: rpool/export/dataset2
            alias: dataset2
    dataset 1:
            name: rpool/export/dataset1
            alias: dataset1
    zonecfg:zonename> exit
  4. Create a new dataset.
    global$ zfs create rpool/export/new-dataset
    global$ zfs unmount rpool/export/new-dataset
  5. Add the new dataset resource to the running solaris zone.

    Verify the addition, commit the change, and exit the zonecfg utility.

    global$ zonecfg -z zonename -r
                                  Add the dataset
    zonecfg:zonename> add dataset
    zonecfg:zonename:dataset> set name=rpool/export/new-dataset
    zonecfg:zonename:dataset> end
                                  Verify the added dataset
    zonecfg:zonename> info dataset
    dataset 0:
            name: rpool/export/dataset2
            alias: dataset2
    dataset 1:
            name: rpool/export/dataset1
            alias: dataset1
    dataset 2:
            name: rpool/export/new-dataset
            alias: new-dataset
                                  Commit the change
    zonecfg:zonename> commit
    zone 'zonename': Checking: Adding dataset name=rpool/export/new-dataset
    zone 'zonename': Checking: Adding dataset alias=new-dataset
    zone 'zonename': Applying the changes
    Exit the command
    zonecfg:zonename> exit

    Note:

    The dataset is not yet added to the persistent stored zone configuration, only to the live zone configuration.
  6. Change the persistent zone configuration to match the live zone configuration.
    global$ zoneadm -z zonename apply
  7. Verify that the new dataset is added to the persistent zone configuration.
    global$ zonecfg -z zonename info dataset
    dataset:
            name: rpool/export/new-dataset
            alias: new-dataset
    dataset:
            name: rpool/export/dataset1
            alias: dataset1
    dataset:
            name: rpool/export/dataset2
            alias: dataset2