Home / Tutorials / ZFS-Tutorials / ZFS – Datasets Administration and Emulated Volumes

ZFS – Datasets Administration and Emulated Volumes

A dataset is a child (virtual) filesystem of the parent zpool or parent dataset. Solaris ZFS Datasets are very light weight and easy to administrate. Theatrically speaking, we can create 2^64 datasets in single zpool. Solaris ZFS datasets is similar to VXVM volume but not completely. These datasets doesn’t require any vfstab entry to mount the datasets across the server reboot. These mounts are automatically managed by ZFS itself.Here we will see the administration of ZFS datasets with complete commands output.


Prerequisites:
1.Skills:Knowledge of Solaris system administration 
2.Lab Environment: Virtual Machine Solaris 11 or Solaris 10 u6 or higher version. 
3.Complete the “Creating ZFS Storage pool and various zpool layouts” tutorial.

Topics:

Task:1-Creating the Datasets:

Creating the ZFS datasets is not a big deal.It can be done using simple command.Most of the ZFS commands are meaning full.

1.List the zpool in which you want to create ZFS datasets.

root@Unixarena-SOL11:~# zpool list oracledata
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
oracledata 3.97G 106K 3.97G 0% 1.00x ONLINE -
root@Unixarena-SOL11:~# zfs list oracledata
NAME USED AVAIL REFER MOUNTPOINT
oracledata 106K 3.91G 31K /oracledata
root@Unixarena-SOL11:~#

2.Create new dataset under zpool “oracledata”

root@Unixarena-SOL11:~# zfs create oracledata/bigdata1
root@Unixarena-SOL11:~# zfs list oracledata/bigdata1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/bigdata1 31K 3.91G 31K /oracledata/bigdata1
root@Unixarena-SOL11:~# df -h /oracledata/bigdata1
Filesystem Size Used Available Capacity Mounted on
oracledata/bigdata1 3.9G 31K 3.9G 1% /oracledata/bigdata1
root@Unixarena-SOL11:~#

3.To create new dataset under parent dataset called oracledata/bigdata1,

root@Unixarena-SOL11:~# zfs list oracledata/bigdata1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/bigdata1 31K 3.91G 31K /oracledata/bigdata1
root@Unixarena-SOL11:~# zfs create oracledata/bigdata1/smalldata1
root@Unixarena-SOL11:~# zfs list oracledata/bigdata1/smalldata1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/bigdata1/smalldata1 31K 3.91G 31K /oracledata/bigdata1/smalldata1
root@Unixarena-SOL11:~#

Task:2-Modifying ZFS Dataset mountpoints

ZFS will automatically mount the dataset according to the dataset name which we have given.But most of the times ,we don;t ZFS to decide those mount points.We can set the new mountpoints according to our requirements.

1.Get the existing mountpoint details of dataset.

root@Unixarena-SOL11:~# zfs list oracledata/bigdata1/smalldata1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/bigdata1/smalldata1 31K 3.91G 31K /oracledata/bigdata1/smalldata1
root@Unixarena-SOL11:~#

2.Set the new mountpoint to the dataset.

root@Unixarena-SOL11:~# zfs set mountpoint=/smalldata1 oracledata/bigdata1/smalldata1
root@Unixarena-SOL11:~# zfs get mountpoint oracledata/bigdata1/smalldata1
NAME PROPERTY VALUE SOURCE
oracledata/bigdata1/smalldata1 mountpoint /smalldata1 local
root@Unixarena-SOL11:~#

3.Verify the mount point using df command.

root@Unixarena-SOL11:~# df -h /smalldata1
Filesystem Size Used Available Capacity Mounted on
oracledata/bigdata1/smalldata1
3.9G 31K 3.9G 1% /smalldata1
root@Unixarena-SOL11:~#

4.You can also set legacy mount point to dataset.(Traditional vfstab entry is required)

root@Unixarena-SOL11:~# zfs set mountpoint=legacy oracledata/bigdata1/smalldata1
root@Unixarena-SOL11:~# zfs list oracledata/bigdata1/smalldata1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/bigdata1/smalldata1 31K 200M 31K legacy
root@Unixarena-SOL11:~# mount -F zfs oracledata/bigdata1/smalldata1 /smalldata1
root@Unixarena-SOL11:~# df -h /smalldata1
Filesystem Size Used Available Capacity Mounted on
oracledata/bigdata1/smalldata1
200M 31K 200M 1% /smalldata1
root@Unixarena-SOL11:~#

5.If you don’t want to mount specific dataset to anywhere,you can use the below command.

root@Unixarena-SOL11:~# zfs set mountpoint=none oracledata/bigdata1/smalldata1
root@Unixarena-SOL11:~# zfs get mountpoint oracledata/bigdata1/smalldata1
NAME PROPERTY VALUE SOURCE
oracledata/bigdata1/smalldata1 mountpoint none local
root@Unixarena-SOL11:~#
Task:3-Create a dataset with specific size
(Quota & Reservation)

