列出当前所有所有的 Pool
$ zpool list
NAME SIZE ALLOC FREE CKPOINT EXPANDSZ FRAG CAP DEDUP HEALTH ALTROOT
SWPool 16.4T 2.35T 14.0T - - 0% 14% 1.00x ONLINE /mnt
SWPoolSSD 1.86T 142G 1.72T - - 0% 7% 1.00x ONLINE /mnt
boot-pool 103G 1.18G 102G - - 0% 1% 1.00x ONLINE -
查看 Pool 的读写状态
# 每一秒更新一次所有 Pool 的读写状态
$ zpool iostat -n 1
capacity operations bandwidth
pool alloc free read write read write
---------- ----- ----- ----- ----- ----- -----
SWPool 2.35T 14.0T 11 19 4.59M 296K
SWPoolSSD 142G 1.72T 6 13 722K 175K
boot-pool 1.18G 102G 0 1 2.64K 204K
---------- ----- ----- ----- ----- ----- -----
# 每一秒更新一次指定 Pool 的读写状态
$ zpool iostat SWPoolSSD -n 1
capacity operations bandwidth
pool alloc free read write read write
---------- ----- ----- ----- ----- ----- -----
SWPoolSSD 142G 1.72T 6 13 738K 176K
SWPoolSSD 142G 1.72T 0 0 0 0
查看特定 Pool 健康状态
You can quickly review pool health status by using the zpool status command as follows:
$ zpool status -x
all pools are healthy
$ zpool status -v <pool name>
pool: tank
state: DEGRADED
status: One or more devices could not be opened. Sufficient replicas exist for
the pool to continue functioning in a degraded state.
action: Attach the missing device and online it using 'zpool online'.
see: http://www.sun.com/msg/ZFS-8000-2Q
scrub: scrub completed after 0h0m with 0 errors on Wed Jan 20 15:13:59 2010
config:
NAME STATE READ WRITE CKSUM
tank DEGRADED 0 0 0
mirror-0 DEGRADED 0 0 0
c1t0d0 ONLINE 0 0 0
c1t1d0 UNAVAIL 0 0 0 cannot open
errors: No known data errors
CRUD
Deleting a ZPool
Deleting a zpool and deleting all data within the zpool:
zpool destroy nameofzpool
Removing a Zpool
If you have a zpool on eg a usb drive, this command will allow you to safely remove it:
zpool export nameofzpool
If you want to import the zpool again:
zpool import nameofzpool
Running zpool import with no arguments will list all available zpools.
Creating a Zpool on a disk image
Though not recommended for normal use, it is possible to create a zpool on top of a file.
dd if=/dev/zero of=filename.img bs=1M count=1000
zpool create nameofzpool /absolute/path/to/filename.img
will create an image of 1GB. It is also possible to create a sparse image, to create an image that can hold 100GB:
dd if=/dev/zero of=filename.img bs=1k count=1 seek=100M
ZVol
Resize
$ zfs set volsize=new_size tank/name_of_the_zvol
Verify
$ zfs get volsize SSDPool2/VM/Ubuntu2
NAME PROPERTY VALUE SOURCE
SSDPool2/VM/Ubuntu2 volsize 200G local
$ zfs list SSDPool2/VM/Ubuntu2
NAME USED AVAIL REFER MOUNTPOINT
SSDPool2/VM/Ubuntu2 18.3G 774G 9.94G -
Reference
- https://www.truenas.com/community/threads/benchmarking-zfs.7928/
- https://docs.oracle.com/cd/E19253-01/819-5461/gammt/index.html
- https://docs.oracle.com/cd/E88353_01/html/E72487/zpool-8.html
- https://docs.oracle.com/cd/E19253-01/819-5461/gamno/index.html
- https://www.freebsd.org/cgi/man.cgi?zpool(8)
- https://wiki.ubuntu.com/ZFS/ZPool
- https://www.truenas.com/community/threads/resizing-zvol.47574/
- https://github.com/churchers/vm-bhyve/issues/250https://sites.google.com/site/ryanbabchishin/home/publications/changing-a-zvol-block-size-while-making-it-sparse-and-compressed