How to add zfs dataset to non-global zone

May 15, 2018 11:28 AM

Solaris zone is powerfull virtualization for unix platform. There many many flexibilities in use hardware resource. For example, you want to assign a dedicated zfs dataset to a zone. 

Solaris zone configuration utility (zonecfg) has a zone property to accomodate this requirement. Enter to zone configuration and specify the dataset name so the dataset will be active in the zone when it running. 

root@global:~# /usr/sbin/zpool list
NAME       SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
rpool     49.5G  25.9G  23.6G  52%  1.00x  ONLINE  -
zonepool  12.9G   942M  12.0G   7%  1.00x  ONLINE  -


root@global:~# zfs create zonepool/oradb
root@global:~# /usr/sbin/zonecfg -z zonedb

zonecfg:zonedb> add dataset
zonecfg:zonedb:dataset> set name=zonepool/oradb
zonecfg:zonedb:dataset> end
zonecfg:zonedb> verify
zonecfg:zonedb> commit
zonecfg:zonedb> exit

Boot the zone zonedb and check the dataset oradb : 

root@global:~# /usr/sbin/zoneadm -z zonedb boot -- -m verbose

root@zonedb:~# zfs list
NAME                              USED  AVAIL  REFER  MOUNTPOINT
oradb                              31K  11.8G    31K  /oradb
rpool                             939M  11.8G    31K  /rpool
rpool/ROOT                        938M  11.8G    31K  legacy
rpool/ROOT/solaris                938M  11.8G   888M  /
rpool/ROOT/solaris/var           42.9M  11.8G  42.0M  /var
rpool/VARSHARE                   1.22M  11.8G  1.16M  /var/share
rpool/VARSHARE/pkg                 63K  11.8G    32K  /var/share/pkg
rpool/VARSHARE/pkg/repositories    31K  11.8G    31K  /var/share/pkg/repositories
rpool/export                       63K  11.8G    32K  /export
rpool/export/home                  31K  11.8G    31K  /export/home

root@zonedb:~#
Dataset 'oradb' known as pool in zonedb zone as bellow :

root@zonedb:~# zpool list
NAME    SIZE  ALLOC   FREE  CAP  DEDUP  HEALTH  ALTROOT
oradb  12.9G   941M  12.0G   7%  1.00x  ONLINE  -
rpool  12.9G   941M  12.0G   7%  1.00x  ONLINE  -

Check the mounted devices, the oradb dataset as known as pool in zonedb. At the mounted device it's automatically mounted and include it in 'df' output :

root@zonedb:~# df -h
Filesystem             Size   Used  Available Capacity  Mounted on
rpool/ROOT/solaris      13G   888M        12G     7%    /
rpool/ROOT/solaris/var
                        13G    42M        12G     1%    /var
/dev                     0K     0K         0K     0%    /dev
proc                     0K     0K         0K     0%    /proc
ctfs                     0K     0K         0K     0%    /system/contract
mnttab                   0K     0K         0K     0%    /etc/mnttab
objfs                    0K     0K         0K     0%    /system/object
swap                   2.2G   456K       2.2G     1%    /system/volatile
sharefs                  0K     0K         0K     0%    /etc/dfs/sharetab
/usr/lib/libc/libc_hwcap1.so.1
                        13G   888M        12G     7%    /lib/libc.so.1
fd                       0K     0K         0K     0%    /dev/fd
swap                   2.2G     0K       2.2G     0%    /tmp
rpool/VARSHARE          13G   1.2M        12G     1%    /var/share
rpool/export            13G    32K        12G     1%    /export
rpool/export/home       13G    31K        12G     1%    /export/home
oradb                   12G    31K        12G     1%    /oradb
rpool                   13G    31K        12G     1%    /rpool
rpool/VARSHARE/pkg      13G    32K        12G     1%    /var/share/pkg
rpool/VARSHARE/pkg/repositories
                        13G    31K        12G     1%    /var/share/pkg/repositories

Thats all, only 2 step required to assign dataset to your solaris zone.


/* EOF */
-- Suwardi -- 

0 comments:

Article list :