ZFS Cheat Sheet Including Zpool, Quotas and Reservations

Sorry for the long title post. I just want to easily distinguish this post from my other ZFS post. The reason? For this week, I’ll be working on a server with ZFS filesystem and looks like the SAs for the servers is not yet familiar with the filesystem. I am the newest member of the UNIX team and there’s this request to grow a filesystem that is directly mounted from a disk slice.. Told the guy that we may need to modify the disk geometry and we may have to repartition the disk.. Then I noticed that there is a 140G disk under ZFS partition. I will convince the user to use that spare disk for his project.

And here are the cheat sheet for ZFS/zpool that is related to this week’s project.

The whole exaple uses virtual devices.. that is chucks of files that represents disk.. of course if you have physical disk available, you may use those.

Here’s how to create “virtual devices” or vdevs as described in the zpool documentation. These can also be real disk slices if you have them available.

$ su
Password:
# cd /
# mkfile 100m disk1 disk2 disk3 disk5
# mkfile 50m disk4
# ls -l disk*
-rw------T 1 root root 104857600 Sep 11 12:15 disk1
-rw------T 1 root root 104857600 Sep 11 12:15 disk2
-rw------T 1 root root 104857600 Sep 11 12:15 disk3
-rw------T 1 root root 52428800 Sep 11 12:15 disk4
-rw------T 1 root root 104857600 Sep 11 12:15 disk5

Here’s how to create a storage pool and check the size and usage.

# zpool create myzfs /disk1 /disk2
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
myzfs 191M 94K 191M 0% ONLINE -

When you created a disk pool, you can create a ZFS Filesystem which also in turn,

Create a second file system. Note that both file system show 159M available because no quotas are set. Each “could” grow to fill the pool.

# zfs create myzfs/colin2
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 172K 159M 21K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin2 18K 159M 18K /myzfs/colin2

Reserve a specified amount of space for a file system ensuring that other users don’t take up all the space.

# zfs set reservation=20m myzfs/colin
# zfs list -o reservation
RESERV
none
20M
none

Set and view quotas

# zfs set quota=20m myzfs/colin2
# zfs list -o quota myzfs/colin myzfs/colin2
QUOTA
none
20M

Destroy a filesystem

# zfs destroy myzfs/colin2
# zfs list
NAME USED AVAIL REFER MOUNTPOINT
myzfs 20.1M 139M 22K /myzfs
myzfs/colin 18K 159M 18K /myzfs/colin
myzfs/colin@test 0 – 18K –
myzfs/colin3 0 139M 18K /myzfs/colin3

That’s what I need for now.. will continue addiction ZFS cheat sheet if needed.. Pardon me, but my primary use of this blog site is for my use 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *