Adding zfs datasets to an existing zone

Adding zfs datasets to an existing zone

If you add zfs datasets to an existing zone you can’t just set a mount point in the zone.
On the next boot Zfs tries to auto mount and when it fails it takes out volfs and about 30 other services

-bash-3.2# zoneadm list -v
ID NAME STATUS PATH BRAND IP
0 global running / native shared
1 myzone running /export/home/zones/myzone native shared

so doing something like this:

-bash-3.2# zfs create mypool/my_apps
-bash-3.2# zfs create mypoo/my_archive
-bash-3.2# zfs create mypool/my_data

-bash-3.2# zfs set mountpoint=/export/home/zones/myzone/root/my_apps mypool/my_apps
-bash-3.2# zfs set mountpoint=/export/home/zones/myzone/root/my_archive mypool/my_archive
-bash-3.2# zfs set mountpoint=/export/home/zones/myzone/root/my_data mypool/my_data

Will work until the next reboot, then the system will go into maintenance mode and you won’t even be able to ssh in.

CORRECT WAY 😉

You set the my_dataset mountpoint to legacy

You then use the zonecfg command to add it

-bash-3.2# zfs set mountpoint=legacy mypool/my_apps
-bash-3.2# zfs set mountpoint=legacy mypool/my_archive
-bash-3.2# zfs set mountpoint=legacy mypool/my_data

-bash-3.2# zoneadm -z myzone halt
-bash-3.2# zonecfg -z myzone
zonecfg:myzone> add fs
zonecfg:myzone:fs> set type=zfs
zonecfg:myzone:fs> set special=mypool/my_apps
zonecfg:myzone:fs> set dir=/my_apps
zonecfg:myzone:fs> end
zonecfg:myzone> add fs
zonecfg:myzone:fs> set type=zfs
zonecfg:myzone:fs> set special=mypool/my_archive
zonecfg:myzone:fs> set dir=/my_archive
zonecfg:myzone:fs> end
zonecfg:myzone> add fs
zonecfg:myzone:fs> set type=zfs
zonecfg:myzone:fs> set special=mypool/my_data
zonecfg:myzone:fs> set dir=/my_data
zonecfg:myzone:fs> end
zonecfg:myzone> commit
zonecfg:myzone> exit
-bash-3.2# zoneadm -z myzone boot

Leave a Reply

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