29 lines
791 B
Bash
Executable File
29 lines
791 B
Bash
Executable File
#!/bin/bash
|
|
# zfs_setup.sh - Create ZFS pool 'tank' on Proxmox host SSDs
|
|
# Adjust device names (/dev/sda /dev/sdb) as appropriate for your hardware.
|
|
|
|
set -euo pipefail
|
|
|
|
POOL_NAME="tank"
|
|
DEVICES=(/dev/sda /dev/sdb)
|
|
|
|
# Check if pool already exists
|
|
if zpool list "$POOL_NAME" >/dev/null 2>&1; then
|
|
echo "ZFS pool '$POOL_NAME' already exists. Exiting."
|
|
exit 0
|
|
fi
|
|
|
|
# Create the pool with RAID-Z (single parity) for redundancy
|
|
zpool create "$POOL_NAME" raidz "${DEVICES[0]}" "${DEVICES[1]}"
|
|
|
|
# Enable compression for better space efficiency
|
|
zfs set compression=on "$POOL_NAME"
|
|
|
|
# Create a dataset for Docker volumes
|
|
zfs create "$POOL_NAME/docker"
|
|
|
|
# Set appropriate permissions for Docker to use the dataset
|
|
chmod 777 "/$POOL_NAME/docker"
|
|
|
|
echo "ZFS pool '$POOL_NAME' created and configured."
|