Reconfiguring the ZFS dataset of a Solaris zone

We got a Solaris 10 system with many zones installed on it. The aim was to create a Primary and an Alternative Boot Environment for the Live Updgrade, and to patch the ABE with LU. The original zone-environment was configured like this:

Zonepath : /zones/zonepath/
Dataset  : zones/zonepath/dataset

In this configuration the ZFS dataset was a descendant of zonepath.
But this ZFS layout and zone config was not Live Upgrade compatible, because the dataset can not be a child of the zonepath, in this case lucreate will fail.
More info: DocID 1396382.1 – zfs dataset of filesystem configured inside a non-global zone is a descendant of zonepath dataset.

What can we do? We need to reconfigure the zone and the zfs dataset (filesystem) too.
In this post I describe the reconfiguration process.
Attention! –All data and ZFS property on the ZFS dataset will be lost if we make any mistake 🙂
If all goes well, no data nor setting will be lost.

1. First we need to check the zone config and the dataset in the zone:

[root@MAB-0030:/]# zonecfg -z test-zone5 info
 zonename: test-zone5
 zonepath: /zones/test-zone5
 brand: native
 autoboot: false
 ip-type: shared
 dir: /lib
 dir: /platform
 dir: /sbin
 dir: /usr
 name: zones/test-zone5/dataset

We can see, that the dataset is a descendant of the zonapath.

[root@MAB-0030:/]# zlogin test-zone5
 [Connected to zone 'test-zone5' pts/2]
 Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
bash-3.2# zfs list -o name,mountpoint,mounted
 NAME                      MOUNTPOINT         MOUNTED
 zones                     /zones                  no
 zones/test-zone5          /zones/test-zone5       no
 zones/test-zone5/dataset  /dataset1              yes
bash-3.2# exit

The dataset in the zone is mounted to /dataset1

2. stopping the zone and check the zone status:

zoneadm -z test-zone5 halt 
zoneadm list -iv

3. if the zone is halted, we can remove the ZFS dataset from the zone configuration:

 zonecfg -z test-zone5 "remove dataset name=zones/test-zone5/dataset;
 verify; commit;"

4. after the dataset was removed, we have to turn off the ZFS ‘zoned’ property

(it descends to the child filesystems too):

 zfs set zoned=off zones/test-zone5/dataset

If we don’t turn off this property, we won’t be able to rename the filesystem and get this error message:
cannot rename ‘zones/test-zone5/dataset’: dataset is used in a non-global zone

5. now we can rename the ZFS filesystem (dataset) to ‘zones/datasets/dataset1-test-zone5’

the parent FS ‘zones/datasets’ should exist before we rename the filesystem: So if doesn’t exist, we create it:

zfs create zones/datasets
zfs rename zones/test-zone5/dataset zones/datasets/dataset1-test-zone5

If the zones/test-zone5/dataset have child filesystems, those will be also renamed automaticaly, for example:
zones/test-zone5/dataset -> zones/datasets/dataset1-test-zone5
zones/test-zone5/dataset/users -> zones/datasets/dataset1-test-zone5/users
zones/test-zone5/dataset/programs -> zones/datasets/dataset1-test-zone5/programs

6. add the renamed ZFS filesystem to the zone as ZFS dataset:

 zonecfg -z test-zone5 "add dataset;
 set name=zones/datasets/dataset1-test-zone5; end; verify; commit;"

7. Finally we can start the zone and check the results. The ‘zoned’ ZFS property will be automatically enabled:

[root@MAB-0030:/]# zlogin test-zone5
[Connected to zone 'test-zone5' pts/2]
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
bash-3.2# zfs list -o name,mountpoint,mounted,quota
 NAME                                  MOUNTPOINT        MOUNTED  QUOTA
 zones                                 /zones             no      none
 zones/datasets                        /zones/datasets    no      none
 zones/datasets/dataset1-test-zone5    /dataset1          yes     4.88G
bash-3.2# df -h
 Filesystem             size   used  avail capacity  Mounted on
 /                      8.2G   605M   7.6G     8%    /
 /dev                   8.2G   605M   7.6G     8%    /dev
 /lib                    14G   6.7G   7.6G    47%    /lib
                        4.9G   979M   3.9G    20%    /dataset1

If we did all well, the zone is now LU compatible and the boot environments for live upgrade can be created and ABE can be patched.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s