11
ZFS for the Masses: Management Tools Provided by the PCBSD and FreeNAS Projects Dru Lavigne [email protected] iXsystems Abstract ZFS is a robust, copyonwrite filesystem designed to be selfhealing and to overcome the inherent limitations of hardware RAID. While it has been available in FreeBSD since 7.0, a lack of integration with server and desktop management tools has slowed its adoption by many FreeBSD users. This paper introduces some of the compelling features of ZFS from a user perspective and some of the PCBSD and FreeNAS utilities for taking advantage of these features. The PCBSD project (pcbsd.org) provides a suite of graphical tools, with commandline equivalents, for installing and managing a FreeBSD desktop or server. The FreeNAS project (freenas.org) provides a FreeBSD based Network Attached Storage solution that provides a graphical, webbased configuration interface. The examples used in this paper are from PCBSD 10.0 and FreeNAS 9.2.0. ZFS Pools and Datasets ZFS provides great flexibility for creating, managing, and growing the capacity of the filesystem as needed. Unlike traditional Unix filesystems, which create a fixed size at filesystem creation time, ZFS uses the concepts of a pool and datasets. A ZFS pool is a disk or collection of disks that is formatted with ZFS. When adding multiple disks to a pool, a level of redundancy, known as a RAIDZ*, can be specified. The number following the RAIDZ indicates how many disks can fail without losing the pool. For example, one disk can fail in a RAIDZ1, two disks in a RAIDZ2, and three disks in a RAIDZ3. In theory, any number of disks can be added when creating a pool and any number of disks can be added to an existing pool to increase its capacity. In practice, specify the number of disks recommended for that RAIDZ level and plan to stripe that same number of disks should the storage capacity of the pool need to be increased in the future. Failure to do so can decrease performance significantly. The recommended number of disks for each RAIDZ configuration is explained in the ZFS Storage Pools Recommendation of the ZFS Best Practices Guide. 1 A ZFS dataset is similar to a folder in that it supports permissions. A dataset is also similar to a filesystem in that you can set properties such as quotas and compression. The full list of available properties are described in zpool(8). Datasets can be created at any time, allowing for great flexibility in managing data. Unless a quota is set on the dataset, the full remaining capacity of the pool is available to any dataset. The PCBSD installer makes it easy to create the ZFS pools and initial datasets. An example of the PCBSD graphical installer is seen in Figures 1 and 2. An example of the PCBSD ncurses installer is seen in Figure 3. If multiple disks are available when installing PC BSD, check the box “Enable ZFS mirror/raidz mode” shown in Figure 1, select the desired configuration from the dropdown menu, and check the number of disks. The installer will indicate the optimal number of disks for that configuration and will not let you select a configuration that does not contain the minimum required disks. 1 http://solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide#ZFS_Storage_Pools_Recommendations

Asiabsdcon14 lavigne

Embed Size (px)

DESCRIPTION

Formal paper for AsiaBSDCon 2014

Citation preview

Page 1: Asiabsdcon14 lavigne

ZFS for the Masses: Management Tools Providedby the PC­BSD and FreeNAS Projects

Dru [email protected]

iXsystems

Abstract

ZFS is a robust, copy­on­write filesystem designedto be self­healing and to overcome the inherentlimitations of hardware RAID. While it has beenavailable in FreeBSD since 7.0, a lack ofintegration with server and desktop managementtools has slowed its adoption by many FreeBSDusers.

This paper introduces some of the compellingfeatures of ZFS from a user perspective and someof the PC­BSD and FreeNAS utilities for takingadvantage of these features. The PC­BSD project(pcbsd.org) provides a suite of graphical tools, withcommand­line equivalents, for installing andmanaging a FreeBSD desktop or server. TheFreeNAS project (freenas.org) provides a FreeBSD­based Network Attached Storage solution thatprovides a graphical, web­based configurationinterface. The examples used in this paper are fromPC­BSD 10.0 and FreeNAS 9.2.0.

ZFS Pools and Datasets

ZFS provides great flexibility for creating,managing, and growing the capacity of thefilesystem as needed. Unlike traditional Unixfilesystems, which create a fixed size at filesystemcreation time, ZFS uses the concepts of a pool anddatasets.

