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
logrotate How log rotation works with logrotate
Viewed 751 times since Sun, Jan 12, 2020
How to Migrate from RHEL 8 to CentOS 8
Viewed 94 times since Fri, May 15, 2020
Telnet – Send GET/HEAD HTTP Request
Viewed 422 times since Mon, Feb 18, 2019
RHCS: Configure an active/backup pacemaker cluster
Viewed 879 times since Sun, Jun 3, 2018
sed Delete / Remove ^M Carriage Return (Line Feed / CRLF) on Linux or Unix
Viewed 516 times since Thu, Feb 7, 2019
high swap space utilization in LINUX
Viewed 482 times since Fri, Jul 13, 2018
OpenSSL: Check SSL Certificate Expiration Date and More
Viewed 567 times since Mon, Feb 18, 2019
20 IPtables Examples For New SysAdmins
Viewed 329 times since Fri, May 15, 2020
stunnel Howto A Guide to create SSL access to a HTTP-only webserver with stunnel
Viewed 455 times since Fri, Sep 28, 2018
How to mount software RAID1 member using mdadm
Viewed 444 times since Wed, Oct 3, 2018