Thursday, November 19, 2009

[Level 2] How to get ZFS clone file system?

Now I have use VirtualBox with ZFS clone file system.
So sometimes, I have to figure out which file system is native, which file system is clone.
Therefore, I write a script to list the ZFS clone file system.

#!/usr/bin/bash
showUsage() {
  cat <
<EOF
Usage:
  $0 pool_name
Ex.
  $0 rpool
EOF
}

######################################################## main

[ $# -lt 1 ] && echo "Error without parameters, exit program..." && showUsage && exit 1
sPoolname=$1 #sPoolname=${1:-rpool}
echo "get pool($sPoolname)..."
zfs get -r origin $sPoolname | egrep -v -- 'origin[ ]+-[ ]+-$'


The you can use the command to find out the clone file system.
# getCloneFS.sh rpool

get pool(rpool)...
NAME                                          PROPERTY  VALUE                                         SOURCE
rpool/ROOT/opensolaris                        origin    rpool/ROOT/opensolaris-1@2009-11-18-05:46:35  -
#





Wish this helps.

regards,
Stanley Huang