Common ZFS commands

Source: Internet
Author: User

Create a pool and ZFS File System:

. Create a file system and mount it to/export/home.
# ZFS create tank/home
# ZFS set mountpoint =/export/home tank/home
. Create a directory for multiple users
Note: It is automatically mounted under/export/home/{Ahrens, bonwick, billm} due to inheritance.
# ZFS create tank/home/Ahrens
# ZFS create tank/home/bonwick
# ZFS create tank/home/billm
. Add more space to the pool
# Zpool add tank mirror c2t0d0 c3t0d0
. Create a storage pool named "tank" (type: "", mirror, raidz, raidz2)

# Zpool create tank <type> c0t0d0 c1t0d0 c1t1d0

. Modify the file system name

# ZFS rename tank/home/Ahrens tank/home/nahrens
. Delete a File System
# ZFS destroy-RF tank/fs

. Modify the name of the storage pool
# Zpool export Tank
# Zpool import tank newpool

2. Set attributes

Automatically share the file system in NFS Mode
# ZFS set sharenfs = RW tank/home
Enable compression for all data in the file system
# Zfs set compression = on Tank
Limit user a's maximum space to 10 GB
# ZFS set quota = 10G tank/home/usera
Ensure that user B has 20 GB of reserved space
# ZFS set reservation = 20G tank/home/userb

You can use commands to query all attributes of a file system.
# ZFS get all tank/home
You can use commands to query all attributes of a storage pool.
# Zpool get all tank
Most attributes can be automatically set through inheritance
# ZFS inherit <property> tank/home/eschrock
3. ZFS Snapshot
Read-only copy of the file system
Instant creation, unlimited quantity, no extra space occupied-blocks are copied only when changes occur
Access through. ZFS/snapshot in the root directory of each FILE SYSTEM
Allows users to restore files without the intervention of the system administrator.
Perform snapshot capture on the starting directory of user
# ZFS snapshot tank/home/usera @ Tuesday
Roll back to the previous Snapshot
# ZFS rollback tank/home/usera @ Monday
View Foo. C on Wednesday
$ CAT/tank/home/usera/. ZFS/Snapshot/Wednesday/Foo. c
Delete a snapshot
# ZFS destroy-r tank/home/usera @ Monday

3. ZFS clone
Writable snapshot copy
Instant creation, unlimited quantity
An ideal method for storing a large portion of the shared data as a large number of dedicated replicas
Software Installation
Work Zone
Diskless Client

Create opensolaris source code clone
# ZFS Clone tank/Solaris @ Monday tank/WS/Lori/fix

4. ZFS send/receive
Based on Snapshot points
Full backup: Any Snapshot
Incremental Backup: Any snapshot increments
Fast-overhead is proportional to changed data
Highly Efficient and supports remote replication.
Generate full backup
# ZFS send tank/fs @ A>/backup/
Generate Incremental Backup
# ZFS send-I tank/fs @ A tank/fs @ B>/backup/B-A
Remote replication: Send an increment every minute
# ZFS send-I tank/fs @ 11:31 tank/fs @ 11:32 |
SSH host ZFS receive-D/tank/fs

5. ZFS data migration

Disk format independent from the host
You can also change the server from x86
Adaptive endianness: no additional cost is required on both platforms.
Write always uses native endianness to set a bit in the block pointer.
Only when the host's byte storage Order (endianness )! = Bytes are exchanged for reading only when the block bytes are stored in order.
Zfs is responsible for all processing
No need to consider the device path, configuration file,/etc/vfstab, etc.
Zfs will share/unshare, Mount/unmount, and so on when necessary

Export the pool from the old Server
Old # zpool export Tank
Physically move the disk and import the pool to the new server
New # zpool import Tank

6. device management
Add/Replace new devices (type: "", mirror, raidz, raidz2)
# Zpool add tank <type> c0t2d0 c0t3d0 c0t4d0
# Zpool Replace tank c0t1d0 c0t2d0
Add/Remove Image devices
# Zpool attach tank c0t1d0 c0t2d0
# Zpool detach tank c0t2d0
Stop the device or start it manually
# Zpool offline tank c0t2d0
# Zpool online tank c0t2d0
View the current status and I/O status of the storage pool
# Zpool status-V Tank
# Zpool iostat tank 1
Add a hot standby Device
# Zpool add tank spare c0t2d0
Specify hot backup to start/stop Hot Backup
# Zpool Replace tank c0t1d0 c0t2d0
# Zpool detach tank c0t2d0
Delete Hot Standby Device
# Zpool remove tank c0t2d0
Add/delete independent log devices (Performance Improvement)
# Zpool add tank log c0t3d0
# Zpool remove tank c0t3d0

7. ZFS permission management
You can assign the management permissions of ZFS (1 m) to common users.
'Zfs allow'
'Zfs unallow'
Grant permissions to a common user
# ZFS allow marks create, snapshot tank/marks
Reclaim the specified permission
# ZFS unallow marks create, snapshot tank/marks
View the current permissions of the file system
# ZFS allow tank/marks

8. Other commands
Show all operation history of the storage pool

# Zpool history Tank
Upgrade the storage pool to the specified spa version.
# Zpool upgrade-v <version> Tank
Upgrade the file system to the specified zpl version.
# ZFS upgrade-v <version> tank/fs
Manually Mount/detach a File System
# ZFS Mount-
# ZFS unmount tank/fs
# ZFS unmount-

The above content is taken from presentation, an engineer and recorded here for quick query.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.