Home / Solaris 10 / How to add ZPOOL-ZFS to Solaris local zones ?

How to add ZPOOL-ZFS to Solaris local zones ?

Oracle is marketing Oracle’s ZFS(Zeta Byte filesystem) is the next generation filesystem. If you say next generation filesystem,will it be enhanced to support OS virtualization ? Yes.It is.Unlike VXVM, we can delegate the entire zpool to local zones.So that we can manage the entire zpool from the local zone level without logging in to global zone.It includes creating new ZFS dataset,destroying existing dataset and managing  the zfs snapshots of delegated zpools. Here will see, how to delegate the entire zpool to local zones and how to assign  the zfs datasets to local zones using various methods .


1.Delegating zpool to local zone.
First we need an existing zpool or create a new zpool in the global zone which you want to delegate to local zone.Once you have zpool,then we can add it to zone’s configuration using zonecfg.
Note:You need to reboot the  local zone to see the newly assigned zpool.
bash-3.00# zpool list sol1pool
NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
sol1pool 89M 97K 88.9M 0% ONLINE -
bash-3.00# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
21 sol1 running /export/zone/sollz1 native shared
bash-3.00# zonecfg -z sol1
zonecfg:sol1> info
zonename: sol1
zonepath: /export/zone/sollz1
brand: native
autoboot: false
bootargs:
pool:
limitpriv:
scheduling-class:
ip-type: shared
hostid:
inherit-pkg-dir:
dir: /lib
inherit-pkg-dir:
dir: /platform
inherit-pkg-dir:
dir: /sbin
inherit-pkg-dir:
dir: /usr
fs:
dir: /vol1
special: /dev/vx/dsk/UADG/vol1
raw: /dev/vx/rdsk/UADG/vol1
type: vxfs
options: []zonecfg:sol1> add dataset
zonecfg:sol1:dataset> set name=sol1pool
zonecfg:sol1:dataset> end
zonecfg:sol1> commit
zonecfg:sol1> exit
bash-3.00# zlogin sol1 zpool list
no pools available
bash-3.00# zoneadm -z sol1 reboot
bash-3.00# zlogin sol1 zpool list
NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
sol1pool 89M 111K 88.9M 0% ONLINE -
bash-3.00# zlogin sol1
[Connected to zone 'sol1' pts/4]Last login: Thu May 30 20:53:38 on pts/4
Oracle Corporation SunOS 5.10 Generic Patch January 2005
# bash
bash-3.00# zpool list
NAME SIZE ALLOC FREE CAP HEALTH ALTROOT
sol1pool 89M 111K 88.9M 0% ONLINE -
bash-3.00# zfs create sol1pool/solfs1
bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
sol1pool 105K 56.9M 21K /sol1pool
sol1pool/solfs1 21K 56.9M 21K /sol1pool/solfs1
bash-3.00# zfs snapshot sol1pool/solfs1@30052013
bash-3.00# zfs list |grep @
sol1pool/solfs1@30052013 0 - 21K -

Note:Once you have delegated zpool to the local zone , you can’t see the mounts in global zone level.
bash-3.00# zfs list |grep sol1pool
sol1pool 106K 56.9M 22K /sol1pool
sol1pool/solfs1 21K 56.9M 21K /sol1pool/solfs1
sol1pool/solfs1@30052013 0 - 21K -
bash-3.00# cd /sol1pool/solfs1
bash: cd: /sol1pool/solfs1: No such file or directory
bash-3.00# cd /sol1pool
bash: cd: /sol1pool: No such file or directory
bash-3.00# zonename
global
bash-3.00#


2.Assigning ZFS dataset  to local zone.This can be done in two ways .
i.Directly set ZFS dataset mountpoint  to local zone’s root path.
bash-3.00# zfs list |grep rpool/dataset1-sol1
rpool/dataset1-sol1 21K 2.60G 21K /dataset1-sol1
bash-3.00# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
22 sol1 running /export/zone/sollz1 native shared
bash-3.00# zfs set mountpoint=/export/zone/sollz1/root/dataset1-sol1 rpool/dataset1-sol1
bash-3.00# zlogin sol1 df -h /dataset1-sol1
Filesystem size used avail capacity Mounted on
rpool/dataset1-sol1 2.6G 21K 2.6G 1% /dataset1-sol1 


To make the above settings persist across the zone reboot,First set mountpoint to legacy to the zfs dataset and add it in zonecfg.

bash-3.00# zfs set mountpoint=legacy rpool/dataset1-sol1
bash-3.00# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
24 sol1 running /export/zone/sollz1 native shared
bash-3.00# zonecfg -z sol1
zonecfg:sol1> add fs
zonecfg:sol1:fs> set type=zfs
zonecfg:sol1:fs> set special=rpool/dataset1-sol1
zonecfg:sol1:fs> set dir=/dataset1-sol1
zonecfg:sol1:fs> end
zonecfg:sol1> verify
zonecfg:sol1> commit
zonecfg:sol1> exit
bash-3.00# zoneadm -z sol1 reboot
bash-3.00# zoneadm -z sol1 reboot
bash-3.00# zlogin sol1 df -h /dataset1-sol1
Filesystem size used avail capacity Mounted on
rpool/dataset1-sol1 2.6G 21K 2.6G 1% /dataset1-sol1

ii.Adding ZFS dataset via lofs filesystem like VXFS
In a order to use lofs, actual zfs filesystem should be mounted in global zone.

bash-3.00# mount -v |grep /rpool/dataset1-sol2
rpool/dataset1-sol2 on /rpool/dataset1-sol2 type zfs read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d50017 on Fri May 31 01:24:17 2013
bash-3.00# zoneadm list -cv
ID NAME STATUS PATH BRAND IP
0 global running / native shared
25 sol1 running /export/zone/sollz1 native shared
bash-3.00# mkdir -p /export/zone/sollz1/root/dataset1-sol2
bash-3.00# mount -F lofs /rpool/dataset1-sol2 /export/zone/sollz1/root/dataset1-sol2
bash-3.00# zlogin sol1 df -h /dataset1-sol2
Filesystem size used avail capacity Mounted on
/dataset1-sol2 2.6G 21K 2.6G 1% /dataset1-sol2

To make the change persist across the zone reboot,

bash-3.00# zonecfg -z sol1
zonecfg:sol1> add fs
zonecfg:sol1:fs> set dir=/dataset1-sol2
zonecfg:sol1:fs> set special=/rpool/dataset1-sol2
zonecfg:sol1:fs> set type=lofs
zonecfg:sol1:fs> end
zonecfg:sol1> verify
zonecfg:sol1> commit
zonecfg:sol1> exit

verifying our work,

bash-3.00# zoneadm -z sol1 reboot
bash-3.00# zlogin sol1 df -h /dataset1-sol2
Filesystem size used avail capacity Mounted on
/dataset1-sol2 2.6G 21K 2.6G 1% /dataset1-sol2

Recommendation:Delegate the zpool to local zone.(i.e Method 1)

If you do not want to see zpool mount in global zone, you can disabled it using legacy option.
# zfs set mountpoint=legacy zpool

Thank you for reading this article.Please leave a comment if you have any doubt.I will get back to you.

VMTURBO-CLOUD-CAPACITY

Leave a Reply

Your email address will not be published. Required fields are marked *