I am sure many of the ZFS beginners wonders how to create a ZFS datasets with specific size.There is no direct command to create it with specific size.To get the specific size datasets ,you need to set quota and reservation property to it.This will work like  VXVM volume.
1.List the ZFS datasets of specific zpool.

root@Unixarena-SOL11:~# zfs list |grep oracledata
oracledata 194K 3.91G 32K /oracledata
oracledata/bigdata1 62K 3.91G 31K /oracledata/bigdata1
oracledata/bigdata1/smalldata1 31K 3.91G 31K /smalldata1
root@Unixarena-SOL11:~# zfs get quota oracledata/bigdata1
NAME PROPERTY VALUE SOURCE
oracledata/bigdata1 quota none local

2.Set the quota property to dataset oracledata/bigdata1. Quota is the limit for the dataset which use the space from that zpool. 
*Zpool size:3.91GB
*After setting quota to oracledata/bigdata1,zpool size is 3.91GB.

root@Unixarena-SOL11:~# zfs set quota=200M oracledata/bigdata1
root@Unixarena-SOL11:~# zfs list oracledata/bigdata1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/bigdata1 62K 200M 31K /oracledata/bigdata1
root@Unixarena-SOL11:~# zfs list |grep oracledata
oracledata 194K 3.91G 32K /oracledata
oracledata/bigdata1 62K 200M 31K /oracledata/bigdata1
oracledata/bigdata1/smalldata1 31K 200M 31K /smalldata1
root@Unixarena-SOL11:~#

3.Set the Reservation property to oracledata/bigdata1 to get the space from zpool oracledata. zpool will not give any guarantee  to bigdata1 dataset that it will get the 200M from zpool unless you set reservation property even though you set quota to it.

root@Unixarena-SOL11:~# zfs set reservation=200M oracledata/bigdata1
root@Unixarena-SOL11:~# zfs get reservation oracledata/bigdata1
NAME PROPERTY VALUE SOURCE
oracledata/bigdata1 reservation 200M local
root@Unixarena-SOL11:~# zfs list |grep oracledata
oracledata 200M 3.71G 32K /oracledata
oracledata/bigdata1 62K 200M 31K /oracledata/bigdata1
oracledata/bigdata1/smalldata1 31K 200M 31K /smalldata1
root@Unixarena-SOL11:~#

4.Now you can see the mount point using df command .

root@Unixarena-SOL11:~# df -h /oracledata/bigdata1
Filesystem Size Used Available Capacity Mounted on
oracledata/bigdata1 200M 31K 200M 1% /oracledata/bigdata1
root@Unixarena-SOL11:~#


Task:4- How to increase/Reduce the dataset size 

If you create a dataset without specifying quota and reservation,then you can skip this task.You come to the situation to Increase or reduce the dataset size when you set quota and reservation datasets.
To increase the dataset size,
1.Get the quota and reservation size of the dataset

root@Unixarena-SOL11:~# zfs list oracledata/bigdata1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/bigdata1 62K 200M 31K /oracledata/bigdata1
root@Unixarena-SOL11:~# zfs get quota oracledata/bigdata1
NAME PROPERTY VALUE SOURCE
oracledata/bigdata1 quota 200M local
root@Unixarena-SOL11:~# zfs get reservation oracledata/bigdata1
NAME PROPERTY VALUE SOURCE
oracledata/bigdata1 reservation 200M local
root@Unixarena-SOL11:~#

2.Increase the dataset size by setting new values to quota and reservation.

root@Unixarena-SOL11:~# zfs set quota=400M oracledata/bigdata1
root@Unixarena-SOL11:~# zfs set reservation=400M oracledata/bigdata1
root@Unixarena-SOL11:~# zfs list oracledata/bigdata1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/bigdata1 62K 400M 31K /oracledata/bigdata1
root@Unixarena-SOL11:~#


Task:5 – Working with Emulated volumes.

Emulated volume is used for swap space.In ZFS ,if you want to create a volume without formatting with ZFS filesystem,you need to create emulated volume.
To create emulated volume,
1.List the zpool where you want to create the emulated volume.

root@Unixarena-SOL11:~# zfs list oracledata
NAME USED AVAIL REFER MOUNTPOINT
oracledata 114K 3.91G 31K /oracledata
root@Unixarena-SOL11:~#

2.Create a emulated volume with size of 1GB in the name of rawvol1.

root@Unixarena-SOL11:~# zfs create -V 1G oracledata/rawvol1
root@Unixarena-SOL11:~# zfs list oracledata/rawvol1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/rawvol1 1.03G 3.91G 16K -
root@Unixarena-SOL11:~#

3.You can see the size difference in zpool.

root@Unixarena-SOL11:~# zfs list |grep oracledata
oracledata 1.03G 2.87G 31K /oracledata
oracledata/rawvol1 1.03G 3.91G 16K -
root@Unixarena-SOL11:~#

4.Where to use these emulated volumes ?
    i.you can use it for swap.Here is the procedure to add ZFS swap.
    ii.You can format the volume with any filesystem and manually mount it with vfstab entries.
