How to grow a ZFS Volume.
Assume the following is true:
1. Display file system mount status
# df -h /mnt/vol1/
Filesystem size used avail capacity Mounted on
/dev/zvol/dsk/fort/vol1
962M 1.0M 903M 1% /mnt/vol1Notice its 1Gig in size (962M formatted).
2. Display current ZFS volume size and reservation properties
# zfs get volsize,reservation fort/vol1
NAME PROPERTY VALUE SOURCE
fort/vol1 volsize 1G -
fort/vol1 reservation 1G localConfirms the volume is 1Gig in size with a 1Gig reservation.
3. Change the volsize ZFS property for fort/vol1 to 2Gig.
# zfs set volsize=2g fort/vol1
4. Confirm the changes were made by displaying the volsize and reservation ZFS properties.
# zfs get volsize,reservation fort/vol1
NAME PROPERTY VALUE SOURCE
fort/vol1 volsize 2G -
fort/vol1 reservation 2G localNotice the “volsize” is now set to 2Gig. At this point, the OS doesnt see the expanded file system. In order for the OS to see the size, you will have to expand the file system with “growfs”.
5. Run growfs to expand mounted file system
# growfs -M /mnt/vol1 /dev/zvol/rdsk/fort/vol1
Warning: 2048 sector(s) in last cylinder unallocated
/dev/zvol/rdsk/fort/vol1: 4194304 sectors in 683 cylinders of 48 tracks, 128 sectors
2048.0MB in 49 cyl groups (14 c/g, 42.00MB/g, 20160 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 86176, 172320, 258464, 344608, 430752, 516896, 603040, 689184, 775328,
3359648, 3445792, 3531936, 3618080, 3704224, 3790368, 3876512, 3962656,
4048800, 4134944The output should now show you the new volume size.
6. Confirm the size of mounted file system using df or dd.
# df -h /mnt/vol1/
Filesystem size used avail capacity Mounted on
/dev/zvol/dsk/fort/vol1
1.9G 2.0M 1.8G 1% /mnt/vol1
# dd if=/dev/zvol/dsk/fort/vol1 of=/dev/null bs=1024k
2048+0 records in
2048+0 records out
Thats it! Growing a ZFS volume is an online operation in my mind.
Your example is ‘partially’ correct. You did grow the ZFS volume using the “zfs set volsize=2g fort/vol1” command. However, your “growfs -M /mnt/vol1 /dev/zvol/rdsk/fort/vol1” command has __nothing__ to do with the volume. There you are simply growing your UFS file system which is mounted on top of your volume. Why would you use UFS there anyway? Why not just use ZFS? Technically, you cannot mount a ZFS volume. You left out the step where you created your UFS file system on top of your ZFS volume.
Great blog! For a beginner at ZFS this really helped.