Tuesday, February 23, 2010

Solaris: ZFS Administration

ZFS has been designed to be robust, scalable and simple to administer.


ZFS pool storage features:
ZFS eliminates the volume management altogether. Instead of forcing us to create virtual volumes, ZFS aggregates devices into a storage pool. The storage pool describes the physical characteristics of the storage (device layout, data redundancy, and so on,) and acts as arbitrary data store from which the file systems can be created.
File systems grow automatically within the space allocated to the storage pool.
ZFS is a transactional file system, which means that the file system state is always consistent on disk. With a transactional file system, data is managed using coy on write semantics.
ZFS supports storage pools with varying levels of data redundancy, including mirroring and a variation on RAID-5. When a bad data block is detected, ZFS fetches the correct data from another replicated copy, and repairs the bad data, replacing it with the good copy.
The file system itself if 128-bit, allowing for 256 quadrillion zettabytes of storage. Directories ca have up to 2 to the power of 48 (256 trillion) entries, and no limit exists on the number of file systems or number of files that can be contained within a file system.
A snapshot is a read-only copy of a file system or volume. Snapshots can be created quickly and easily. Initially, snapshots consume no additional space within the pool.
Clone – A file system whose initial contents are identical to the contents of a snapshot.

ZFS component Naming requirements:
Each ZFS component must be named according to the following rules;
1. Empty components are not allowed.
2. Each component can only contain alphanumeric characters in addition to the following 4 special characters:
a. Underscore (_)
b. Hyphen (-)
c. Colon (: )
d. Period (.)
3. Pool names must begin with a letter, expect that the beginning sequence c(0-9) is not allowed (this is because of the physical naming convention). In addition, pool names that begin with mirror, raid z, or spare are not allowed as these name are reserved.
4. Data set names must begin with an alphanumeric character.

ZFS Hardware and Software requirements and recommendations:
1. A SPARC or X86 system that is running the Solaris 10 6/06 release or later release.
2. The minimum disk size is 128 M bytes. The minimum amount of disk space required for a storage pool is approximately 64 Mb.
3. The minimum amount of memory recommended to install a Solaris system is 512 Mb. However, for good ZFS performance, at least 1 Gb or more of memory is recommended.
4. Whilst creating a mirrored disk configuration, multiple controllers are recommended.



ZFS Steps:

zpool create
zpool add
zpool remove
zpool attach
zpool detach
zpool destroy
zpool list
zpool status
zpool replace



zfs create
zfs destroy
zfs snapshot
zfs rollback
zfs clone
zfs list
zfs set
zfs get
zfs mount
zfs unmount
zfs share
zfs unshare




Output: Creating a zpool:

bash-3.00# zpool create testpool c2d0s7
bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 2G 77.5K 2.00G 0% ONLINE -

bash-3.00# df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c1d0s0 20G 10G 9.3G 53% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.3G 728K 3.3G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
/usr/lib/libc/libc_hwcap2.so.1
20G 10G 9.3G 53% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 3.3G 48K 3.3G 1% /tmp
swap 3.3G 32K 3.3G 1% /var/run
testpool 2.0G 24K 2.0G 1% /testpool



Output: Creating a directory under a zpool:

bash-3.00# zfs create testpool/homedir
bash-3.00# df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c1d0s0 20G 10G 9.3G 53% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.3G 728K 3.3G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
/usr/lib/libc/libc_hwcap2.so.1
20G 10G 9.3G 53% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 3.3G 48K 3.3G 1% /tmp
swap 3.3G 32K 3.3G 1% /var/run
testpool 2.0G 25K 2.0G 1% /testpool
testpool/homedir 2.0G 24K 2.0G 1% /testpool/homedir

