ZFS

From Indie IT Wiki
Jump to: navigation, search

Introduction

http://www.howtogeek.com/175159/an-introduction-to-the-z-file-system-zfs-for-linux/

https://wiki.gentoo.org/wiki/ZFS

https://wiki.archlinux.org/index.php/ZFS

Usage

https://wiki.ubuntu.com/Kernel/Reference/ZFS

Installation

sudo apt-get install zfsutils-linux

Pools

https://wiki.ubuntu.com/ZFS/ZPool

Create the root storage directory for the pools...

sudo mkdir /zfs

Create the mirror (raid1) zpool...

sudo zpool create -f -m /zfs/zpool1 zpool1 mirror /dev/sdb /dev/sdc

Check...

sudo zpool list

NAME     SIZE  ALLOC   FREE  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
zpool1  1008M   368K  1008M         -     1%     0%  1.00x  ONLINE  -
sudo zpool status

pool: zpool1
state: ONLINE
scan: scrub repaired 0 in 0h0m with 0 errors on Wed Jun  8 13:55:46 2016
config:
       NAME        STATE     READ WRITE CKSUM
       zpool1      ONLINE       0     0     0
         mirror-0  ONLINE       0     0     0
           sdb     ONLINE       0     0     0
           sdc     ONLINE       0     0     0
errors: No known data errors
sudo zpool iostat zpool1

              capacity     operations    bandwidth
pool        alloc   free   read  write   read  write
----------  -----  -----  -----  -----  -----  -----
zpool1       151G  3.48T      0     63    285  6.28M
sudo tree /zfs

/zfs/
└── zpool1

Increase Storage Space

If you have a mirror (raid1) pool, you have to add disks in pairs.

Here, we add 2 more drives to the existing pool and double the size of the storage space available...

sudo zpool add -f zpool1 mirror /dev/sdd /dev/sde

Now, check the size of the pool...

sudo zpool list

Datasets

http://wiki.nas4free.org/doku.php?id=zfs:dataset

Create a dataset for Documents...

sudo zfs create zpool1/Documents

Check...

sudo zfs list
NAME               USED  AVAIL  REFER  MOUNTPOINT
zpool1             154K   976M    19K  /zfs/zpool1
zpool1/Documents    19K   976M    19K  /zfs/zpool1/Documents

If you want to, set a quota limit of 100Mb...

sudo zfs set quota=100M zpool1/Documents

sudo zfs list
NAME               USED  AVAIL  REFER  MOUNTPOINT
zpool1             155K   976M    19K  /zfs/zpool1
zpool1/Documents    19K   100M    19K  /zfs/zpool1/Documents

Now, you can create datasets for the other main directories...

sudo zfs create zpool1/Music
sudo zfs create zpool1/Pictures
sudo zfs create zpool1/Videos
sudo zfs list
NAME               USED  AVAIL  REFER  MOUNTPOINT
zpool1             227K   976M    19K  /zfs/zpool1
zpool1/Documents    19K   100M    19K  /zfs/zpool1/Documents
zpool1/Music        19K   976M    19K  /zfs/zpool1/Music
zpool1/Pictures     19K   976M    19K  /zfs/zpool1/Pictures
zpool1/Videos       19K   976M    19K  /zfs/zpool1/Videos
sudo tree /zfs/
/zfs/
└── zpool1
    ├── Documents
    ├── Music
    ├── Pictures
    └── Videos

Tutorial

https://fitzberg.ghost.io/zfs-tutorial-part-1/

Replace A Disk

https://forum.proxmox.com/threads/disk-replacement-procedure-for-a-zfs-raid-1-install.21356/#post-133719

Increase Storage By Replacing Disks With Larger Disks

https://www.dan.me.uk/blog/2012/11/14/increase-capacity-of-freebsd-zfs-array-by-replacing-disks/