Example:

root@Unixarena-SOL11:~# mkfs -F ufs /dev/zvol/rdsk/oracledata/rawvol1  1G
mkfs: bad numeric arg for size: "1G"
mkfs: size reset to default 2097118
Warning: 4130 sector(s) in last cylinder unallocated
/dev/zvol/rdsk/oracledata/rawvol1: 2097118 sectors in 342 cylinders of 48 tracks, 128 sectors
1024.0MB in 25 cyl groups (14 c/g, 42.00MB/g, 20160 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 86176, 172320, 258464,
344608, 430752, 516896, 603040, 689184, 775328,
1292192, 1378336, 1464480, 1550624, 1636768, 1722912, 1809056, 1895200,
1981344, 2067488
root@Unixarena-SOL11:~#
root@Unixarena-SOL11:~# mount -F ufs /dev/zvol/dsk/oracledata/rawvol1 /rawvol1
root@Unixarena-SOL11:~# df -h /rawvol1
Filesystem Size Used Available Capacity Mounted on
/dev/zvol/dsk/oracledata/rawvol1
962M 1.0M 865M 1% /rawvol1
root@Unixarena-SOL11:~#

5.How can we increase the emulated volume size ? Let see.

root@Unixarena-SOL11:~# zfs set volsize=1.5G oracledata/rawvol1
root@Unixarena-SOL11:~# zfs list |grep oracledata/rawvol1
oracledata/rawvol1 1.55G 3.85G 62.7M -
root@Unixarena-SOL11:~#

After increasing the volume,you can increase the filesystem size using traditional ufs method using growfs command.

root@Unixarena-SOL11:~# df -h /rawvol1/
Filesystem Size Used Available Capacity Mounted on
/dev/zvol/dsk/oracledata/rawvol1
962M 1.0M 865M 1% /rawvol1
root@Unixarena-SOL11:~# umount /rawvol1
root@Unixarena-SOL11:~# growfs /dev/zvol/rdsk/oracledata/rawvol1
Warning: 34 sector(s) in last cylinder unallocated
/dev/zvol/rdsk/oracledata/rawvol1: 3145694 sectors in 512 cylinders of 48 tracks, 128 sectors
1536.0MB in 37 cyl groups (14 c/g, 42.00MB/g, 20160 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 86176, 172320, 258464, 344608, 430752, 516896, 603040, 689184, 775328,
2325920, 2412064, 2498208, 2584352, 2670496, 2756640, 2842784, 2928928,
3015072, 3101216
root@Unixarena-SOL11:~#
root@Unixarena-SOL11:~# mount -F ufs /dev/zvol/dsk/oracledata/rawvol1 /rawvol1
root@Unixarena-SOL11:~# df -h /rawvol1
Filesystem Size Used Available Capacity Mounted on
/dev/zvol/dsk/oracledata/rawvol1
1.4G 1.5M 1.3G 1% /rawvol1
root@Unixarena-SOL11:~#


Task:6 Destroying the ZFS datasets

“zfs destroy” command destroys the zfs datasets even though filesystem  is mounted. If you have child datasets,it will give you error that its having child datasets. But still you can remove dataset using -r option. 
Note:This operation can not be undone.
1.Destroying normal datasets.

root@Unixarena-SOL11:~# zfs list oracledata/data1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/data1 31K 3.91G 31K /oracledata/data1
root@Unixarena-SOL11:~# zfs destroy oracledata/data1
root@Unixarena-SOL11:~# zfs list oracledata/data1
cannot open 'oracledata/data1': filesystem does not exist
root@Unixarena-SOL11:~#

2.Destroying Emulated ZFS volume.

root@Unixarena-SOL11:~# zfs list oracledata/rawvol1
NAME USED AVAIL REFER MOUNTPOINT
oracledata/rawvol1 1.55G 3.82G 92.9M -
root@Unixarena-SOL11:~# zfs destroy oracledata/rawvol1
root@Unixarena-SOL11:~# zfs list oracledata/rawvol1
cannot open 'oracledata/rawvol1': filesystem does not exist
root@Unixarena-SOL11:~#

3.Let see what will happen, if you try to destroy dataset which has child datasets.

root@Unixarena-SOL11:~# zfs list |grep data1
oracledata/data1 63K 3.91G 32K /oracledata/data1
oracledata/data1/child1 31K 3.91G 31K /oracledata/data1/child1
root@Unixarena-SOL11:~#
root@Unixarena-SOL11:~# zfs destroy oracledata/data1
cannot destroy 'oracledata/data1': filesystem has children
use '-r' to destroy the following datasets:
oracledata/data1/child1
root@Unixarena-SOL11:~# zfs destroy -r oracledata/data1
root@Unixarena-SOL11:~# zfs list |grep data1
root@Unixarena-SOL11:~#


Hope this article is helpful for Solaris administrators. Thank you for reading this article.

VMTURBO-CLOUD-CAPACITY

Leave a Reply

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