bash-3.00# mkfile 100m testpool/homedir/newfile
bash-3.00# df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c1d0s0 20G 10G 9.1G 54% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.1G 728K 3.1G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
/usr/lib/libc/libc_hwcap2.so.1
20G 10G 9.1G 54% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 3.1G 48K 3.1G 1% /tmp
swap 3.1G 32K 3.1G 1% /var/run
testpool 2.0G 25K 1.9G 1% /testpool
testpool/homedir 2.0G 100M 1.9G 5% /testpool/homedir


Mirror:

bash-3.00# zpool create testmirrorpool mirror c2d0s3 c2d0s4
bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testmirrorpool 4.97G 52.5K 4.97G 0% ONLINE -
testpool 2G 100M 1.90G 4% ONLINE -
bash-3.00# df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c1d0s0 20G 10G 9.1G 54% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.1G 736K 3.1G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
/usr/lib/libc/libc_hwcap2.so.1
20G 10G 9.1G 54% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 3.1G 48K 3.1G 1% /tmp
swap 3.1G 32K 3.1G 1% /var/run
testpool 2.0G 25K 1.9G 1% /testpool
testpool/homedir 2.0G 100M 1.9G 5% /testpool/homedir
testmirrorpool 4.9G 24K 4.9G 1% /testmirrorpool



bash-3.00# cat /etc/mnttab
#device device mount FS fsck mount mount
#to mount to fsck point type pass at boot options
#

testpool /testpool zfs rw,devices,setuid,exec,atime,dev=2d50002 125 8087961
testpool/homedir /testpool/homedir zfs rw,devices,setuid,exec,atime,dev=2d 50003 1258088096
testmirrorpool /testmirrorpool zfs rw,devices,setuid,exec,atime,dev=2d50004 125 8089634


DESTROYING A POOL:

bash-3.00# zpool destroy testmirrorpool
bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 2G 100M 1.90G 4% ONLINE -



MANAGING ZFS PROPERTIES:

bash-3.00# zfs get all testpool/homedir
NAME PROPERTY VALUE SOURCE
testpool/homedir type filesystem -
testpool/homedir creation Sat Nov 14 11:34 2009 -
testpool/homedir used 24.5K -
testpool/homedir available 4.89G -
testpool/homedir referenced 24.5K -
testpool/homedir compressratio 1.00x -
testpool/homedir mounted yes -
testpool/homedir quota none default
testpool/homedir reservation none default
testpool/homedir recordsize 128K default
testpool/homedir mountpoint /testpool/homedir default
testpool/homedir sharenfs off default
testpool/homedir checksum on default
testpool/homedir compression off default
testpool/homedir atime on default
testpool/homedir devices on default
testpool/homedir exec on default
testpool/homedir setuid on default
testpool/homedir readonly off default
testpool/homedir zoned off default
testpool/homedir snapdir hidden default
testpool/homedir aclmode groupmask default
testpool/homedir aclinherit secure default


bash-3.00# zfs set quota=500m testpool/homedir

bash-3.00# zfs set compression=on testpool/homedir

bash-3.00# zfs set mounted=no testpool/homedir
cannot set mounted property: read only property

bash-3.00# zfs get all testpool/homedir
NAME PROPERTY VALUE SOURCE
testpool/homedir type filesystem -
testpool/homedir creation Sat Nov 14 11:34 2009 -
testpool/homedir used 24.5K -
testpool/homedir available 500M -
testpool/homedir referenced 24.5K -
testpool/homedir compressratio 1.00x -
testpool/homedir mounted yes -
testpool/homedir quota 500M local
testpool/homedir reservation none default
testpool/homedir recordsize 128K default
testpool/homedir mountpoint /testpool/homedir default
testpool/homedir sharenfs off default
testpool/homedir checksum on default
testpool/homedir compression on local
testpool/homedir atime on default
testpool/homedir devices on default
testpool/homedir exec on default
testpool/homedir setuid on default
testpool/homedir readonly off default
testpool/homedir zoned off default
testpool/homedir snapdir hidden default
testpool/homedir aclmode groupmask default
testpool/homedir aclinherit secure default


