• Bez kategorii

How to remove dataset from Solaris zone and mount it as lofs

Because of building mail system I need to export ZFS filesystem via NFS to other node, where postfix with deliver will save messages to mail boxes. As you can see in this installation transcript I configured whole zpool „studmail” as ZFS dataset for zone st1. Unfortunatelly, you can not simply share ZFS via NFS in non-global zone:

root@st1:~# zfs list
NAME                         USED  AVAIL  REFER  MOUNTPOINT
studmail                     301M  1.78T  28.0K  none
studmail/etc                4.52M  1.78T  4.19M  /data/etc
studmail/studmail            480K  1.78T   417K  /data/studmail
studmail/var                 296M  1.78T   294M  /data/var

root@st1:~# zfs set sharenfs=rw=@192.168.X.X/32,anon=0 studmail/studmail
cannot set property for 'studmail/studmail': 'sharenfs' cannot be set in a non-global zone

So I decided to reconfigure zone to use lofs and not dataset, but at first I must to change mountpoints:

root@st1:~# zfs set mountpoint=/data/etc/st1 studmail/etc
root@st1:~# zfs set mountpoint=/data/var/st1 studmail/var
root@st1:~# zfs list
NAME                         USED  AVAIL  REFER  MOUNTPOINT
studmail                     301M  1.78T  28.0K  none
studmail/etc                4.52M  1.78T  4.19M  /data/etc/st1
studmail/studmail            480K  1.78T   417K  /data/studmail
studmail/var                 296M  1.78T   294M  /data/var/st1

Now we can halt and reconfigure zone:

root@st1:~# halt

[Connection to zone 'st1' pts/2 closed]
root@feniks:~# zonecfg -z st1
zonecfg:st1> info
zonename: st1
zonepath: /zones/st1
brand: native
autoboot: true
...
dataset:
	name: studmail

Removing dataset (if you have more than one, you need to put name in command):

zonecfg:st1> remove dataset

Adding ZFS filesystems as lofs:

zonecfg:st1> add fs
zonecfg:st1:fs> set dir=/data/etc
zonecfg:st1:fs> set special=/data/etc/st1
zonecfg:st1:fs> end
type not specified
zonecfg:st1:fs> set type=lofs
zonecfg:st1:fs> end
zonecfg:st1> add fs
zonecfg:st1:fs> set dir=/data/var
zonecfg:st1:fs> set special=/data/var/st1
zonecfg:st1:fs> set type=lofs
zonecfg:st1:fs> end
zonecfg:st1> add fs
zonecfg:st1:fs> set dir=/data/studmail
zonecfg:st1:fs> set special=/data/studmail
zonecfg:st1:fs> set type=lofs
zonecfg:st1:fs> end
zonecfg:st1> verify
zonecfg:st1> commit
zonecfg:st1> exit

OK, but now the directories are empty. Why? Let’s check zoned property in dataset:

root@feniks:~# zfs get -r zoned studmail
NAME                        PROPERTY  VALUE  SOURCE
studmail                    zoned     on     local
studmail/etc                zoned     on     inherited from studmail
studmail/studmail           zoned     on     inherited from studmail
studmail/var                zoned     on     inherited from studmail

So, filesystems are mounted, but you do not see its content into a global zone. We need to change this:

root@feniks:~# zfs set zoned=off studmail
root@feniks:~# zfs get -r zoned studmail
NAME                        PROPERTY  VALUE  SOURCE
studmail                    zoned     off    local
studmail/etc                zoned     off    inherited from studmail
...
root@feniks:~# ls -laF /data/etc/st1
total 4
drwxr-xr-x  2 root root  2 Aug 10 13:30 ./
drwxr-xr-x 27 root root 28 Aug 13 10:26 ../

Still empty (or no directory)? The simpliest way is to export and import zpool:

root@feniks:~# zpool export studmail
root@feniks:~# zpool import studmail 
root@feniks:~# zfs list -r studmail
NAME                         USED  AVAIL  REFER  MOUNTPOINT
studmail                     301M  1.78T  28.0K  none
studmail/etc                4.52M  1.78T  4.19M  /data/etc/st1
studmail/studmail            480K  1.78T   417K  /data/studmail
studmail/var                 296M  1.78T   294M  /data/var/st1
root@feniks:~# ls -laF /data/etc/st1 
total 638
drwxr-xr-x 10 root root     13 Jul 21 14:03 ./
drwxr-xr-x 27 root root     28 Aug 13 10:26 ../
drwxr-xr-x  7 root root     11 Jan 15  2010 apache/
drwxr-xr-x  2 root root     13 Apr 12 13:23 certs/
drwxr-xr-x  3 root root      6 Aug 17 08:40 dovecot/
drwxr-xr-x  2   27 root      4 Apr 26 13:22 gnarwl/
...

I think, we can boot zone:

root@feniks:~# zoneadm -z st1 boot
root@feniks:~# zoneadm -z st1 list -v
  ID NAME             STATUS     PATH                           BRAND    IP    
  14 st1              running    /zones/st1                     native   shared

Now we can export share via NFS from global zone:

root@feniks:~# zfs set sharenfs=rw=@192.168.X.X/32,anon=0 studmail/studmail
root@feniks:~# share
-               /data/studmail   anon=0,sec=sys,rw=192.168.X.X/32   "" 

WARNING: I do not care about security in this example, please see NFS documentation for options!

Możesz również polubić…

Leave a Reply

Witryna wykorzystuje Akismet, aby ograniczyć spam. Dowiedz się więcej jak przetwarzane są dane komentarzy.