ZFS Cheatsheet

For those of us who orbit around the sun rather than live there:

There are two main commands for ZFS, “zfs” and “zpool”

"zpool list" - Show current usage on zfs pools
"zpool iostat 5" - Display I/O stats for zfs pools
"zpool vdevs" - Shows current mirror/pool device properties
"zpool create pool c0t3d0 c1t1d0 c4t4d0 c5t2d0" - Creates a pool consisting of c0t3d0 c1t1d0, c4t4d0, c5t2d0
"zpool create -fv pool slice1 slice2" - Creates a pool consisting of slice1 and slice2
"zpool create pool mirror c1t0d0 c2t0d0" - Creates a mirror consisting of c2t0d0 and c2t0d0
"zpool add -f pool mirror c0t1d0s3 c0t1d0s4" - Adds mirror to pool
"zfs list" - Show current zfs filesystems
"zfs create pool/filesystem" - Creates filesystem under pool
"zfs create pool/filesystem /mountpoint" - Creates filesystem under pool and mounts it to mountpoint
"zfs snapshot pool/filesystem@snapshotname" - Takes snapshot of filesystem
"zfs mount pool/filesystem /mountpoint" - Mounts a zfs filesystem to mountpoint
"zfs destroy pool/filesystem" - Deletes filesystem from pool
"zfs destroy pool" - Deletes pool

Package Name: SUNWzfs
Older Solaris 10 u6 and below you cannot export and import the disks. So moving them to new hardware is not possible :(
There is never a need to fsck a ZFS filesystem.

NOTE BENE: I get a lot of traffic on this page and I’m sure some of you guys have cheatsheets and crib notes of your own for zfs. Please feel free to leave a comment with your favorite commands.  We can all learn from each other.

About Jay Farschman - Jay currently works as a Senior Systems Administrator for an asset management company in Colorado where he works with companies that produce hardware, telecommunications software and financial services.  Jay previously owned a consulting company and provided training and consulting services for three Fortune 500 companies and numerous small businesses where he leveraged Linux to provided exceptional value

Dealing with ZFS Boot Problems

As a Sys Admin who gives his user’s plenty of power to sometimes things get messed up in the boot process so that the system cannot boot properly.  No prob0lem you say, boot from CDROM into single-user mode and mount partition, find and fix the problem……. ummmm, wait.  How do I do that?  This article covers how to mount ZFS in single-user mode.  Fixing the problem is up to you.

STEPS

  1. First get an OK prompt.   With a Fujitsu-based system this is accomplished by logging into the contol interface and issuing a sendbreak -d 0.  Refer to your manual, or drop me a comment if you need a hand with this.
  2. Insert the CDROM and issue a “boot cdrom -s”
  3. “zfs list” is going to show you all of the available zpools.
    NAME                        USED  AVAIL  REFER  MOUNTPOINT
    rpool                      12.5G  54.4G    97K  /rpool
    rpool/ROOT                 6.97G  54.4G    21K  legacy
    rpool/ROOT/s10s_u8wos_08a  6.97G  54.4G  6.97G  /
    rpool/dump                 1.00G  54.4G  1.00G  -
    rpool/export               2.53G  54.4G  23.5K  /export
    rpool/export/home          2.53G  54.4G  2.53G  /export/home
    rpool/swap                    2G  56.4G    16K  -
  4. zfs get mountpoint rpool/ROOT/s10s_u8wos_08a is going to show you that the mountpoint is / and we know that is already in use.
    NAME                       PROPERTY    VALUE       SOURCE
    rpool/ROOT/s10s_u8wos_08a  mountpoint  /           local
  5. Change that mount point temporarily with the command “zfs set mountpoint=/mnt rpool/ROOT/s10s_u8wos_08a”
  6. “zfs mount rpool/ROOT/s10s_u8wos_08a”

At this point simply cd on over to the problem file and fix it.  In my case the user had modified the /etc/vsftab file so that it could no longer boot so I had to edit /mnt/etc/vfstab.

About Jay Farschman - Jay currently works as a Senior Systems Administrator for an asset management company in Colorado where he works with companies that produce hardware, telecommunications software and financial services.  Jay previously owned a consulting company and provided training and consulting services for three Fortune 500 companies and numerous small businesses where he leveraged Linux to provided exceptional value