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
How To Use Systemctl to Manage Systemd Services and Units
Viewed 7597 times since Mon, Dec 7, 2020
RHCS6: Basic operations on clustered services
Viewed 2751 times since Sun, Jun 3, 2018
HowTo: The Ultimate Logrotate Command Tutorial with 10 Examples
Viewed 5385 times since Fri, Nov 30, 2018
SSH ProxyCommand example: Going through one host to reach another server
Viewed 13744 times since Tue, Aug 6, 2019
Manage SSH Key File With Passphrase
Viewed 2344 times since Tue, Mar 5, 2019
How to encrypt a partition using LUKS?
Viewed 1924 times since Fri, Jul 13, 2018
bash mistakes This page is a compilation of common mistakes made by bash users. Each example is flawed in some way.
Viewed 9178 times since Sun, Dec 6, 2020
RHEL: Services basic management - chkconfig
Viewed 5748 times since Sat, Jun 2, 2018
How to Synchronize Directories Using Lsyncd in Linux
Viewed 13984 times since Wed, Oct 31, 2018
RHEL: Bonding network interfaces
Viewed 3792 times since Sat, Jun 2, 2018