This post isn't meant to be a full how-to like most of my others, but more of a working document for installing and working with ZFSonLinux on CentOS 7. As of today, I've been working with ZFSonLinux for a little over a year and it's been rock solid and quite performant. I'm in the process of rebuilding my HomeLab so I decided to make my notes available on my blog.
While ZFSonLinux can run on many different Linux distributions, I will be focusing only on CentOS 7.
Let's Get Started!
1.) updates and install:
Installing ZFSonLinux is quite simple, thanks to rpm packages and an el7 repo.
yum -y update && systemctl reboot # Update and reboot first, to load any upgraded kernel
yum -y install epel-release
yum localinstall --nogpgcheck http://archive.zfsonlinux.org/epel/zfs-release.el7.noarch.rpm
yum -y install kernel-devel zfs
systemctl reboot
And that's it! You should now be able to create your first ZFS Pool.
2.) create a zfs pool:
ZFS has a few different RAID levels available, such as raidz (RAID 5 equivilant), raidz2 (RAID 6 equivilant), raidz3 (RAID 7.3 eqivilant), and mirror (RAID 1/10 equivilant).
zpool create -f tank raidz /dev/sdb /dev/sdc /dev/sdd -m /mnt/zfs_tank
All we're doing here is running the zpool
command with the create
value to create a new pool. -f
is for force, which will wipe any partitions and/or data from the disks to prepare them to join the pool. tank
is the name on our new pool, and you can use whatever you want. raidz
designates the raid level you want to use, and other options are raidz2
, raidz3
, and mirror
. Next we specify the drives we want to join to the pool (use fdisk -l
or gdisk -l
to find your disks). And finally, we use the -m
switch to designate where we want to mount this pool at, /mnt/zfs_tank
in the example above.
That's all it takes to create a raidz (RAID 5 equivilant) pool containing 3 drives. Those 3 drives will create a vdev, aka Virtual Device. With ZFS, you cannot expand a vdev, so the proper way to add more disks is to add another vdev to the pool, and expand the pool. To add 3 more disks in a new vdev for this pool, try:
zpool add -f tank raidz /dev/sde /dev/sdf /dev/sdg
Now this pool will contain 6 drives, with 2 3-drive vdevs. To view the pool layout, run:
[root@server ~]# zpool status tank
pool: tank
state: ONLINE
scan: scrub repaired 0 in 0h0m with 0 errors on Sun Feb 19 13:21:54 2016
config:
NAME STATE READ WRITE CKSUM
tank_data_01 ONLINE 0 0 0
raidz1-0 ONLINE 0 0 0
sdb ONLINE 0 0 0
sdc ONLINE 0 0 0
sdd ONLINE 0 0 0
raidz1-1 ONLINE 0 0 0
sde ONLINE 0 0 0
sdf ONLINE 0 0 0
sdg ONLINE 0 0 0
errors: No known data errors
Pretty straight-forward.
Let's say we have 6 drives and want to run those in a mirror (RAID 10) setup. We can do this by running:
zpool create -f tank mirror /dev/sdb /dev/sdc mirror /dev/sdd /dev/sde mirror /dev/sdf /dev/sdg -m /mnt/zfs_tank
[root@server ~]# zpool status tank
pool: tank
state: ONLINE
scan: scrub repaired 0 in 0h0m with 0 errors on Sun Feb 19 13:21:54 2016
config:
NAME STATE READ WRITE CKSUM
tank_data_01 ONLINE 0 0 0
mirror-0 ONLINE 0 0 0
sdb ONLINE 0 0 0
sdc ONLINE 0 0 0
mirror-1 ONLINE 0 0 0
sdd ONLINE 0 0 0
sde ONLINE 0 0 0
mirror-2 ONLINE 0 0 0
sdf ONLINE 0 0 0
sdg ONLINE 0 0 0
errors: No known data errors
Easy.
More to come in the future!