ZFS: Grow/Shrink an existing zfs filesystem

ZFS: Grow/Shrink an existing zfs filesystem

# Tested on RHEL 6 & 7


# Choose the F.S. to resize and verify current size

zfs list
   NAME           USED  AVAIL  REFER  MOUNTPOINT
   c_pool         204K  19.6G    30K  /c_pool
   c_pool/zfs01    30K  1024M    30K  /zfs01
   c_pool/zfs02    30K  19.6G    30K  /filesystem02
   m_pool         100K  9.78G    30K  /m_pool


ZPOOL=c_pool
ZFS=zfs01


df -h /$ZFS
   Filesystem            Size  Used Avail Use% Mounted on
   c_pool/zfs01          1.0G  128K  1.0G   1% /zfs01



# Extend F.S. to 2GB

zfs set quota=2g $ZPOOL/$ZFS



# Check

zfs list
   NAME           USED  AVAIL  REFER  MOUNTPOINT
   c_pool         204K  19.6G    30K  /c_pool
   c_pool/zfs01    30K  2.00G    30K  /zfs01
   c_pool/zfs02    30K  19.6G    30K  /filesystem02
   m_pool         100K  9.78G    30K  /m_pool


df -h /$ZFS
   Filesystem            Size  Used Avail Use% Mounted on
   c_pool/zfs01          2.0G  128K  2.0G   1% /zfs01



# Reduce F.S. back to 1GB

zfs set quota=1g $ZPOOL/$ZFS



# Check

zfs list
   NAME           USED  AVAIL  REFER  MOUNTPOINT
   c_pool         204K  19.6G    30K  /c_pool
   c_pool/zfs01    30K  1024M    30K  /zfs01
   c_pool/zfs02    30K  19.6G    30K  /filesystem02
   m_pool         100K  9.78G    30K  /m_pool



df -h /$ZFS
   Filesystem            Size  Used Avail Use% Mounted on
   c_pool/zfs01          1.0G  128K  1.0G   1% /zfs01



# Here is what happens if we fill up a little bit our filesystem and then try to reduce it
# below the boundary of used space

df -h /$ZFS
   Filesystem            Size  Used Avail Use% Mounted on
   c_pool/zfs01          1.0G  350M  675M  35% /zfs01


zfs set quota=256m $ZPOOL/$ZFS
   cannot set property for 'c_pool/zfs01': size is less than current used or reserved space
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
Open SSL Creating Certificate Signing Request — CSR Generation
Viewed 1977 times since Mon, Feb 18, 2019
logrotate Log Rotate Configuration
Viewed 3258 times since Sun, Jan 12, 2020
SSH ProxyCommand example: Going through one host to reach another server
Viewed 13744 times since Tue, Aug 6, 2019
10 Linux DIG Command Examples for DNS Lookup
Viewed 11184 times since Sun, Sep 30, 2018
Index » Community Contributions » System encryption using LUKS and GPG encrypted keys for arch linux
Viewed 3283 times since Fri, Jul 13, 2018
Enabling or disabling a repository using Red Hat Subscription Management
Viewed 9943 times since Mon, Oct 29, 2018
Secure Remote Logging to Central Log Server Using RSYSLOG on CentOS 6 / CentOS 7 and stunnel
Viewed 4097 times since Sun, Dec 6, 2020
Linux / UNIX: DNS Lookup Command
Viewed 9654 times since Sun, Sep 30, 2018
Tip: SSD and Linux. Enable TRIM and check if it works
Viewed 17148 times since Fri, May 15, 2020
Need to set up yum repository for locally-mounted DVD on Red Hat Enterprise Linux 7
Viewed 3235 times since Mon, Oct 29, 2018