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 Add Swap Space on Ubuntu 16.04
Viewed 2414 times since Fri, Jun 8, 2018
List DNS records, nameservers of a domain from command line
Viewed 2076 times since Sun, Sep 30, 2018
20 Linux Command Tips and Tricks That Will Save You A Lot of Time linux
Viewed 4840 times since Thu, Apr 18, 2019
How to retrieve and change partition’s UUID Universally Unique Identifier on linux
Viewed 3152 times since Tue, Jul 17, 2018
Inxi: Find System And Hardware Information On Linux
Viewed 2375 times since Sat, Jun 2, 2018
How To Set Up an SSL Tunnel Using Stunnel on Ubuntu
Viewed 3383 times since Fri, Sep 28, 2018
stunnel basics and pki standards
Viewed 9544 times since Fri, Sep 28, 2018
SSH ProxyCommand example: Going through one host to reach another server
Viewed 13744 times since Tue, Aug 6, 2019
WatchDog watchdog.sh script for checking server running
Viewed 5478 times since Tue, Jul 31, 2018
RHCS6: Quorum disk and heuristics
Viewed 4295 times since Sun, Jun 3, 2018