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
LVM: Reduce SWAP size by removing a Logical Volume
Viewed 1746 times since Sat, Jun 2, 2018
How To: Linux Hard Disk Encryption With LUKS [ cryptsetup Command ]
Viewed 7015 times since Fri, Jul 13, 2018
Tip: SSD and Linux. Enable TRIM and check if it works
Viewed 7101 times since Fri, May 15, 2020
Linux RAID Mdadm Cheat Sheet
Viewed 4906 times since Fri, May 15, 2020
15 Linux Yum Command Examples – Install, Uninstall, Update Packages
Viewed 2940 times since Thu, Oct 25, 2018
HowTo: Retrieve Email from a POP3 Server using the Command Line
Viewed 9135 times since Mon, Feb 18, 2019
30 Handy Bash Shell Aliases For Linux / Unix / MacOS
Viewed 4112 times since Thu, Feb 11, 2021
How to find your System details using inxi
Viewed 2967 times since Sat, Jun 2, 2018
What is OS Watcher Utility and How to use it for Database Troubleshooting ?
Viewed 29478 times since Thu, Jun 21, 2018
linux aix Killing a process and all of its descendants
Viewed 3296 times since Tue, May 5, 2020