INHERITING ZFS PROPERTIES:

bash-3.00# zfs get -r compression testpool
NAME PROPERTY VALUE SOURCE
testpool compression off default
testpool/homedir compression on local
testpool/homedir/nesteddir compression on local

bash-3.00# zfs inherit compression testpool/homedir

bash-3.00# zfs get -r compression testpool
NAME PROPERTY VALUE SOURCE
testpool compression off default
testpool/homedir compression off default
testpool/homedir/nesteddir compression on local

bash-3.00# zfs inherit -r compression testpool/homedir

bash-3.00# zfs get -r compression testpool
NAME PROPERTY VALUE SOURCE
testpool compression off default
testpool/homedir compression off default
testpool/homedir/nesteddir compression off default

QUERYING ZFS PROPERTIES:

bash-3.00# zfs get checksum testpool/homedir
NAME PROPERTY VALUE SOURCE
testpool/homedir checksum on default

bash-3.00# zfs get all testpool/homedir
NAME PROPERTY VALUE SOURCE
testpool/homedir type filesystem -
testpool/homedir creation Sat Nov 14 11:34 2009 -
testpool/homedir used 50K -
testpool/homedir available 500M -
testpool/homedir referenced 25.5K -
testpool/homedir compressratio 1.00x -
testpool/homedir mounted yes -
testpool/homedir quota 500M local
testpool/homedir reservation none default
testpool/homedir recordsize 128K default
testpool/homedir mountpoint /testpool/homedir default
testpool/homedir sharenfs off default
testpool/homedir checksum on default
testpool/homedir compression off default
testpool/homedir atime on default
testpool/homedir devices on default
testpool/homedir exec on default
testpool/homedir setuid on default
testpool/homedir readonly off default
testpool/homedir zoned off default
testpool/homedir snapdir hidden default
testpool/homedir aclmode groupmask default
testpool/homedir aclinherit secure default

bash-3.00# zfs get -s local all testpool/homedir
NAME PROPERTY VALUE SOURCE
testpool/homedir quota 500M local



RAID-Z POOL:

bash-3.00# zpool create testraid5pool raidz c2d0s3 c2d0s4 c2d0s5
bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 2G 100M 1.90G 4% ONLINE -
testraid5pool 14.9G 89K 14.9G 0% ONLINE -
bash-3.00# df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c1d0s0 20G 10G 9.1G 54% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.1G 736K 3.1G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
/usr/lib/libc/libc_hwcap2.so.1
20G 10G 9.1G 54% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 3.1G 48K 3.1G 1% /tmp
swap 3.1G 32K 3.1G 1% /var/run
testpool 2.0G 25K 1.9G 1% /testpool
testpool/homedir 2.0G 100M 1.9G 5% /testpool/homedir
testraid5pool 9.8G 32K 9.8G 1% /testraid5pool


DOUBLE PARITY RAID-Z POOL:

bash-3.00# zpool create doubleparityraid5pool raidz2 c2d0s3 c2d0s4 c2d0s5
bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
doubleparityraid5pool 14.9G 158K 14.9G 0% ONLINE -
testpool 2G 100M 1.90G 4% ONLINE -
bash-3.00# df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c1d0s0 20G 10G 9.1G 54% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.1G 736K 3.1G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
/usr/lib/libc/libc_hwcap2.so.1
20G 10G 9.1G 54% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 3.1G 48K 3.1G 1% /tmp
swap 3.1G 32K 3.1G 1% /var/run
testpool 2.0G 25K 1.9G 1% /testpool
testpool/homedir 2.0G 100M 1.9G 5% /testpool/homedir
doubleparityraid5pool 4.9G 24K 4.9G 1% /doubleparityraid5pool



DRY RUN OF STORAGE POOL CREATION:

bash-3.00# zpool create -n testmirrorpool mirror c2d0s3 c2d0s4
would create 'testmirrorpool' with the following layout:

