From owner-freebsd-doc@FreeBSD.ORG Thu Feb 20 07:07:31 2014 Return-Path: Delivered-To: freebsd-doc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4C1B3C4D for ; Thu, 20 Feb 2014 07:07:31 +0000 (UTC) Received: from mx1.scaleengine.net (beauharnois2.bhs1.scaleengine.net [142.4.218.15]) by mx1.freebsd.org (Postfix) with ESMTP id 20D921A6B for ; Thu, 20 Feb 2014 07:07:29 +0000 (UTC) Received: from [10.1.1.1] (S01060001abad1dea.hm.shawcable.net [50.70.146.73]) (Authenticated sender: allan.jude@scaleengine.com) by mx1.scaleengine.net (Postfix) with ESMTPSA id 022945DC21 for ; Thu, 20 Feb 2014 07:07:20 +0000 (UTC) Message-ID: <5305A9A4.1010603@allanjude.com> Date: Thu, 20 Feb 2014 02:07:16 -0500 From: Allan Jude User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: freebsd-doc@FreeBSD.org Subject: ZFS handbook project patch X-Enigmail-Version: 1.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="jXBqfIoI7A7s1SsEHTcJEC2its8v0F2Mg" X-BeenThere: freebsd-doc@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Documentation project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Feb 2014 07:07:31 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --jXBqfIoI7A7s1SsEHTcJEC2its8v0F2Mg Content-Type: multipart/mixed; boundary="------------090505060909090403030007" This is a multi-part message in MIME format. --------------090505060909090403030007 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Attached is another patch to the project branch for the ZFS section of the handbook adds the missing documentation on the 'zpool status', 'zpool scrub' and 'zpool clear' commands, and fills in the compression section (both the zfs set compression part, and the beefed up section of the terminology page). It also adds a 'zpool status' example to the 'zpool upgrade' section, so users know what a pool that needs to be upgraded will look like, and adds a reminder to make sure they update the bootcode (one of the popular problems people seem to run into, despite the fact the 'zpool upgrade' reminds you. It also fixes a paragraph that someone else wrote, that Warren had pointed out made no sense. Also adds some missing tags, and replace all of the tags that are actually commands with Feedback welcome --=20 Allan Jude --------------090505060909090403030007 Content-Type: text/plain; charset=windows-1252; name="zfs.compression.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="zfs.compression.diff" Index: zfsupdate-201307/en_US.ISO8859-1/books/handbook/zfs/chapter.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- zfsupdate-201307/en_US.ISO8859-1/books/handbook/zfs/chapter.xml (revi= sion 44001) +++ zfsupdate-201307/en_US.ISO8859-1/books/handbook/zfs/chapter.xml (work= ing copy) @@ -134,7 +134,7 @@ =20 Then start the service: =20 - &prompt.root; service zfs start + &prompt.root; service zfs start =20 The examples in this section assume three SCSI disks with the device names @@ -152,12 +152,12 @@ pool using a single disk device, use zpool: =20 - &prompt.root; zpool create example= /dev/da0 + &prompt.root; zpool create example /dev/da0 =20 To view the new pool, review the output of df: =20 - &prompt.root; df + &prompt.root; df Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s1a 2026030 235230 1628718 13% / devfs 1 1 0 100% /dev @@ -169,10 +169,10 @@ accessible as a file system. Files may be created on it and users can browse it, as seen in the following example: =20 - &prompt.root; cd /example -&prompt.root; ls -&prompt.root; touch testfile -&prompt.root; ls -al + &prompt.root; cd /example +&prompt.root; ls +&prompt.root; touch testfile +&prompt.root; ls -al total 4 drwxr-xr-x 2 root wheel 3 Aug 29 23:15 . drwxr-xr-x 21 root wheel 512 Aug 29 23:12 .. @@ -182,8 +182,8 @@ ZFS features. To create a dataset on this pool with compression enabled: =20 - &prompt.root; zfs create example/compressed -&prompt.root; zfs set compression=3Dgzip example/compressed + &prompt.root; zfs create example/compressed +&prompt.root; zfs set compression=3Dgzip example/compressed =20 The example/compressed dataset is now a ZFS compressed file system. Try copying @@ -192,14 +192,14 @@ =20 Compression can be disabled with: =20 - &prompt.root; zfs set compression=3Doff example= /compressed + &prompt.root; zfs set compression=3Doff example/c= ompressed =20 To unmount a file system, use zfs umount and then verify by using df: =20 - &prompt.root; zfs umount example/compressed -&prompt.root; df + &prompt.root; zfs umount example/compressed +&prompt.root; df Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s1a 2026030 235232 1628716 13% / devfs 1 1 0 100% /dev @@ -210,8 +210,8 @@ use zfs mount and verify with df: =20 - &prompt.root; zfs mount example/compressed -&prompt.root; df + &prompt.root; zfs mount example/compressed +&prompt.root; df Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s1a 2026030 235234 1628714 13% / devfs 1 1 0 100% /dev @@ -222,7 +222,7 @@ The pool and file system may also be observed by viewing the output from mount: =20 - &prompt.root; mount + &prompt.root; mount /dev/ad0s1a on / (ufs, local) devfs on /dev (devfs, local) /dev/ad0s1d on /usr (ufs, local, soft-updates) @@ -237,13 +237,13 @@ is created. Important files will be stored here, the file system is set to keep two copies of each data block: =20 - &prompt.root; zfs create example/data -&prompt.root; zfs set copies=3D2 example/data + &prompt.root; zfs create example/data +&prompt.root; zfs set copies=3D2 example/data =20 It is now possible to see the data and space utilization by issuing df: =20 - &prompt.root; df + &prompt.root; df Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s1a 2026030 235234 1628714 13% / devfs 1 1 0 100% /dev @@ -264,9 +264,9 @@ To destroy the file systems and then destroy the pool as they are no longer needed: =20 - &prompt.root; zfs destroy example/compressed -&prompt.root; zfs destroy example/data -&prompt.root; zpool destroy example + &prompt.root; zfs destroy example/compressed +&prompt.root; zfs destroy example/data +&prompt.root; zpool destroy example =20 @@ -283,7 +283,7 @@ command, specifying the disks to add to the pool: =20 - &prompt.root; zpool create storage raidz da0 da= 1 da2 + &prompt.root; zpool create storage raidz da0 da1 = da2 =20 &sun; recommends that the number of devices used in a @@ -301,22 +301,22 @@ command makes a new file system in the pool called home: =20 - &prompt.root; zfs create storage/home + &prompt.root; zfs create storage/home =20 Now compression and keeping extra copies of directories and files can be enabled with these commands: =20 - &prompt.root; zfs set copies=3D2 storage/home -&prompt.root; zfs set compression=3Dgzip storage/home + &prompt.root; zfs set copies=3D2 storage/home +&prompt.root; zfs set compression=3Dgzip storage/home= =20 To make this the new home directory for users, copy the user data to this directory, and create the appropriate symbolic links: =20 - &prompt.root; cp -rp /home/* /storage/home -&prompt.root; rm -rf /home /usr/home -&prompt.root; ln -s /storage/home /home -&prompt.root; ln -s /storage/home /usr/home + &prompt.root; cp -rp /home/* /storage/home +&prompt.root; rm -rf /home /usr/home +&prompt.root; ln -s /storage/home /home +&prompt.root; ln -s /storage/home /usr/home =20 Users now have their data stored on the freshly created /storage/home. @@ -325,7 +325,7 @@ Try creating a snapshot which can be rolled back later: =20 - &prompt.root; zfs snapshot storage/home@08-30-0= 8 + &prompt.root; zfs snapshot storage/home@08-30-08<= /command> =20 Note that the snapshot option will only capture a real file system, not a home directory or a file. The @@ -333,7 +333,7 @@ file system name or the volume name. When a user's home directory is accidentally deleted, restore it with: =20 - &prompt.root; zfs rollback storage/home@08-30-0= 8 + &prompt.root; zfs rollback storage/home@08-30-08<= /command> =20 To list all available snapshots, run ls in the file system's @@ -341,7 +341,7 @@ directory. For example, to see the previously taken snapshot: =20 - &prompt.root; ls /storage/home/.zfs/snapshot + &prompt.root; ls /storage/home/.zfs/snapshot =20 It is possible to write a script to perform regular snapshots on user data. However, over time, snapshots can @@ -348,7 +348,7 @@ consume a great deal of disk space. The previous snapshot can be removed using the following command: =20 - &prompt.root; zfs destroy storage/home@08-30-08= + &prompt.root; zfs destroy storage/home@08-30-08 =20 After testing, /storage/home can be @@ -355,19 +355,19 @@ made the real /home using this command: =20 - &prompt.root; zfs set mountpoint=3D/home storag= e/home + &prompt.root; zfs set mountpoint=3D/home storage/= home =20 Run df and mount to confirm that the system now treats the file system as the real /home: =20 - &prompt.root; mount + &prompt.root; mount /dev/ad0s1a on / (ufs, local) devfs on /dev (devfs, local) /dev/ad0s1d on /usr (ufs, local, soft-updates) storage on /storage (zfs, local) storage/home on /home (zfs, local) -&prompt.root; df +&prompt.root; df Filesystem 1K-blocks Used Avail Capacity Mounted on /dev/ad0s1a 2026030 235240 1628708 13% / devfs 1 1 0 100% /dev @@ -380,7 +380,7 @@ created can be generated as part of the nightly &man.periodic.8; runs: =20 - &prompt.root; echo 'daily_status_zfs_enable=3D"= YES"' >> /etc/periodic.conf + &prompt.root; echo 'daily_status_zfs_enable=3D"YE= S"' >> /etc/periodic.conf =20 @@ -391,7 +391,7 @@ RAID-Z devices may be viewed with this command: =20 - &prompt.root; zpool status -x + &prompt.root; zpool status -x =20 If all pools are Online and everything @@ -425,19 +425,19 @@ This indicates that the device was previously taken offline by the administrator with this command: =20 - &prompt.root; zpool offline storage da1 + &prompt.root; zpool offline storage da1= =20 Now the system can be powered down to replace da1. When the system is back online, the failed disk can replaced in the pool: =20 - &prompt.root; zpool replace storage da1 + &prompt.root; zpool replace storage da1= =20 From here, the status may be checked again, this time without so that all pools are shown: =20 - &prompt.root; zpool status storage + &prompt.root; zpool status storage pool: storage state: ONLINE scrub: resilver completed with 0 errors on Sat Aug 30 19:44:11 2008 @@ -463,7 +463,7 @@ upon creation of file systems and may be disabled using the following command: =20 - &prompt.root; zfs set checksum=3Doff storage/ho= me + &prompt.root; zfs set checksum=3Doff storage/home= =20 Doing so is not recommended! @@ -478,16 +478,16 @@ scrubbing. Verify the data integrity of the storage pool, with this command: =20 - &prompt.root; zpool scrub storage + &prompt.root; zpool scrub storage =20 The duration of a scrub depends on the amount of data stored. Large amounts of data can take a considerable amount of time to verify. It is also very I/O - intensive, so much so that only one scrub> may be run at any + intensive, so much so that only one scrub may be run at any given time. After the scrub has completed, the status is updated and may be viewed with a status request: =20 - &prompt.root; zpool status storage + &prompt.root; zpool status storage pool: storage state: ONLINE scrub: scrub completed with 0 errors on Sat Jan 26 19:57:37 2013 @@ -502,9 +502,10 @@ =20 errors: No known data errors =20 - The completion time is displayed and helps to ensure data - integrity over a long period of time. - + The completion date of the last scrub operation is + displayed to help track when another scrub is required. + Routine pool scrubs help protect data from silent corruption + and ensure the integrity of the pool. =20 Refer to &man.zfs.8; and &man.zpool.8; for other ZFS options. @@ -581,6 +582,53 @@ redundancy. =20 + + Checking the Status of a Pool + + It is important to monitor the status of the + ZFS pool. If a drive goes offline, a + read or write error is detected, or a checksum fails to match, + the corresponding counters in the + display will be incremented. The + output shows the configuration and status of each device in + the pool, in addition to the status of the pool as the whole. + Also displayed are any actions that may need to be taken, and + details about when the last + + operation was completed. + + &prompt.root; zpool status + pool: mypool + state: ONLINE + scan: scrub repaired 0 in 2h25m with 0 errors on Sat Sep 14 04:25:50 2= 013 +config: + + NAME STATE READ WRITE CKSUM + mypool ONLINE 0 0 0 + raidz2-0 ONLINE 0 0 0 + ada0p3 ONLINE 0 0 0 + ada1p3 ONLINE 0 0 0 + ada2p3 ONLINE 0 0 0 + ada3p3 ONLINE 0 0 0 + ada4p3 ONLINE 0 0 0 + ada5p3 ONLINE 0 0 0 + +errors: No known data errors + + + + Clearing Errors + + If an error is detected with a device in a pool, the + corresponding read, write, or checksum counter will be + incremented. Once the issue is resolved, or to track the + rate of errors, zpool clear mypool will + reset the counters. This step can be important for automated + scripts that monitor the health of the pool and alert the + administrator when there is an error, further errors may not + be reported if the old errors are not cleared. + + Replacing a Functioning Device =20 @@ -622,8 +670,40 @@ restored from backups. =20 + + Scrubbing a Pool + + It is strongly recommended that a + Scrub operation be + performed regularly. Ideally atleast once each quarter. The + operating is very I/O intensive and + will reduce performance while it is in progress, so it much + be scheduled to avoid high demand periods. + + &prompt.root; zpool scrub mypool +&prompt.root; zpool status + pool: mypool + state: ONLINE + scan: scrub in progress since Wed Feb 19 20:52:54 2014 + 116G scanned out of 8.60T at 649M/s, 3h48m to go + 0 repaired, 1.32% done +config: + + NAME STATE READ WRITE CKSUM + mypool ONLINE 0 0 0 + raidz2-0 ONLINE 0 0 0 + ada0p3 ONLINE 0 0 0 + ada1p3 ONLINE 0 0 0 + ada2p3 ONLINE 0 0 0 + ada3p3 ONLINE 0 0 0 + ada4p3 ONLINE 0 0 0 + ada5p3 ONLINE 0 0 0 + +errors: No known data errors + + - ZFS Self-Healing + <acronym>ZFS</acronym> Self-Healing =20 ZFS utilizes the checkums stored with each data block to provide a feature called self-healing. @@ -651,8 +731,8 @@ two disks /dev/ada0 and /dev/ada1 is created. =20 - &prompt.root; zpool create healer<= /replaceable> mirror /dev/ada0 /d= ev/ada1 -&prompt.root; zpool status healer<= /userinput> + &prompt.root; zpool create healer mirror /dev/ada0 /dev= /ada1 +&prompt.root; zpool status healer pool: healer state: ONLINE scan: none requested @@ -665,7 +745,7 @@ ada1 ONLINE 0 0 0 =20 errors: No known data errors -&prompt.root; zpool list +&prompt.root; zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT healer 960M 92.5K 960M 0% 1.00x ONLINE - =20 @@ -674,12 +754,12 @@ A checksum of the pool is then created to compare it against the pool later on. =20 - &prompt.root; cp /some/important/data /healer -&prompt.root; zfs list + &prompt.root; cp /some/important/data /healer +&prompt.root; zfs list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT healer 960M 67.7M 892M 7% 1.00x ONLINE - -&prompt.root; sha1 /healer > checksum.txt -&prompt.root; cat checksum.txt +&prompt.root; sha1 /healer > checksum.txt +&prompt.root; cat checksum.txt SHA1 (/healer) =3D 2753eff56d77d9a536ece6694bf0a82740344d1f =20 Next, data corruption is simulated by writing random data @@ -700,12 +780,12 @@ of the pool are created before running the command! =20 - &prompt.root; zpool export healer<= /replaceable> -&prompt.root; dd if=3D/dev/random of=3D/dev/ada1 bs=3D1m coun= t=3D200 + &prompt.root; zpool export healer +&prompt.root; dd if=3D/dev/random of=3D/dev/ada1 bs=3D1m count=3D= 200 200+0 records in 200+0 records out 209715200 bytes transferred in 62.992162 secs (3329227 bytes/sec) -&prompt.root; zpool import healer +&prompt.root; zpool import healer =20 The ZFS pool status shows that one device has experienced an error. It is important to know that @@ -717,7 +797,7 @@ easily as the CKSUM column contains a value greater than zero. =20 - &prompt.root; zpool status healer<= /replaceable> + &prompt.root; zpool status healer pool: healer state: ONLINE status: One or more devices has experienced an unrecoverable error. A= n @@ -742,8 +822,8 @@ with the original one should reveal whether the pool is consistent again. =20 - &prompt.root; sha1 /healer >> checksum.txt -&prompt.root; cat checksum.txt + &prompt.root; sha1 /healer >> checksum.txt +&prompt.root; cat checksum.txt SHA1 (/healer) =3D 2753eff56d77d9a536ece6694bf0a82740344d1f SHA1 (/healer) =3D 2753eff56d77d9a536ece6694bf0a82740344d1f =20 @@ -762,8 +842,8 @@ required to remove the falsely written data from ada1. =20 - &prompt.root; zpool scrub healer -&prompt.root; zpool status healer<= /userinput> + &prompt.root; zpool scrub healer +&prompt.root; zpool status healer pool: healer state: ONLINE status: One or more devices has experienced an unrecoverable error. An @@ -792,7 +872,7 @@ operation is complete, the pool status has changed to the following: =20 - &prompt.root; zpool status healer<= /replaceable> + &prompt.root; zpool status healer pool: healer state: ONLINE status: One or more devices has experienced an unrecoverable error. An @@ -817,8 +897,8 @@ from the pool status by running zpool clear. =20 - &prompt.root; zpool clear healer -&prompt.root; zpool status healer<= /userinput> + &prompt.root; zpool clear healer +&prompt.root; zpool status healer pool: healer state: ONLINE scan: scrub repaired 66.5M in 0h2m with 0 errors on Mon Dec 10 12:26:2= 5 2012 @@ -890,17 +970,38 @@ need to be imported on an older system before upgrading. The upgrade process is unreversible and cannot be undone. =20 + &prompt.root; zpool status + pool: mypool + state: ONLINE +status: The pool is formatted using a legacy on-disk format. The pool c= an + still be used, but some features are unavailable. +action: Upgrade the pool using 'zpool upgrade'. Once this is done, the + pool will no longer be accessible on software that does not supp= ort feat + flags. + scan: none requested +config: + + NAME STATE READ WRITE CKSUM + mypool ONLINE 0 0 0 + mirror-0 ONLINE 0 0 0 + ada0 ONLINE 0 0 0 + ada1 ONLINE 0 0 0 + +errors: No known data errors + The newer features of ZFS will not be available until zpool upgrade has completed. can be used to see what new features will be provided by upgrading, as well as which features are already supported by the existing version. - =20 - - Checking the Status of a Pool - - + + If the system boots from the zpool, the boot code must + also be updated to support the new zpool version. Run + gpart bootcode on the partition that + contains the boot code. See &man.gpart.8; for more + information. + =20 @@ -917,7 +1018,7 @@ review this history is aptly named zpool history: =20 - &prompt.root; zpool history + &prompt.root; zpool history History for 'tank': 2013-02-26.23:02:35 zpool create tank mirror /dev/ada0 /dev/ada1 2013-02-27.18:50:58 zfs set atime=3Doff tank @@ -939,7 +1040,7 @@ displays user initiated events as well as internally logged ZFS events. =20 - &prompt.root; zpool history -i + &prompt.root; zpool history -i History for 'tank': 2013-02-26.23:02:35 [internal pool create txg:5] pool spa 28; zfs spa 28= ; zpl 5;uts 9.1-RELEASE 901000 amd64 2013-02-27.18:50:53 [internal property set txg:50] atime=3D0 dataset =3D= 21 @@ -954,7 +1055,7 @@ including information like the name of the user who issued the command and the hostname on which the change was made. =20 - &prompt.root; zpool history -l + &prompt.root; zpool history -l History for 'tank': 2013-02-26.23:02:35 zpool create tank mirror /dev/ada0 /dev/ada1 [user 0= (root) on :global] 2013-02-27.18:50:58 zfs set atime=3Doff tank [user 0 (root) on myzfsbox:= global] @@ -992,7 +1093,7 @@ to limit monitoring to just that pool. A basic example: =20 - &prompt.root; zpool iostat + &prompt.root; zpool iostat capacity operations bandwidth pool alloc free read write read write ---------- ----- ----- ----- ----- ----- ----- @@ -1019,7 +1120,7 @@ pool. This example shows a mirrored pool consisting of two devices: =20 - &prompt.root; zpool iostat -v + &prompt.root; zpool iostat -v capacity operations bandwidth pool alloc free read write read write ----------------------- ----- ----- ----- ----- ----- ----- @@ -1122,16 +1223,16 @@ compression property on a 250 MB volume allows creation of a compressed FAT filesystem. =20 - &prompt.root; zfs create -V 250m -o compression= =3Don tank/fat32 -&prompt.root; zfs list tank + &prompt.root; zfs create -V 250m -o compression=3D= on tank/fat32 +&prompt.root; zfs list tank NAME USED AVAIL REFER MOUNTPOINT tank 258M 670M 31K /tank -&prompt.root; newfs_msdos -F32 /dev/zvol/tank/fat32 -&prompt.root; mount -t msdosfs /dev/zvol/tank/fat32 /mnt -&prompt.root; df -h /mnt | grep fat32 +&prompt.root; newfs_msdos -F32 /dev/zvol/tank/fat32 +&prompt.root; mount -t msdosfs /dev/zvol/tank/fat32 /mnt +&prompt.root; df -h /mnt | grep fat32 Filesystem Size Used Avail Capacity Mounted on /dev/zvol/tank/fat32 249M 24k 249M 0% /mnt -&prompt.root; mount | grep fat32 +&prompt.root; mount | grep fat32 /dev/zvol/tank/fat32 on /mnt (msdosfs, local) =20 Destroying a volume is much the same as destroying a @@ -1182,8 +1283,8 @@ (:) is used to create a custom namespace for the property. =20 - &prompt.root; zfs set custom:costcenter=3D1234 tank -&prompt.root; zfs get custom:costcenter tank + &prompt.root; zfs set custom:costcenter=3D1234 tank +&prompt.root; zfs get custom:costcenter tank NAME PROPERTY VALUE SOURCE tank custom:costcenter 1234 local =20 @@ -1193,11 +1294,11 @@ datasets, it will be removed completely (although the changes are still recorded in the pool's history). =20 - &prompt.root; zfs inherit -r custo= m:costcenter tank -&prompt.root; zfs get custom:costcenter tank + &prompt.root; zfs inherit -r custom<= /replaceable>:costcenter tank +&prompt.root; zfs get custom:costcenter tank NAME PROPERTY VALUE SOURCE tank custom:costcenter - - -&prompt.root; zfs get all tank | g= rep custom:costcenter +&prompt.root; zfs get all tank | gre= p custom:costcenter= &prompt.root; =20 @@ -1255,7 +1356,7 @@ =20 - ZFS Replication + <acronym>ZFS</acronym> Replication =20 Keeping data on a single pool in one location exposes it to risks like theft, natural and human disasters. Keeping @@ -1265,12 +1366,13 @@ the data to standard output. Using this technique, it is possible to not only store the data on another pool connected to the local system, but also to send it over a network to - another system that runs ZFS. To achieve this replication, - ZFS uses filesystem snapshots (see the - section on ZFS snapshots) to send - them from one location to another. The commands for this - operation are zfs send and + another system that runs ZFS . To achieve + this replication, ZFS uses filesystem + snapshots (see the section on + ZFS + snapshots) to send them from one location to another. + The commands for this operation are + zfs send and zfs receive, respectively. =20 The following examples will demonstrate the functionality @@ -1357,7 +1459,7 @@ mypool 984M 43.7M 940M 4% 1.00x ONLINE - =20 - ZFS Incremental Backups + <acronym>ZFS</acronym> Incremental Backups =20 Another feature of zfs send is that it can determine the difference between two snapshots to @@ -1365,12 +1467,12 @@ saving disk space and time for the transfer to another pool. For example: =20 - &prompt.root; zfs snapshot mypool@backup2 -&prompt.root; zfs list -t snapshot + &prompt.root; zfs snapshot mypool@backup2 +&prompt.root; zfs list -t snapshot NAME USED AVAIL REFER MOUNTPOINT mypool@backup1 5.72M - 43.6M - mypool@backup2 0 - 44.1M - -&prompt.root; zpool list +&prompt.root; zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT backup 960M 61.7M 898M 6% 1.00x ONLINE - mypool 960M 50.2M 910M 5% 1.00x ONLINE - @@ -1377,20 +1479,20 @@ =20 A second snapshot called backup2 was created. This second - snapshot contains only the changes on the ZFS filesystem - between now and the last snapshot, - backup1. Using the + snapshot contains only the changes on the + ZFS filesystem between now and the last + snapshot, backup1. Using the -i flag to zfs send and providing both snapshots, an incremental snapshot can be transferred, containing only the data that has changed. =20 - &prompt.root; zfs send -i mypool@backup1 mypool@backup2 > /backup/incremental= -&prompt.root; zpool list + &prompt.root; zfs send -i mypool@backup1 mypool@backup2 > /backup/incremental +&prompt.root; zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT backup 960M 80.8M 879M 8% 1.00x ONLINE - mypool 960M 50.2M 910M 5% 1.00x ONLINE - -&prompt.root; ls -lh /backup +&prompt.root; ls -lh /backup total 82247 drwxr-xr-x 1 root wheel 61M Dec 3 11:36 backup1 drwxr-xr-x 1 root wheel 18M Dec 3 11:36 incremental= @@ -1407,7 +1509,7 @@ =20 - Receiving ZFS Data Streams + Receiving <acronym>ZFS</acronym> Data Streams =20 Up until now, only the data streams in binary form were sent to other pools. To get to the actual data contained in @@ -1421,8 +1523,8 @@ pool to another. This way, the data can be used directly on the receiving pool after the transfer is complete. =20 - &prompt.root; zfs send mypool@backup1 | zfs receive backup= /backup1 -&prompt.root; ls -lh /backup + &prompt.root; zfs send mypool@backup1 | zfs receive backup/b= ackup1 +&prompt.root; ls -lh /backup total 431 drwxr-xr-x 4219 root wheel 4.1k Dec 3 11:34 backup1= =20 @@ -1429,11 +1531,11 @@ The directory backup1 does contain all the data, which were part of the snapshot of the same name. Since this originally was a complete filesystem - snapshot, the listing of all ZFS filesystems for this pool - is also updated and shows the + snapshot, the listing of all ZFS + filesystems for this pool is also updated and shows the backup1 entry. =20 - &prompt.root; zfs list + &prompt.root; zfs list NAME USED AVAIL REFER MOUNTPOINT backup 43.7M 884M 32K /backup backup/backup1 43.5M 884M 43.5M /backup/backup1 @@ -1465,16 +1567,16 @@ encryption of the data on the pool itself. To make sure the network connection between both systems is securely encrypted, SSH can be used. - Since ZFS only requires the stream to be redirected from - standard output, it is relatively easy to pipe it through - SSH. + Since ZFS only requires the stream to be + redirected from standard output, it is relatively easy to + pipe it through SSH. =20 A few settings and security precautions have to be made - before this can be done. Since this chapter is about ZFS - and not about configuring SSH, it only lists the things - required to perform the encrypted zfs - send operation. The following settings should - be made: + before this can be done. Since this chapter is about + ZFS and not about configuring SSH, it + only lists the things required to perform the encrypted + zfs send operation. The following + settings should be made: =20 @@ -1500,8 +1602,8 @@ the receiving system, the encrypted stream can be sent using the following commands: =20 - &prompt.root; zfs snapshot -r mypool/ho= me@monday -&prompt.root; zfs send -R mypool/home@monday | ssh backuphost zfs recv -dvu backuppool<= /screen> + &prompt.root; zfs snapshot -r mypool/home= @monday +&prompt.root; zfs send -R mypool/home@monday | ssh backuphost zfs recv -dvu backuppool =20 The first command creates a recursive snapshot (option -r) called @@ -1549,13 +1651,13 @@ storage/home/bob, use the following: =20 - &prompt.root; zfs set quota=3D10G storage/home/= bob + &prompt.root; zfs set quota=3D10G storage/home/bo= b =20 To enforce a reference quota of 10 GB for storage/home/bob, use the following: =20 - &prompt.root; zfs set refquota=3D10G storage/ho= me/bob + &prompt.root; zfs set refquota=3D10G storage/home= /bob =20 The general format is userquota@user=3Dsize<= /replaceable>, @@ -1589,11 +1691,11 @@ For example, to enforce a user quota of 50 GB for the user named joe: =20 - &prompt.root; zfs set userquota@joe=3D50G + &prompt.root; zfs set userquota@joe=3D50G =20 To remove any quota: =20 - &prompt.root; zfs set userquota@joe=3Dnone + &prompt.root; zfs set userquota@joe=3Dnone =20 User quota properties are not displayed by @@ -1611,13 +1713,13 @@ firstgroup to 50 GB, use: =20 - &prompt.root; zfs set groupquota@firstgroup=3D5= 0G + &prompt.root; zfs set groupquota@firstgroup=3D50G= =20 To remove the quota for the group firstgroup, or to make sure that one is not set, instead use: =20 - &prompt.root; zfs set groupquota@firstgroup=3Dn= one + &prompt.root; zfs set groupquota@firstgroup=3Dnon= e =20 As with the user quota property, non-root users can @@ -1638,7 +1740,7 @@ root can list the quota for storage/home/bob using: =20 - &prompt.root; zfs get quota storage/home/bob + &prompt.root; zfs get quota storage/home/bob =20 @@ -1657,11 +1759,11 @@ so to set a reservation of 10 GB on storage/home/bob, use: =20 - &prompt.root; zfs set reservation=3D10G storage= /home/bob + &prompt.root; zfs set reservation=3D10G storage/h= ome/bob =20 To clear any reservation: =20 - &prompt.root; zfs set reservation=3Dnone storag= e/home/bob + &prompt.root; zfs set reservation=3Dnone storage/= home/bob =20 The same principle can be applied to the refreservation property for setting a @@ -1672,16 +1774,10 @@ This command shows any reservations or refreservations that exist on storage/home/bob: =20 - &prompt.root; zfs get reservation storage/home/= bob -&prompt.root; zfs get refreservation storage/home/bob + &prompt.root; zfs get reservation storage/home/bo= b +&prompt.root; zfs get refreservation storage/home/bob= =20 - - Compression - - - - Deduplication =20 @@ -1700,7 +1796,7 @@ To activate deduplication, set the dedup property on the target pool: =20 - &prompt.root; zfs set dedup=3Don p= ool + &prompt.root; zfs set dedup=3Don poo= l =20 Only new data being written to the pool will be deduplicated. Data that has already been written to the pool @@ -1708,7 +1804,7 @@ such, a pool with a freshly activated deduplication property will look something like this example: =20 - &prompt.root; zpool list + &prompt.root; zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT pool 2.84G 2.19M 2.83G 0% 1.00x ONLINE - =20 @@ -1719,7 +1815,7 @@ copied three times into different directories on the deduplicated pool created above. =20 - &prompt.root; zpool list + &prompt.root; zpool list for d in dir1 dir2 dir3; do for> mkdir $d && cp -R /usr/ports $d & for> done @@ -1726,7 +1822,7 @@ =20 Redundant data is detected and deduplicated: =20 - &prompt.root; zpool list + &prompt.root; zpool list NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT pool 2.84G 20.9M 2.82G 0% 3.00x ONLINE - =20 @@ -1742,7 +1838,7 @@ ZFS can show potential space savings by simulating deduplication on an existing pool: =20 - &prompt.root; zdb -S pool + &prompt.root; zdb -S pool Simulated DDT histogram: =20 bucket allocated referenced @@ -1778,8 +1874,80 @@ due to the much lower memory requirements. =20 + + Compression + + ZFS provides transparent compression. + Compressing data at the block level as it is written not only + saves storage space, but can also result in higher disk + throughput than would otherwise be possible. If data is + compressed by 25%, then the compressed data can be written to + the disk at the same rate as the uncompressed version, + resulting in an effective write speed of 125% of what would + normally be possible. Compression can also be a great + alternative to + Deduplication + because it does not require additional memory to store a + DDT. + + ZFS offers a number of different + compression algorithms to choose from, each with different + trade-offs. With the introduction of LZ4 + compression in ZFS v5000, it is possible + to enable compression for the entire pool without the large + performance trade-off of other algorithms. The biggest + advantage to LZ4 is the + early abort feature. If + LZ4 does not achieve atleast 12.5% + compression in the first part of the data, the block is + written uncompressed to avoid wasting CPU cycles trying to + compress data that is either already compressed or + uncompressible. For details about the different compression + algorithms available in ZFS, see the + Compression entry + in the terminology section. + + The administrator can monitor the effectiveness of + ZFS compression using a number of dataset + properties. + + &prompt.root; zfs get used,compressratio,compress= ion,logicalused mypool/compressed_dataset +NAME PROPERTY VALUE SOURCE +mypool/compressed_dataset used 449G - +mypool/compressed_dataset compressratio 1.11x - +mypool/compressed_dataset compression lz4 local +mypool/compressed_dataset logicalused 496G - + + The dataset is currently using 449 GB of storage + space (the used property). If this dataset was not compressed + it would have taken 496 GB of space (the logicallyused + property). This results in the 1.11:1 compression + ratio. + + Compression can have an unexpected side effect when + combined with + User Quotas. + ZFS user quotas restrict how much space + a user can consume on a dataset, however the measurements are + based on how much data is stored, after compression. So if a + user has a quota of 10 GB, and writes 10 GB of + compressible data, they will still be able to store additional + data. If they later update a file, say a database, with more + or less compressible data, the amount of space available to + them will change. This can result in the odd situation where + a user did not increase the actual amount of data (the + logicalused property), but the change in + compression means they have now reached their quota. + + Compression can have a similar unexpected interaction with + backups. Quotas are often used to limit how much data can be + stored to ensure there is sufficient backup space available. + However since quotas do not consider compression, more data + may be written than will fit in uncompressed backups. + + - ZFS and Jails + <acronym>ZFS</acronym> and Jails =20 zfs jail and the corresponding jailed property are used to delegate a @@ -1843,22 +2011,22 @@ =20 - ZFS Advanced Topics + <acronym>ZFS</acronym> Advanced Topics =20 - ZFS Tuning + <acronym>ZFS</acronym> Tuning =20 =20 - Booting Root on ZFS + Booting Root on <acronym>ZFS</acronym> =20 =20 - ZFS Boot Environments + <acronym>ZFS</acronym> Boot Environments =20 @@ -1870,7 +2038,7 @@ =20 - ZFS on i386 + <acronym>ZFS</acronym> on i386 =20 Some of the features provided by ZFS are memory intensive, and may require tuning for maximum @@ -1942,38 +2110,46 @@ FreeBSD - Wiki - ZFS + Wiki - ZFS =20 FreeBSD - Wiki - ZFS Tuning + Wiki - ZFS Tuning =20 Illumos - Wiki - ZFS + Wiki - ZFS =20 Oracle - Solaris ZFS Administration Guide + Solaris ZFS Administration + Guide =20 ZFS + xlink:href=3D"http://www.solarisinternals.com/wiki/index.php/ZFS_Ev= il_Tuning_Guide">ZFS Evil Tuning Guide =20 ZFS + xlink:href=3D"http://www.solarisinternals.com/wiki/index.php/ZFS_Be= st_Practices_Guide">ZFS Best Practices Guide + + + Cal= omel + Blog - ZFS Raidz Performance, Capacity + and Integrity + =20 @@ -2449,10 +2625,68 @@ and write throughput, as only the smaller compressed version of the file needs to be read or written. =20 - - LZ4 compression is only - available after &os; 9.2. - + + + LZ4 - + was added in ZFS pool version + 5000 (feature flags), and is now the recommended + compression algorithm. LZ4 + compresses approximately 50% faster than + LZJB when operating on + compressible data, and is over three times faster + when operating on uncompressible data. + LZ4 also decompresses + approximately 80% faster than + LZJB. On modern CPUs, + LZ4 can often compress at over + 500 MB/s, and decompress at over + 1.5 GB/s (per single CPU core). + + + LZ4 compression is + only available after &os; 9.2. + + + + + LZJB - + is the default compression algorithm in + ZFS. Created by Jeff Bonwick + (one of the original creators of + ZFS). LZJB + offers good compression with less + CPU overhead compared to + GZIP. In the future, the + default compression algorithm will likely change + to LZ4. + + + + GZIP - + is a popular stream compression algorithm and is + available in ZFS. One of the + main advantages of using GZIP + is its configurable level of compression. When + setting the compress property, + the administrator can choose which level of + compression to use, ranging from + gzip1, the lowest level of + compression, and gzip9, the + higher level of compression. This gives the + administrator control over how much + CPU time to trade for saved + disk space. + + + + ZLE - + (zero length encoding) is a special compression + algorithm that only compresses continuous runs of + zeros. This compression algorithm is only useful + if your dataset contains large areas where only + the zero byte is written. + + =20 @@ -2511,7 +2745,9 @@ at least once each quarter. Checksums of each block are tested as they are read in normal use, but a scrub operation makes sure even infrequently used blocks are - checked for silent corruption. + checked for silent corruption, improving the security of + your data, especially in archival storage + situations. =20 --------------090505060909090403030007-- --jXBqfIoI7A7s1SsEHTcJEC2its8v0F2Mg Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (MingW32) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQIcBAEBAgAGBQJTBamnAAoJEJrBFpNRJZKf13wQAKCxDZGBn6Qnz13NJiiAjtx5 dzKr0sOyED0/gmQ0yCVdXxNcSeLQ8jqJm3NrmApwzPM9TAtW2mim1cVx1YzKLu0q 2NYYdgHkiKoMqyyAxpna3XC3I07W1VrQcp7xsh9pCYW/qp09HeAg0+0f+zedkfA/ W4xUo+tuQfrF7v+uhQtnQ5xRULES0/0aQL1ctqse/KUxZzvVVSB0DhAoIWhO2O6J wsqxkLLEyF3MIFRb5Bi86FnqbM6TteibvrXBeEAvO9e6Yk5Q/hHPFRuEWCN+589g 2y2t6s7EqvdH2/DGGrohyEv0v4LCdX1XFSUAkrGVguuuwdv888rU4IpkkVt0HFOd kgvQXBgFcqX1E+shblS2qtiQ09jAwlT+sjd7fjGwmKO/uLdZZ/cJPLnE5O65DZuZ fgmNcWFcMdnim7vNU3UfZlRP+zHUW+7NjgAti2PYb7u8wEHS/Bd9efnwruFAF/zB zIckWF7t9DAg9T1gCeLokgb7ojRckbHanerU3VQg3b6tPDJrA9cjE7GG8wxZzRsE Bd5dnMw4ipC39A+qhSSNUVD5N5tK1gIg3BqLwf8V7CUv6rBlBwLTosVuvcrKqYN/ 67NZn6+c7dnSEgBgpDBAt4c+4r2mzeonInQcTV9l6PveWINSIRLEcDoV2CBy0Z7h SgG/Cyq51oY0ZsErGxCM =nls0 -----END PGP SIGNATURE----- --jXBqfIoI7A7s1SsEHTcJEC2its8v0F2Mg--