A ZFS pool is a disk or collection of disks that isformatted with ZFS. When adding multiple disks toa pool, a level of redundancy, known as a RAIDZ*,can be specified. The number following the RAIDZindicates how many disks can fail without losingthe pool. For example, one disk can fail in aRAIDZ1, two disks in a RAIDZ2, and three disksin a RAIDZ3. In theory, any number of disks can beadded when creating a pool and any number ofdisks can be added to an existing pool to increaseits capacity. In practice, specify the number of disksrecommended for that RAIDZ level and plan tostripe that same number of disks should the storagecapacity of the pool need to be increased in thefuture. Failure to do so can decrease performancesignificantly. The recommended number of disksfor each RAIDZ configuration is explainedin the ZFS Storage Pools Recommendation ofthe ZFS Best Practices Guide. 1

A ZFS dataset is similar to a folder in that itsupports permissions. A dataset is also similar to afilesystem in that you can set properties such asquotas and compression. The full list of availableproperties are described in zpool(8). Datasets canbe created at any time, allowing for great flexibilityin managing data. Unless a quota is set on thedataset, the full remaining capacity of the pool isavailable to any dataset.

The PC­BSD installer makes it easy to create theZFS pools and initial datasets. An example of thePC­BSD graphical installer is seen in Figures 1 and2. An example of the PC­BSD ncurses installer isseen in Figure 3.

If multiple disks are available when installing PC­BSD, check the box “Enable ZFS mirror/raidzmode” shown in Figure 1, select the desiredconfiguration from the drop­down menu, and checkthe number of disks. The installer will indicate theoptimal number of disks for that configuration andwill not let you select a configuration that doesnot contain the minimum required disks.

1 http://solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide#ZFS_Storage_Pools_Recommendations

Page 2: Asiabsdcon14 lavigne

Figure 1: Pool Creation in Graphical PC­BSD Installer

Figure 2: Dataset Creation in Graphical PC­BSD Installer

Page 3: Asiabsdcon14 lavigne

Figure 3: Dataset Creation in ncurses PC­BSD Installer

To modify the ZFS options of a default datasetwhen installing PC­BSD, highlight an existingdataset in the screen shown in Figure 2. Use the“+Add” button to create additional datasets.

When using the ncurses installer shown in Figure 3,select an existing dataset with the up/down arrowsand press enter to configure its options. Select“add” to create a new dataset andset its options.

In FreeNAS, the operating system is separate fromthe storage disks so pool creation occurs from themanagement interface. The ZFS Volume Manager,shown in Figure 4, will automatically display theoptimal pool configuration and storage capacity forthe number of selected disks. Once the pool iscreated, datasets can be created as needed using thescreen shown in Figure 5.

Page 4: Asiabsdcon14 lavigne

Figure 4: Using the FreeNAS ZFS Volume Manager to Create the Pool

Figure 5: Creating a Dataset in FreeNAS

Page 5: Asiabsdcon14 lavigne

ZFS Multiple Boot Environments

The default datasets provided by the PC­BSDinstaller are used to provide a ZFS feature knownas multiple boot environments. Boot environmentscan be used to mitigate the risk associated with afailed operating system upgrade. They can also beused to test hardware compatibility on anothersystem or to provide a staging area to testapplication upgrades. Before performing one ofthese operations, simply create a snapshot of thecurrent boot environment. Should the upgrade failor you wish to return to the previous bootenvironment, simply reboot and select the desiredboot environment from the boot menu.

Figure 6 shows the PC­BSD Boot Manager utilityfor creating and managing boot environments. Thisutility is a front­end to the built­in beadm CLI.Figure 7 shows an example boot menu after a bootenvironment has been created.

Boot environments do not include user homedirectories, meaning that any changes to a user'sdata will still be available if the system is bootedinto a previous boot environment. The LifePreserver tool, described in the next section, can beused by users to manage previous versions of theirdata.

Figure 6: Using Boot Manager to Manage Boot Environments

Page 6: Asiabsdcon14 lavigne

Figure 7: Sample Boot Menu Containing a Created Boot Environment

Using Life Preserver for Snapshot Managementin PC­BSD

In ZFS, a point­in­time snapshot can be taken atany time and can either be stored locally orreplicated to another system. Snapshots areinstantaneous and initially zero bytes in size. As thedata changes between that point in time, thesnapshot grows accordingly. Snapshots can be usedto retrieve a version of a file from a previous pointin time, or even to return the entire filesystem to acertain point in time.

The Life Preserver utility, shown in Figure 8, canbe used to create a snapshot at any time. Forexample, if a user is about to make edits toimportant files, they can first create a snapshotwhich will preserve the current versions of everyfile in the pool.

Alternately, Life Preserver provides a Wizard toschedule the automated creation of snapshots every5, 10, 30, 60 minutes or once per day and tooptionally send a copy of those snapshots to aremote system. The backup schedule and system toreplicate to can be modified at any time byclicking the “Configure” button.