testmirrorpool
mirror
c2d0s3
c2d0s4
bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 2G 100M 1.90G 4% ONLINE -
bash-3.00# df
/ (/dev/dsk/c1d0s0 ):19485132 blocks 2318425 files
/devices (/devices ): 0 blocks 0 files
/system/contract (ctfs ): 0 blocks 2147483612 files
/proc (proc ): 0 blocks 16285 files
/etc/mnttab (mnttab ): 0 blocks 0 files
/etc/svc/volatile (swap ): 6598720 blocks 293280 files
/system/object (objfs ): 0 blocks 2147483444 files
/lib/libc.so.1 (/usr/lib/libc/libc_hwcap2.so.1):19485132 blocks 2318425 files
/dev/fd (fd ): 0 blocks 0 files
/tmp (swap ): 6598720 blocks 293280 files
/var/run (swap ): 6598720 blocks 293280 files
/testpool (testpool ): 3923694 blocks 3923694 files
/testpool/homedir (testpool/homedir ): 3923694 blocks 3923694 files

Note: Here the –n option is used not to create a zpool but just to check if it is possible to create it or not. If it is possible, it’ll give the above output, else it’ll give the error which is expected to occur when creating the zpool.

LISTING THE POOLS AND ZFS:

bash-3.00# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testmirrorpool 4.97G 52.5K 4.97G 0% ONLINE -
testpool 2G 100M 1.90G 4% ONLINE -

bash-3.00# zpool list -o name,size,health
NAME SIZE HEALTH
testmirrorpool 4.97G ONLINE
testpool 2G ONLINE

bash-3.00# zpool status -x
all pools are healthy

bash-3.00# zpool status -x testmirrorpool
pool 'testmirrorpool' is healthy

bash-3.00# zpool status -v
pool: testmirrorpool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
testmirrorpool ONLINE 0 0 0
mirror ONLINE 0 0 0
c2d0s3 ONLINE 0 0 0
c2d0s4 ONLINE 0 0 0

errors: No known data errors

pool: testpool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
c2d0s7 ONLINE 0 0 0

errors: No known data errors


bash-3.00# zpool status -v testmirrorpool
pool: testmirrorpool
state: ONLINE
scrub: none requested
config:


NAME STATE READ WRITE CKSUM
testmirrorpool ONLINE 0 0 0
mirror ONLINE 0 0 0
c2d0s3 ONLINE 0 0 0
c2d0s4 ONLINE 0 0 0

errors: No known data errors


bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 100M 1.87G 25.5K /testpool
testpool/homedir 100M 1.87G 100M /testpool/homedir

bash-3.00# zfs list -H
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 114K 1.97G 26.5K /testpool
testpool/homedir_old 24.5K 1.97G 24.5K /testpool/homedir_old

bash-3.00# zfs list -o name,sharenfs,mountpoint
NAME SHARENFS MOUNTPOINT
testmirrorpool off /testmirrorpool
testpool off /testpool
testpool/homedir_old off /testpool/homedir_old

bash-3.00# zfs create testpool/homedir_old/nesteddir
bash-3.00# zfs list testpool/homedir_old
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old 52K 1.97G 27.5K /testpool/homedir_old
bash-3.00# zfs list -r testpool/homedir_old
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old 52K 1.97G 27.5K /testpool/homedir_old
testpool/homedir_old/nesteddir 24.5K 1.97G 24.5K /testpool/homedir_old/nesteddir

bash-3.00# zfs get -r compression testpool
NAME PROPERTY VALUE SOURCE
testpool compression off default
testpool/homedir compression off default
testpool/homedir/nesteddir compression off default
bash-3.00# zfs set compression=on testpool/homedir/nesteddir
bash-3.00# zfs get -r compression testpool
NAME PROPERTY VALUE SOURCE
testpool compression off default
testpool/homedir compression off default
testpool/homedir/nesteddir compression on local

