This toolkit provides a collection of modular scripts to manage ZFS pools with DigitalOcean block storage volumes. The scripts are designed to be simple, modular, and reusable.
The toolkit consists of:
- A main script that orchestrates the entire workflow
- Individual micro-scripts that each handle a specific task
- A setup script to make sure everything is ready to run
- A DigitalOcean droplet
- Root access
- DigitalOcean API token with read/write permissions (to create new volumes)
- Clone or download this repository to your DigitalOcean droplet
- Run the setup script to make all component scripts executable and check for required dependencies:
sudo ./setup.sh
- Set your DigitalOcean API token if you plan to create new volumes:
export DO_API_TOKEN=your_token_here
Execute the main script:
sudo ./main.sh
Optionally, you can specify a custom pool name:
sudo ./main.sh --poolname mypool
The toolkit includes the following micro-scripts:
Script | Description |
---|---|
terraform_list_volumes.sh |
Lists all DigitalOcean volumes in a specific region |
terraform_get_droplet_metadata.sh |
Retrieves metadata about the current DigitalOcean droplet |
zfs_list_disks.sh |
Lists all disks used by ZFS pools |
summarize_storage.sh |
Displays a summary of ZFS pools and DigitalOcean volumes |
find_new_disks.sh |
Finds new unformatted disks that are not part of any ZFS pool |
terraform_create_new_volume.sh |
Creates a new DigitalOcean volume and attaches it to a droplet |
zfs_create_pool.sh |
Creates a new ZFS pool using the specified disk |
zfs_add_stripe.sh |
Adds a new device as a stripe vdev to an existing ZFS pool |
zfs_add_mirror.sh |
Adds a new device as a mirror to an existing device in a ZFS pool |
speedtest.sh |
Performs a read/write speed test on a ZFS pool |
Each script can be run independently for specific tasks, or together via the main script for a complete workflow.
The main script (main.sh
) provides a guided workflow:
- Collects droplet metadata
- Checks current storage status
- Scans for new disks
- Creates a new volume if no new disks are found
- Offers options to:
- Add the new disk as a stripe to an existing pool (to increase capacity)
- Add the new disk as a mirror to an existing pool (to increase redundancy)
- Create a new pool with the new disk
- Displays updated storage status
- Offers to run a speed test
- Shows ZFS usage examples
sudo ./main.sh --poolname datapool
./terraform_list_volumes.sh
./find_new_disks.sh --largest
./zfs_add_mirror.sh tank /dev/disk/by-id/scsi-0DO_Volume_volume-nyc1-02
./speedtest.sh tank
- All the scripts require root privileges
- The scripts automatically install any missing dependencies
- The main workflow is designed for DigitalOcean, but individual scripts may work on other cloud providers with minimal modifications
- If a script fails, check the error message for details
- Make sure your DigitalOcean API token has the necessary permissions
- Verify that you're running the scripts on a DigitalOcean droplet
- Check that the required dependencies are installed
This toolkit is open-source software licensed under the MIT license.