NFS in Solaris 11 non-global zone

1. Create the ZFS file system for your NFS share.
=======================
root@GLOBAL:~# zfs create -o mountpoint=legacy GLOBAL/tmp

root@GLOBAL:~# zfs list
NAME                                               USED  AVAIL  REFER  MOUNTPOINT
GLOBAL                                               2.13T  3.21T  44.9K  none
GLOBAL/backup                                        33.2G  3.21T  33.2G  /backup
GLOBAL/test                                         2.10T  3.21T  2.10T  /test
GLOBAL/tmp                                           44.9K  3.21T  44.9K  legacy

2. Add the file system to your non-global zone.
=======================
root@GLOBAL:~# zonecfg -z NFS
zonecfg:NFS> info
zonename: NFS
zonepath: /zones/NFS
brand: solaris
autoboot: true
bootargs:
file-mac-profile:
pool:
limitpriv:
scheduling-class:
ip-type: shared
hostid:
fs-allowed:
net:
address: 192.168.0.2/24
allowed-address not specified
configure-allowed-address: true
physical: net0
defrouter: 192.168.0.1

zonecfg:NFS> add fs
zonecfg:NFS:fs> set dir=/share
zonecfg:NFS:fs> set special=GLOBAL/tmp
zonecfg:NFS:fs> set type=zfs
zonecfg:NFS:fs> info
fs:
dir: /share
special: GLOBAL/tmp
raw not specified
type: zfs
options: []
zonecfg:NFS:fs> end

zonecfg:NFS> add dataset
zonecfg:NFS:dataset> info
dataset:
name: GLOBAL/tmp
alias not specified
zonecfg:NFS:dataset> end

zonecfg:NFS> verify
zonecfg:NFS> commit
zonecfg:NFS> exit

3. Boot the zone.
=======================

root@GLOBAL:/etc/nfs# zlogin NFS
[Connected to zone 'NFS' pts/5]
Oracle Corporation      SunOS 5.11      11.0    November 2011
You have new mail.

root@NFS:~# zfs list | grep -i tmp
tmp                         44.9K  3.21T  44.9K  legacy
root@NFS:~# df -h | grep -i share
GLOBAL/tmp                3.2T    44K       3.2T     1%    /share

4. Setup the NFS Sharing on the filesystem.

=======================
root@NFS:~# share -F nfs -o ro=HOST1:HOST2,rw=GLOBAL /share
root@NFS:~# share
tmp     /tmp    nfs     sec=sys,ro=HOST1:HOST2,rw=GLOBAL

5. Test your share
=======================

root@HOST1:/# mount 192.168.0.103:/share /mnt
root@HOST1:/# df -h | grep -i share
sharefs                  0K     0K         0K     0%    /etc/dfs/sharetab
192.168.0.103:/share      3.2T    45K       3.2T     1%    /mnt
root@HOST1:/mnt# touch /mnt/test
touch: cannot create test: Read-only file system

root@GLOBAL:/etc/nfs# mount 192.168.0.103:/share /mnt
root@GLOBAL:/etc/nfs# df -h | grep -i share
sharefs                  0K     0K         0K     0%    /etc/dfs/sharetab
GLOBAL/share              5.3T   2.1T       3.2T    40%    /share
192.168.0.103:/share      3.2T    44K       3.2T     1%    /mnt

Leave A Reply

Comments

No comments yet, be the first to add one!

Tags