bash-3.00# zfs inherit compression testpool/homedir/nesteddir
bash-3.00# zfs get -r compression testpool
NAME PROPERTY VALUE SOURCE
testpool compression off default
testpool/homedir compression off default
testpool/homedir/nesteddir compression off default
REFER MOUNTPOINT
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 114K 1.97G 26.5K /testpool
testpool/homedir_old 24.5K 1.97G 24.5K /testpool/homedir_old

bash-3.00# zfs list -t filesystem -o name,used
NAME USED
testmirrorpool 75.5K
testpool 114K
testpool/homedir_old 24.5K


DESTROYING A ZFS:

bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 100M 1.87G 25.5K /testpool
testpool/homedir 100M 1.87G 100M /testpool/homedir

bash-3.00# ls -l testpool/homedir/
total 4
drwxr-xr-x 2 root root 2 Nov 13 11:36 newdir
-rw-r--r-- 1 root root 0 Nov 13 11:36 newfile

bash-3.00# pwd
/testpool/homedir/newdir

bash-3.00# zfs destroy testpool/homedir
cannot unmount '/testpool/homedir': Device busy

bash-3.00# zfs destroy -f testpool/homedir

bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 82K 1.97G 24.5K /testpool


bash-3.00# zfs create testpool/homedir/nesteddir
bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 144K 1.97G 26.5K /testpool
testpool/homedir 49K 1.97G 24.5K /testpool/homedir
testpool/homedir/nesteddir 24.5K 1.97G 24.5K /testpool/homedir/nesteddir

bash-3.00# zfs destroy testpool/homedir
cannot destroy 'testpool/homedir': filesystem has children
use '-r' to destroy the following datasets:
testpool/homedir/nesteddir
bash-3.00# zfs destroy -r testpool/homedir


RENAMING ZFS:

bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 114K 1.97G 26.5K /testpool
testpool/homedir 24.5K 1.97G 24.5K /testpool/homedir

bash-3.00# zfs rename testpool/homedir testpool/homedir_old
bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 114K 1.97G 26.5K /testpool
testpool/homedir_old 24.5K 1.97G 24.5K /testpool/homedir_old
bash-3.00# df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c1d0s0 20G 11G 8.6G 56% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.1G 736K 3.1G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
/usr/lib/libc/libc_hwcap2.so.1
20G 11G 8.6G 56% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 3.1G 48K 3.1G 1% /tmp
swap 3.1G 32K 3.1G 1% /var/run
testpool 2.0G 26K 2.0G 1% /testpool
testmirrorpool 4.9G 24K 4.9G 1% /testmirrorpool
testpool/homedir_old 2.0G 24K 2.0G 1% /testpool/homedir_old


bash-3.00# zfs create testpool/homedir_old/nesteddir
bash-3.00# zfs list testpool/homedir_old
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old 52K 1.97G 27.5K /testpool/homedir_old
bash-3.00# zfs list -r testpool/homedir_old
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old 52K 1.97G 27.5K /testpool/homedir_old
testpool/homedir_old/nesteddir 24.5K 1.97G 24.5K /testpool/homedir_old/nesteddir


MOUNTING AND UNMOUNTING ZFS FILESYSTEMS:

bash-3.00# zfs get mountpoint testpool/homedir
NAME PROPERTY VALUE SOURCE
testpool/homedir mountpoint /testpool/homedir default

bash-3.00# zfs get mounted testpool/homedir
NAME PROPERTY VALUE SOURCE
testpool/homedir mounted yes -

bash-3.00# zfs set mountpoint=/mnt/altloc testpool/homedir

bash-3.00# zfs get mountpoint testpool/homedir
NAME PROPERTY VALUE SOURCE
testpool/homedir mountpoint /mnt/altloc local

LEGACY MOUNT POINTS:

Legacy filesystems must be managed through mount and umount commands and the /etc/vfstab file. Unlike normal zfs filesystems, zfs doesn't automatically mount legacy filesystems on boot.

