Adding volumes and disk devices to non-global zones

Adding file system or disk devices to a non-global zone is an integral part of creating a zone.

We can add different types of file systems, raw devices and disk devices as well to a non-global zone. This article provides a series of examples of adding different file systems, raw and disk devices to a non-global zone.

Adding a Raw Disk device

We can either add a slice or a complete raw disk to the non global zone. In case of a full disk use s2 slice or else use any other slice you want to add.

global# zonecfg -z zone01
zonecfg:zone01> add device
zonecfg:zone01:device> set match=/dev/rdsk/c0t0d0s6
zonecfg:zone01:device> end
zonecfg:zone01> commit
zonecfg:zone01> verify
zonecfg:zone01> exit

Adding a VxVM file system

global# zonecfg -z zone01
zonecfg:zone01> add fs
zonecfg:zone01:fs> set
zonecfg:zone01:fs> set special=/dev/vx/dsk/datadg/datavol
zonecfg:zone01:fs> set raw=/dev/vx/rdsk/datadg/datavol
zonecfg:zone01:fs> set dir=/data
zonecfg:zone01:fs> end
zonecfg:zone01> commit
zonecfg:zone01> verify
zonecfg:zone01> exit

Adding a VxVM raw volume

global# zonecfg -z zone01
zonecfg:zone01> add device
zonecfg:zone01:device> set match=/dev/vx/rdsk/dg1/vol1
zonecfg:zone01:device> end
zonecfg:zone01> commit
zonecfg:zone01> verify
zonecfg:zone01> exit

Adding UFS under SVM

global# zonecfg -z zone01
zonecfg:zone01> add fs
zonecfg:zone01:fs> set dir=/u01
zonecfg:zone01:fs> set special=/dev/md/dsk/d100
zonecfg:zone01:fs> set raw=/dev/md/rdsk/d100
zonecfg:zone01:fs> set
zonecfg:zone01:fs> add options [nodevices,logging]
zonecfg:zone01:fs> end
zonecfg:zone01> commit
zonecfg:zone01> verify
zonecfg:zone01> exit

Adding UFS under VxVM volume

We can also create a UFS file system on a VxVM volume as follows:

global# vxassist -g datadg make datavol 1g
global# mkfs -F ufs /dev/vx/rdsk/datadg/datavol
global# mount -F ufs /dev/vx/dsk/datadg/datavol /zones/zone01/root/data

To add the UFS under VxVM:

global# zonecfg -z zone01
zonecfg:zone01> add fs
zonecfg:zone01:fs> set
zonecfg:zone01:fs> set special=/dev/vx/dsk/datadg/datavol
zonecfg:zone01:fs> set raw=/dev/vx/rdsk/datadg/datavol
zonecfg:zone01:fs> set dir=/zones/zone1/root/data
zonecfg:zone01:fs> end
zonecfg:zone01> commit
zonecfg:zone01> verify
zonecfg:zone01> exit

Adding a ZFS file system to a non-global zone — Make sure the mount point property of the ZFS file system getting added to a zone is set to legacy, otherwise it may get assigned to multiple non-global zones simultaneously.

global# zonecfg -z zone01
zonecfg:zone01> add fs
zonecfg:zone01:fs> set
zonecfg:zone01:fs> set special=rpool/data
zonecfg:zone01:fs> set dir=/data
zonecfg:zone01:fs> end
zonecfg:zone01> verify
zonecfg:zone01> commit
zonecfg:zone01> exit

Adding ZFS file system as a loopback file system (lofs)to a non-global zone:

global# zonecfg -z zone01
zonecfg:zone01> add fs
zonecfg:zone01:fs> set special=rpool/data
zonecfg:zone01:fs> set dir=/data
zonecfg:zone01:fs> set
zonecfg:zone01:fs> end
zonecfg:zone01> commit
zonecfg:zone01> verify
zonecfg:zone01> exit
global# mkdir -p /zoneroot/zone01/root/data
global# mount -F lofs rpool/data /zoneroot/zone01/root/data

Delegating a dataset to a non-global zone — here you have a complete control of the dataset you delegate to the non-global zone. For example you can create your own child datasets under the dataset you delegate and set properties of the delegated dataset etc. The ZFS file system data will be available as a pool in the non-globa zone.

global# zonecfg -z zone01
zonecfg:zone01> add dataset
zonecfg:zone01:dataset> set name=rpool/data
zonecfg:zone01:dataset> end
zonecfg:zone01> commit
zonecfg:zone01> verify
zonecfg:zone01> exit

Adding ZFS volumes to non-global zones

global# zonecfg -z zone01
zonecfg:zone1> add device
zonecfg:zone1:device> set match=/dev/zvol/dsk/rpool/datavol
zonecfg:zone1:device> end
zonecfg:zone1> verify
zonecfg:zone1> commit
zonecfg:zone1> exit

To adda a CD-ROM to the non-global zone:

global# zonecfg -z zone01
zonecfg:zone01> add fs
zonecfg:zone01:fs> set dir=/cdrom
zonecfg:zone01:fs> set special=/cdrom
zonecfg:zone01:fs> set
zonecfg:zone01:fs> end
zonecfg:zone01> verify
zonecfg:zone01> commit
zonecfg:zone01> exit