How to Use ZFS File System on Ubuntu
In Linux, a large number of file systems can be used. Why should we try a new file system? They all work well, don't they? But they are not exactly the same. Some of these file systems have outstanding advantages, such as ZFS.
Why ZFS?
ZFS is excellent. This is a truly modern file system. The built-in functions make sense for processing a large amount of data.
If you are considering using ZFS for your ultra-high-speed NVMe SSD, this may not be the best choice. It is slower than other file systems, but it is no problem at all, it aims to store a large amount of data and maintain security.
ZFS eliminates the need to create a traditional RAID array (LCTT: redundant independent disk array. Instead, you can create ZFS pools or even add drives to these pools at any time. The behavior operations of the ZFS pool are almost identical to those of RAID, but the functions are built into the file system.
ZFS can also replace LVM (LCTT: Logical Disk volume management), allowing you to dynamically partition and manage partitions without the need to process underlying details or worry about related risks.
This is also a CoW (LCTT: Copy at write time) file system. This won't mention too much technology, which means ZFS can protect your data from gradual damages. ZFS creates a file checksum and allows you to roll back these files to previous working versions.
Install ZFS
Install ZFS on Ubuntu
Installing ZFS on Ubuntu is very simple, but this process is slightly different from the latest version for Ubuntu LTS (LCTT notes: supported versions for a long time.
Ubuntu 16.04 LTS
sudo apt install zfs
Ubuntu 17.04 and later
sudo apt install zfsutils
After installing the program, you can use the tools provided by ZFS to create ZFS drives and partitions.
Create a pool
Create ZFS Pool
In ZFS, the pool is roughly equivalent to RAID. They are flexible and easy to operate.
RAID0
RAID0 just places your hard disk in a pool, just like a huge drive. It can increase the speed of your drive (LCTT annotation: parallel access after data striping, can increase the speed of File Reading) But if your drive is damaged, you may lose data.
To implement RAID0 using ZFS, you only need to create a normal pool.
sudo zpool create your-pool /dev/sdc /dev/sdd
RAID1 (image)
You can usemirrorKeyword to implement the RAID1 function. RAID1 creates a one-to-one copy of the drive. This means that your data is being backed up. It also improves performance. Of course, you use half of the storage space for replication.
sudo zpool create your-pool mirror /dev/sdc /dev/sdd
RAID5/RAIDZ1
ZFS implements the RAID5 function as RAIDZ1. RAID5 requires at least three drives. And allows you to write the backup parity data to 1/n of the drive space (n is the number of drives), leaving the available storage space. If a drive fails, the array will remain online, but the faulty drive should be replaced as soon as possible, in the original article, the number of drives is a multiple of three. Based on wiki, RAID5 requires at least three drives. You can also guess from the following command ).
sudo zpool create your-pool raidz1 /dev/sdc /dev/sdd /dev/sde
RAID6/RAIDZ2
RAID6 is almost identical to RAID5, but it requires at least four drives. It doubles the parity data and allows up to two drives to be damaged without causing the array to be shut down (LCTT, according to the wiki, RAID6 requires at least four drives ).
sudo zpool create your-pool raidz2 /dev/sdc /dev/sdd /dev/sde /dev/sdf
RAID10 (striped image)
RAID10 aims to improve the access speed and data redundancy through data striping to become a perfect solution. You need at least four drives, but only half of the space is used. You can create two images in the same pool to create a pool in raid 10 (LCTT). Here it is also slightly different from the original version. The original version is a multiple of four drives. According to wiki, RAID10 requires at least four drives ).
sudo zpool create your-pool mirror /dev/sdc /dev/sdd mirror /dev/sde /dev/sdf
Pool operations
ZFS pool Status
There are also some management tools that you must use once you have created your pool. First, check the status of your pool.
sudo zpool status
Update
When you update ZFS, you also need to update your pool. When you check their status, your pool will notify you of any updates. To update the pool, run the following command.
sudo zpool upgrade your-pool
You can also update all pools.
sudo zpool upgrade -a
Add drive
You can also add the drive to the pool at any time. TellzpoolThe name of the pool and the location of the drive. It handles everything.
sudo zpool add your-pool /dev/sdx
Other ideas
ZFS in File Browser
ZFS creates a directory in the root file system of your pool. You can use the GUI File Manager or CLI to browse them by name.
ZFS is very powerful, and many other things can be used for it, but these are the basis. This is an excellent Storage Load file system, even if it is just a RAID array for the hard drive of files. ZFS is also outstanding in NAS systems.
Regardless of the stability and reliability of ZFS, it is best to back up your data when implementing new features on your hard disk.
Https://www.bkjia.com/Linux/2018-02/150950.htm