bash-3.00# zfs set mountpoint=legacy testpool/additionaldir

bash-3.00# mount -F zfs testpool/additionaldir /mnt/legacy

bash-3.00# df -h
Filesystem size used avail capacity Mounted on
/dev/dsk/c1d0s0 20G 11G 8.6G 56% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 3.3G 732K 3.3G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
/usr/lib/libc/libc_hwcap2.so.1
20G 11G 8.6G 56% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 3.3G 48K 3.3G 1% /tmp
swap 3.3G 32K 3.3G 1% /var/run
testpool 4.9G 24K 4.9G 1% /testpool
testpool/homedir 500M 25K 500M 1% /mnt/altloc
testpool/homedir/nesteddir
500M 24K 500M 1% /mnt/altloc/nesteddir
testpool/additionaldir
4.9G 24K 4.9G 1% /mnt/legacy


MOUNTING ZFS FILESYSTEMS:

bash-3.00# umountall

bash-3.00# zfs mount

bash-3.00# zfs mount -a

bash-3.00# zfs mount
testpool/homedir /mnt/altloc
testpool/homedir/nesteddir /mnt/altloc/nesteddir
testpool /testpool

Note:
1. zfs mount -a command doesn't mount legacy filesystems.
2. To force a mount on top of a non-empty directory, use the option -O
3. To specify the options like ro, rw use the option -o

UNMOUNTING ZFS FILESYSTEMS:

bash-3.00# zfs mount
testpool /testpool
testpool/homedir /testpool/homedir
testpool/homedir/nesteddir /testpool/homedir/nesteddir

bash-3.00# zfs unmount /testpool/homedir

bash-3.00# zfs mount
testpool /testpool

bash-3.00# zfs mount -a

bash-3.00# zfs umount /testpool/homedir

bash-3.00# zfs mount
testpool /testpool

bash-3.00# pwd
/testpool/homedir

bash-3.00# zfs unmount /testpool/homedir
cannot unmount '/testpool/homedir': Device busy

bash-3.00# zfs unmount -f /testpool/homedir

bash-3.00# zfs mount
testpool /testpool

Note: The sub command works both the ways - unmount,umount. This is to provide backwards compatibility.



ZFS WEB-BASED MANAGEMENT:

bash-3.00# /usr/sbin/smcwebserver start
Starting Sun Java(TM) Web Console Version 3.0.2 ...
The console is running

bash-3.00# /usr/sbin/smcwebserver enable

The enable sub command enables the server to run automatically when the system boots.


ZFS SNAPSHOTS:

bash-3.00# zfs list -r
NAME USED AVAIL REFER MOUNTPOINT
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 146K 1.97G 26.5K /testpool
testpool/homedir_old 52K 1.97G 27.5K /testpool/homedir_old
testpool/homedir_old/nesteddir 24.5K 1.97G 24.5K /testpool/homedir_old/nesteddir

bash-3.00# zfs snapshot testpool/homedir_old@snap1

bash-3.00# zfs list -t snapshot
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old@snap1 0 - 27.5K -

bash-3.00# zfs snapshot -r testpool/homedir_old@snap2

bash-3.00# zfs list -t snapshot
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old@snap1 0 - 27.5K -
testpool/homedir_old@snap2 0 - 27.5K -
testpool/homedir_old/nesteddir@snap2 0 - 24.5K -



bash-3.00# zfs get all testpool/homedir_old@snap1
NAME PROPERTY VALUE SOURCE
testpool/homedir_old@snap1 type snapshot -
testpool/homedir_old@snap1 creation Fri Nov 13 16:26 2009 -
testpool/homedir_old@snap1 used 0 -
testpool/homedir_old@snap1 referenced 27.5K -
testpool/homedir_old@snap1 compressratio 1.00x -


PROPERTIES OF SNAPSHOTS:

