Your favorite ZFS file system

Source: Internet
Author: User

As a new feature of Solaris 10 and OpenSolaris, ZFS attracts the attention of many in the open source community, and Linux's father, Linus Torvalds, openly represents a particular interest in the Solaris Software's ZFS (zettabyte file system), It is considered that the system manages files in hard disk storage mode, has built-in function spanning multiple hard disks while maintaining data integrity. But according to his "pessimistic" forecasts, Sun will try to stop Linux from getting ZFS. In this article, I want to talk about my own knowledge of ZFS. What is ZFS

Solaris ZFS can be said to be an innovation in traditional disk and file system management. Operating system design at the beginning of the time, the disk is divided into different partitions (partition), on each partition to establish the management data of the file system, the operating system through the Read/write system calls to provide read and write access to files on the file system. With the development of technology, people find that this method of file management has many problems, of which two points are the most prominent, first, because the size of the file system is actually created when the file system is specified, and the size of the file system is limited by the size of the partition, while in use if a file system space is full, In addition to reconfiguring the system, there is no choice; In addition, a portion of the file system is occupied by the file system itself, to store information about the file system, such as the file system in fact block number, size, root node block number, file system properties and so on. This information is generated when the file system is created, which is why the file system space is still not 100%free when Du is in an empty file system. If the second problem can be tolerated (after all, a fraction of knowledge), then the first drawback is enough to drive people to find good solutions. RAID is a good way to solve a problem.

RAID (Redundant array of inexpensive Disks), as the name implies is a disk array composed of multiple disks to store data, the file system can be built on multiple disks, so that can be fanciful. In order to enhance the security of the data, prevent a hard disk in the array corruption, resulting in the loss of all data, RAID also provides redundant information, so that the damaged disk in the array can be replaced by other disks. Currently, the more popular raid includes the RAID0,RAID1,RAID5 and their comps.

RAID0 provides the functionality of stripe, and simply pieced together the disks in the array, and any one of the disks is destroyed, resulting in a total annihilation; RAID0 provides the mirror function that two identical disks hold the same content so that any disk is broken and another is on the top, However, the cost increases by twice times; RAID5 also establishes stripe and redundancy on multiple disks (at least 3), allowing disk space to be expanded while providing redundancy to ensure the replacement of any one disk.

Currently, there are 3 ways to implement raid. First, the RAID function is implemented by hardware, by the purchase of expensive hardware board card, to build a RAID system, the current market raid control card is divided by Lsi,intel,qlogic, the second, in the system's South Bridge chip and the BIOS to add RAID function support, This feature is almost always supported on Intel's server platforms, which is much cheaper than the first, and the third is that all RAID functions are performed by the operating system software, and common unix/linux systems are supported by tools called Volume Manager to support RAID functionality. This method is the cheapest, easiest to get, and also best fits the meaning of the raid name: cheap.

However, there is no exception to the cheap goods that are not good. There are two drawbacks to the Volume Manager tool, first of all, the tools are more complex to use. The author used a week to learn the Volume Manger tool under FreeBSD, deeply feel its configuration file obscure, second, is also fatal, that is RAID5 write hole defect. RAID5 in writing data, is divided into two steps, the first to write data to the disk array, and then the stripe on the data on the check code record to the array, if the data is just finished writing, the system power off, then the data corresponding to the check code will not be able to recover, long-term past, can imagine.

So much has been said about how ZFS solves this problem. As shown in the following illustration,

Traditional volume manager Regardless of hardware, firmware or operating system software implementation, volume are pre-set, the file system is built on a single volume, the space between different volume can not be shared dynamically, so that the file system is limited to one device , so the file system itself is limited by the size of the volume. While the ZFS file system is not limited to any particular device or volume, but instead puts all possible devices into a storage pool, the size of the file system is allocated in this pool according to its actual needs, which is somewhat similar to the system memory management method, based on this management method, The ZFS file system can take full advantage of all storage devices in the storage pool. What's more, all of this is transparent to the user, and users can manage the ZFS file system dynamically, just like creating and deleting directories, and when a filesystem is created, it automatically mount to the system's file directory tree, which greatly simplifies the difficulty of ZFS administration. At the same time, devices in the storage pool can be dynamically added, deleted, or replaced, and the same ZFS file system can be ported between different systems.

With all that said, let's try. Create and manage a ZFS to experience ZFS's ease of management and powerful functionality. Management of ZFS

The following line of commands creates a ZFS storage pool:

bash-3.00# zpool Create test raidz2 c0t1d0s0 c0t1d0s1 c0t1d0s2 c0t1d0s3

Where the RAID2 parameter specifies that a RAID-Z raid is established on the subsequent device, which is similar to RAID5, but resolves the write hole issue with the RAID 5 software implementation. ZFS can provide 4 RAID levels, called stripe (default), MIRROR,RAIDZ1, and RAIDZ2, respectively. Swapping raidz2 for mirror or RAIDZ1 will create other types of RAID. The created storage pool can be viewed using the following command:

bash-3.00# Zpool List

NAME SIZE used AVAIL CAP Health Altroot

Test 15.9G 274K 15.9G 0% ONLINE-

bash-3.00# zpool status-v Test

Pool:test

State:online

Scrub:none requested

Config

NAME State READ WRITE cksum

Test ONLINE 0 0 0

RAIDZ2 ONLINE 0 0 0

C0t1d0s0 ONLINE 0 0 0

C0T1D0S1 ONLINE 0 0 0

C0t1d0s2 ONLINE 0 0 0

C0T1D0S3 ONLINE 0 0 0

Errors:no Known data errors

After the storage pool is created, ZFS creates a directory with the same name as the storage pool under the root directory and mount the ZFS root file system under that directory, all of which are based on the ZFS root file system, which can be passed the-m parameter, Mount the root directory in a different location in the System directory tree:

Bash-3.00#zpool create-m/EXPORT/ZFS Home c1t0d0

Deleting a ZFS storage pool is also relatively straightforward:

bash-3.00# Zpool Destroy Test

If the current device is in use, causing the command to be unsuccessful, you can use the-f parameter to forcibly destroy it (by default you know the consequences of doing so).

Creating and Deleting a ZFS file system and creating deleting a directory is as simple as:

bash-3.00# ZFS Create Test/home

bash-3.00# ZFS Destroy Test/home

bash-3.00# ZFS Rename Test/home/user test/home/user2

bash-3.00# ZFS List

NAME used AVAIL REFER mountpoint

Test 210K 7.78G 29.9k/test

Test/home 56.8K 7.78G 29.9k/test/home

Test/home/user2 26.9K 7.78G 26.9k/test/home/user2

Once these filesystems are created, the system automatically mount them in the ZFS root directory, and the administrator does not need to modify the/etc/vfstab file. In addition, the ZFS command can use the quota and reservation properties to specify quotas and reserve space for a ZFS file system.

The ZFS file system also provides the ability to snapshot (snapshot) and Clone (clone), as this article is not intended to be a complete ZFS administration Guide, and you can download the appropriate article to docs.sun.com. summarizing This article provides a brief introduction to the background of ZFS related to the Solaris 10/opensolaris, as well as a brief description of how to create and manage a ZFS file system. Keywords: ZFS, OpenSolaris, Volume Manager, ZPOOL.

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: info-contact@alibabacloud.com 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.