The “Restore Data” tab, shown in Figure 9,provides a time­slider for scrolling throughsnapshots. Once a snapshot is selected, simplybrowse to the location of a directory or file andclick the “Restore” button to restore a copy of theselected item. Multiple versions can be restored,allowing the user to find a specific change.

If snapshots are replicated to another system, aspecified remote snapshot can be used to restore adamaged installation or to clone an existinginstallation to another system.To use this function,start a PC­BSD installation on the desired system,and select the “Restore from Life­preserverbackup” option in the screen shown in Figure 10. Awizard will prompt you for the IP address and logininformation of the system hosting the snapshots.Once connected, you can select which snapshot (orpoint in time) to restore from.

Refer to Kris Moore's paper "Snapshots,Replication, and Boot­Environments ­ How newZFS utilities are changing FreeBSD & PC­BSD"for more information about Life Preserver.

Page 7: Asiabsdcon14 lavigne

Figure 8: Creating a Snapshot

Figure 9: Restoring a Previous Version from a Snapshot

Page 8: Asiabsdcon14 lavigne

Figure 10: Restoring/Cloning a System from a Replicated Snapshot

Using Warden to Manage Jail Snapshots inPC­BSD

Warden provides a graphical interface for quicklydeploying and managing FreeBSD jails. It also hasa built­in, per­jail, snapshot management utility.Figure 11 shows the “Snapshot” tab for ahighlighted jail. To create a snapshot now, click the“+Add” button. To schedule the automatic creationof snapshots, check the “Scheduled Snapshots” boxand select the frequency. Once snapshots areavailable, use the time­slider to select the desiredsnapshot.

It is worth noting that since Warden providesexperimental Linux jail support, it provides amechanism for experimenting with ZFS features onLinux without licensing concerns.

Snapshot Management in FreeNAS

FreeNAS provides Periodic Snapshot Tasks, shownin Figure 12, for scheduling snapshots. Snapshotscan be scheduled on the filesystem (with or withoutits datasets) or on an individual dataset basis.Replication Tasks, shown in Figure 13, canoptionally be used to schedule the replication of theresulting snapshots to another system runningrsync. The replication can be optionally encryptedif the other system is running SSH. The replicationtask can be scheduled to occur immediately aftersnapshot creation or a replication window can becreated to replicate queued snapshots after businesshours.

Page 9: Asiabsdcon14 lavigne

Figure 11: Managing a Jail's Snapshots

Figure 12: Scheduling a Periodic Snapshot Task in FreeNAS

Page 10: Asiabsdcon14 lavigne

Figure 13: Scheduling the Replication of Snapshots to Another System

Scrub Management

Another ZFS feature is the scrub, a process whichchecks the checksum associated with each diskblock, and if the checksum differs, attempts tocorrect the data stored in the block. Schedulingregular scrubs and viewing their results helps toidentify data integrity problems, detect silent datacorruptions caused by transient hardware issues,and provide an early indication of pending diskfailures. This type of insight into the health of one'sdata is particularly useful in a device that is usedfor network storage, such as FreeNAS.

When a pool is created in FreeNAS, itautomatically schedules a ZFS Scrub task to occurevery Sunday evening at midnight. As seen in theexample in Figure 14, the schedule can bemodified to a time that least impacts users.

In PC­BSD 10.0, the ZFS Pools tab of DiskManager can be used to start a scrub when needed.A future version of PC­BSD will add the ability tocreate a scrub schedule.

For any ZFS system, it is recommended to performa scrub once per week for consumer­quality drivesand once per month for datacenter­quality drives.

Page 11: Asiabsdcon14 lavigne

Figure 14: Editing the Scrub Schedule in FreeNAS

Additional Resources

The management utilities provided in both PC­BSDand FreeNAS make it easy to take advantage of themany features provided by ZFS. This paper hasonly scratched the surface of the available features.

Both the PC­BSD and FreeNAS Projects providecomprehensive Guides which detail the use of theseand other tools. The Guides are version­specificand one should download the version that matchestheir operating system version:

• the PC­BSD Users Handbook can be downloadedfrom wiki.pcbsd.org

• the FreeNAS User Guide can be downloadedfrom doc.freenas.org

There are many good resources for learning moreabout ZFS. These include:

ZFS Best Practices Guide:http://www.solarisinternals.com/wiki/index.php/ZFS_Best_Practices_Guide

Becoming a ZFS Ninja (video):http://blogs.oracle.com/video/entry/becoming_a_zfs_ninja

ZFS Wikipedia entry:http://en.wikipedia.org/wiki/Zfs