ZFS: Create a new zfs filesystem

ZFS: Create a new zfs filesystem

# Tested on RHEL 6 & 7

# Select the zpool where F.S. will be created

zpool list
   NAME     SIZE  ALLOC   FREE    CAP  DEDUP  HEALTH  ALTROOT
   c_pool  9.94G   120K  9.94G     0%  1.00x  ONLINE  -
   m_pool  9.94G   100K  9.94G     0%  1.00x  ONLINE  -


ZPOOL=c_pool


zpool status $ZPOOL
     pool: c_pool
    state: ONLINE
    scan: none requested
   config:

           NAME        STATE     READ WRITE CKSUM
           c_pool      ONLINE       0     0     0
             sdb       ONLINE       0     0     0
             sdc       ONLINE       0     0     0

   errors: No known data errors


# Create the new zfs

ZFSFS=zfs01
MNTPT=zfs01            # Without "/"

# During F.S. creation options can be specified. Mount point for the newly created F.S.
# is optional. If not specified, F.S. will be mounted under <zpool_mount_point>/<newfs_name>
# (on the other hand, if specified at the moment of creation, mountpoint won't be automatically
# removed when destroying the zfs)

zfs create  -o mountpoint=/$MNTPT  -o sharenfs=on -o compression=on $ZPOOL/$ZFSFS


# Check

zfs list
   NAME           USED  AVAIL  REFER  MOUNTPOINT
   c_pool         153K  19.6G    30K  /c_pool
   c_pool/zfs01    30K  19.6G    30K  /zfs01    <----
   m_pool         100K  9.78G    30K  /m_pool


df -h -F zfs
   Filesystem            Size  Used Avail Use% Mounted on
   m_pool                9.8G     0  9.8G   0% /m_pool
   c_pool                 20G  128K   20G   1% /c_pool
   c_pool/zfs01           20G  128K   20G   1% /zfs01
   <----



# If no quota (F.S. size) is assigned to new filesystem it will be able to use all
# the space available on the pool, what may be a little bit dangerous if pool is
# being shared by several filesystems.
#
# Example:
#
# We have a filesystem named <filesystem01> that has been created on <pool_c> with no
# quota restrictions:
#
# root@server:/root#> zfs list
#    NAME                     USED  AVAIL  REFER  MOUNTPOINT
#    pool_c                141K  3.91G    32K  /pool_c
#    pool_c/filesystem01    31K  3.91G    31K  /pool_c/filesystem01
#
#
# We fill the F.S. a little bit:
#
# root@server:/pool_c/filesystem01#> mkfile 2048m /pool_c/filesystem01/file01
#
# root@server:/pool_c/filesystem01#> zfs list
#    NAME                     USED  AVAIL  REFER  MOUNTPOINT
#    pool_c               2.00G  1.91G    32K  /pool_c
#    pool_c/filesystem01  2.00G  1.91G  2.00G  /pool_c/filesystem01
#
# We create a new filesystem without quota on the pool
#
# root@server:/pool_c/filesystem01#> zfs create pool_c/filesystem02
#
# root@server:/pool_c/filesystem01#> zfs list
#    NAME                     USED  AVAIL  REFER  MOUNTPOINT
#    pool_c               2.00G  1.91G    32K  /pool_c
#    pool_c/filesystem01  2.00G  1.91G  2.00G  /pool_c/filesystem01
#    pool_c/filesystem02    31K  1.91G    31K  /pool_c/filesystem02
#
#
# If we continue to fill up the first F.S.
#
# root@server:/pool_c/filesystem01#> mkfile 1024m /pool_c/filesystem01/file02
#
#
# The available space for all F.S. belonging to the pool will be reduced
#
# root@server:/pool_c/filesystem01#> zfs list
#    NAME                     USED  AVAIL  REFER  MOUNTPOINT
#    pool_c               2.98G   948M    33K  /pool_c
#    pool_c/filesystem01  2.98G   948M  2.98G  /pool_c/filesystem01
#    pool_c/filesystem02    31K   948M    31K  /pool_c/filesystem02
#
#
# *** We can use the 'quota' property to set a limit on the amount of disk space a file
# system can use. In addition, we can use the 'reservation' property to guarantee that a
# specified amount of disk space is available to a file system. Both properties apply to
# the dataset on which they are set and all descendents of that dataset.
#
# The 'refquota' and 'refreservation' properties are used to manage file system space
# without accounting for disk space consumed by descendents, such as snapshots and clones.
#
# Setting the 'refquota' or 'refreservation' property higher than the 'quota' or
# 'reservation' property has no effect. If you set the 'quota' or 'refquota' property,
# operations that try to exceed either value fail. It is possible to a exceed a 'quota'
# that is greater than the 'refquota'. For example, if some snapshot blocks are modified,
# you might actually exceed the 'quota' before you exceed the 'refquota'.



# Let's add a quota to our filesystem


zfs set quota=1g $ZPOOL/$ZFSFS


zfs list
   NAME           USED  AVAIL  REFER  MOUNTPOINT
   c_pool         153K  19.6G    30K  /c_pool
   c_pool/zfs01    30K  1024M    30K  /zfs01 
  <----
   m_pool         100K  9.78G    30K  /m_pool
0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
RHCS6: Install a two-node basic cluster
Viewed 3566 times since Sun, Jun 3, 2018
How To: Linux Hard Disk Encryption With LUKS [ cryptsetup Command ]
Viewed 7467 times since Fri, Jul 13, 2018
Linux Cluster Tutorial
Viewed 2255 times since Sat, Sep 29, 2018
How setting the TZ environment variable avoids thousands of system calls
Viewed 10338 times since Mon, May 21, 2018
Setting up encrypted tunnel using stunnel
Viewed 2660 times since Fri, Sep 28, 2018
ZFS: Verify/change properties of a zfs filesystem
Viewed 2727 times since Sun, Jun 3, 2018
RHEL: Services basic management - systemd
Viewed 18897 times since Sat, Jun 2, 2018
Top 4 Reasons for Node Reboot or Node Eviction in Real Application Cluster (RAC) Environment
Viewed 101223 times since Thu, Jun 21, 2018
20 Linux YUM (Yellowdog Updater, Modified) Commands for Package Management YUM
Viewed 11461 times since Thu, Oct 25, 2018
Enabling or disabling a repository using Red Hat Subscription Management
Viewed 10279 times since Mon, Oct 29, 2018