ZFS file system allow you to take snapshot, this is great for backing up MySQL databases. Last day i setup 2 * 2 TB Hard disk on My PC as RAID 1 (mirror) using ZFS.
First install ZFS with
apt install zfsutils-linux
I created same size partition on both hard disks. You can use full disk if you want, but i created partition, so i can use first 100 GB of each disk for installing Operating system.
RAID 1
RAID 1 mirror data between 2 disks. Even if one of the disk die, your data will be safe.
To create RAID 1, run
zpool create tank mirror /dev/sdx3 /dev/sdy3
Here sdx3 and sdy3 is partition on my HDD. Replace it with your actual partition to be used with ZFS. Be carefull not to use wrong partition or you will lose data.
If you are using full disk, then use
zpool create tank mirror /dev/sdx /dev/sdy
RAID 0
RAID 0 is dangerous, only use if you don’t care about data or you have a backup. If one of the disk fails, you will lose all data.
To setup RAID 0, use
zpool create tank /dev/sdx3 /dev/sdy3
Pool
Once you create a ZFS pool with “zpool” command, it get auto mounted as “/pool-name”. In above cause, i used name “tank”.
Here is what i have on my PC
root@ok-pc-01:~# df -h | grep tank tank/data 1.6T 371G 1.3T 23% /mnt/data tank 1.3T 0 1.3T 0% /tank root@ok-pc-01:~#
The 2nd entry is the ZFS pool tank.
Datasets
Datasets are like partitions. You can create multiple partitions inside your pool, they sare disk space. You can set disk quotas if needed, by default no quota per datasets are set.
In above example /tank/data is a datasets i use.
To create a data set, run
zfs create -o mountpoint=/mnt/data tank/data
Here “-o mountpoint” specify where you want to mount the new dataset.
zpool status
To see status for your ZFS file system, run
root@ok-pc-01:~# zpool status pool: tank state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM tank ONLINE 0 0 0 mirror-0 ONLINE 0 0 0 sda3 ONLINE 0 0 0 sdc3 ONLINE 0 0 0 errors: No known data errors root@ok-pc-01:~#
See zfs