scottmuc / infrastructure

Documentation / Automation for personal third-party infrastructure
The Unlicense
11 stars 2 forks source link

Building a FreeBSD / ZSF NAS #78

Open scottmuc opened 4 months ago

scottmuc commented 4 months ago

Objective

To manage my storage with great tools and to enjoy the maintenance of a self-managed appliance.

Resources

Reference Implementations

scottmuc commented 4 months ago

Using Tests as a Learning Journal

I've been spending time getting acquainted and inspired with ZFS and it's made me realize that it's very important that I develop some confidence with the tool-chain. I thought writing up the scenarios that I'm most intrigued and concerned about would be a lot of fun, and it would result in an artifact I can look back on. So far, the progress looks like this:

~/workspace/infrastructure/devices/erebor ? bin/test
..

Finished in 3.22 seconds (files took 0.0509 seconds to load)
2 examples, 0 failures

Feature: A FreeBSD ZFS NAS
  In order to run and maintain a NAS with some features that important for when
  disaster strikes, I want to document my understand of how failures can be
  recovered from so that when it actually happens, I'm not too stressed.

  Scenario: Replacing a failed drive
    Given a 3 disk raidz1 pool with data
    When one of the disks fail
    And I replace the failed drive
    Then my files are all still available

  Scenario: Adding more disk space

  Scenario: Restoring from a snapshot

3 scenarios (2 undefined, 1 pending)
4 steps (3 skipped, 1 pending)
0m0.006s

It's been a blast to revisit vagrant and cucumber. Now to start fleshing out the step definitions and find what type of fixtures I need to create.

scottmuc commented 4 months ago

Tests Passing

Having the first scenario passing gives me some idea what recovering from a failed drive looks like. Funnily enough, I found a lot of guidance from an Arch Linux docs page. This has given me a positive first impression of ZFS so far.

~/workspace/infrastructure/devices/erebor ? ./bin/test
..

Finished in 3.5 seconds (files took 0.08377 seconds to load)
2 examples, 0 failures

Feature: A FreeBSD ZFS NAS
  In order to run and maintain a NAS with some features that important for when
  disaster strikes, I want to document my understand of how failures can be
  recovered from so that when it actually happens, I'm not too stressed.

  Background:
    Given a 3 disk raidz1 pool
    And it contains some data

  Scenario: Replacing a failed drive
    Given that one of the disks has failed
    When the failed disk is replaced
    Then my files are all still available

  Scenario: Adding more disk space

  Scenario: Restoring from a snapshot

3 scenarios (2 undefined, 1 passed)
5 steps (5 passed)
0m7.920s
scottmuc commented 4 months ago

All Tests Passing

All 3 scenarios that I'm most interested in are passing. Using cucumber was a fun exercise since it's been over a decade since my last time using it. I like that the step definitions have become a bit of a command journal for me to refer to.

Overall this was a delightful experience. ZFS feels good and intuitive to me. The model of having a pool composed of storage providers organized in vdevs. That it's only 2 commands to know (zfs and zpool) makes it approachable. That being said, the resources I listed in the original issue description shows that there are many ways to compose the ZFS primitives together.

Next Steps

Look into what hardware to purchase.

scottmuc commented 2 months ago

Hardware Research

I don't really have a budget figured out. Trying to make this as cheap as possible isn't the goal, but I don't want to spend thousands either. Some of the things decided already:

References