bash-3.00# zfs get all testpool/homedir_old@snap1
NAME PROPERTY VALUE SOURCE
testpool/homedir_old@snap1 type snapshot -
testpool/homedir_old@snap1 creation Fri Nov 13 16:26 2009 -
testpool/homedir_old@snap1 used 0 -
testpool/homedir_old@snap1 referenced 27.5K -
testpool/homedir_old@snap1 compressratio 1.00x -
bash-3.00#
bash-3.00# zfs set compressratio=2.00x testpool/homedir_old@snap1
cannot set compressratio property: read only property
bash-3.00# zfs set compression=on testpool/homedir_old@snap1
cannot set compression property for 'testpool/homedir_old@snap1': snapshot properties cannot be modified



RENAMING ZFS SNAPSHOTS:

bash-3.00# zfs rename testpool/homedir_old@snap1 additionalpool/homedir@snap3
cannot rename to 'additionalpool/homedir@snap3': snapshots must be part of same dataset

bash-3.00# zfs rename testpool/homedir_old@snap1 testpool/homedir_old@snap3

bash-3.00# zfs list -t snapshot
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old@snap3 0 - 27.5K -
testpool/homedir_old@snap2 0 - 27.5K -
testpool/homedir_old/nesteddir@snap2 0 - 24.5K -


DISPLAYING AND ACCESSING ZFS SNAPSHOTS:

bash-3.00# ls /testpool/homedir_old/.zfs/snapshot
snap2 snap3

bash-3.00# zfs list -r -t snapshot -o name,creation testpool/homedir_old
NAME CREATION
testpool/homedir_old@snap3 Fri Nov 13 16:26 2009
testpool/homedir_old@snap2 Fri Nov 13 16:31 2009
testpool/homedir_old/nesteddir@snap2 Fri Nov 13 16:31 2009

ROLLING BACK TO A ZFS SNAPSHOT:

bash-3.00# zfs rollback testpool/homedir_old@snap3
cannot rollback to 'testpool/homedir_old@snap3': more recent snapshots exist
use '-r' to force deletion of the following snapshots:
testpool/homedir_old@snap2

bash-3.00# zfs rollback -r testpool/homedir_old@snap3

DESTROYING A ZFS SNAPSHOT:

bash-3.00# zfs destroy testpool/homedir_old@snap3
cannot destroy 'testpool/homedir_old@snap3': snapshot has dependent clones
use '-R' to destroy the following datasets:
testpool/additionaldir/testclone

bash-3.00# zfs destroy -R testpool/homedir_old@snap3


CREATING ZFS CLONES:

bash-3.00# zfs clone testpool/homedir_old@snap3 testpool/additionaldir/testclone

bash-3.00# zfs list
NAME USED AVAIL REFER MOUNTPOINT
additionalpool 104K 4.89G 25.5K /additionalpool
additionalpool/homedir 24.5K 4.89G 24.5K /additionalpool/homedir
testmirrorpool 75.5K 4.89G 24.5K /testmirrorpool
testpool 185K 1.97G 27.5K /testpool
testpool/additionaldir 25.5K 1.97G 25.5K /testpool/additionaldir
testpool/additionaldir/testclone 0 1.97G 27.5K /testpool/additionaldir/testclone
testpool/homedir_old 52K 1.97G 27.5K /testpool/homedir_old
testpool/homedir_old@snap3 0 - 27.5K -
testpool/homedir_old/nesteddir 24.5K 1.97G 24.5K /testpool/homedir_old/nesteddir
testpool/homedir_old/nesteddir@snap2 0 - 24.5K -

SETTING CLONE PROPERTIES:

bash-3.00# zfs get all testpool/additionaldir/testclone
NAME PROPERTY VALUE SOURCE
testpool/additionaldir/testclone type filesystem -
testpool/additionaldir/testclone creation Fri Nov 13 16:51 2009 -
testpool/additionaldir/testclone used 22.5K -
testpool/additionaldir/testclone available 1.97G -
testpool/additionaldir/testclone referenced 27.5K -
testpool/additionaldir/testclone compressratio 1.00x -
testpool/additionaldir/testclone mounted yes -
testpool/additionaldir/testclone origin testpool/homedir_old@snap3 -
testpool/additionaldir/testclone quota none default
testpool/additionaldir/testclone reservation none default
testpool/additionaldir/testclone recordsize 128K default
testpool/additionaldir/testclone mountpoint /testpool/additionaldir/testclone default
testpool/additionaldir/testclone sharenfs off local
testpool/additionaldir/testclone checksum on default
testpool/additionaldir/testclone compression off default
testpool/additionaldir/testclone atime on default
testpool/additionaldir/testclone devices on default
testpool/additionaldir/testclone exec on default
testpool/additionaldir/testclone setuid on default
testpool/additionaldir/testclone readonly off default
testpool/additionaldir/testclone zoned off default
testpool/additionaldir/testclone snapdir hidden default
testpool/additionaldir/testclone aclmode groupmask default
testpool/additionaldir/testclone aclinherit secure default

bash-3.00# zfs set sharenfs=on testpool/additionaldir/testclone

bash-3.00# zfs set quota=500m testpool/additionaldir/testclone

bash-3.00# zfs get sharenfs,quota testpool/additionaldir/testclone
NAME PROPERTY VALUE SOURCE
testpool/additionaldir/testclone sharenfs on local
testpool/additionaldir/testclone quota 500M local


REPLACING A ZFS FILESYSTEM WITH A ZFS CLONE:

bash-3.00# zfs list -r testpool/homedir_old
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old 74.5K 1.97G 27.5K /testpool/homedir_old
testpool/homedir_old@snap3 22.5K - 27.5K -
testpool/homedir_old/nesteddir 24.5K 1.97G 24.5K /testpool/homedir_old/nesteddir
testpool/homedir_old/nesteddir@snap2 0 - 24.5K -


bash-3.00# zfs list -r testpool/additionaldir
NAME USED AVAIL REFER MOUNTPOINT
testpool/additionaldir 48K 1.97G 25.5K /testpool/additionaldir
testpool/additionaldir/testclone 22.5K 500M 27.5K /testpool/additionaldir/testclone

bash-3.00# zfs promote testpool/additionaldir/testclone

bash-3.00# zfs list -r testpool/homedir_old
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old 47K 1.97G 27.5K /testpool/homedir_old
testpool/homedir_old/nesteddir 24.5K 1.97G 24.5K /testpool/homedir_old/nesteddir
testpool/homedir_old/nesteddir@snap2 0 - 24.5K -

bash-3.00# zfs list -r testpool/additionaldir
NAME USED AVAIL REFER MOUNTPOINT
testpool/additionaldir 75.5K 1.97G 25.5K /testpool/additionaldir
testpool/additionaldir/testclone 50K 500M 27.5K /testpool/additionaldir/testclone
testpool/additionaldir/testclone@snap3 22.5K - 27.5K -

bash-3.00# zfs list -r testpool/homedir_old
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old 50K 500M 27.5K /testpool/homedir_old
testpool/homedir_old@snap3 22.5K - 27.5K -

bash-3.00# zfs list -r testpool/additionaldir
NAME USED AVAIL REFER MOUNTPOINT
testpool/additionaldir 24.5K 1.97G 24.5K /testpool/additionaldir

bash-3.00# zfs list -r testpool/homedir_old_old
NAME USED AVAIL REFER MOUNTPOINT
testpool/homedir_old_old 47K 1.97G 27.5K /testpool/homedir_old_old
testpool/homedir_old_old/nesteddir 24.5K 1.97G 24.5K /testpool/homedir_old_old/nesteddir
testpool/homedir_old_old/nesteddir@snap2 0 - 24.5K -

DESTROYING ZFS CLONE:

bash-3.00# zfs destroy /testpool/homedir_old@snap3

No comments:

Post a Comment