Skip to main content

A tool to manage Samba on a ZFS-backed system.

Project description

Samba & ZFS Management Tool

A command-line tool for simplifying Samba share management on ZFS-backed systems.

smb-zfs automates the setup and administration of users, groups, and shares, ensuring Samba and ZFS configurations remain synchronized.

It provides a reliable interface for common administrative tasks through two modes: a standard CLI smb-zfs for scripting and an interactive wizard smb-zfs wizard for guided setup.

$ smb-zfs -h
usage: smb-zfs [-h] [--version] [-v] {wizard,setup,create,modify,delete,list,passwd,remove,get-state} ...

A tool to manage Samba on a ZFS-backed system.

positional arguments:
  {wizard,setup,create,modify,delete,list,passwd,remove,get-state}
                        Available commands
    wizard              Start an interactive wizard for common tasks.
    setup               Set up and configure Samba, ZFS, and Avahi.
    create              Create a new user, share, or group.
    modify              Modify an existing user, share, or group.
    delete              Delete a user, share, or group.
    list                List all managed users, shares, groups or pools.
    passwd              Change a user's Samba password.
    remove              Uninstall smb-zfs and remove all related configurations and data.
    get-state           Print the current state as JSON.

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -v, --verbose         Increase verbosity level (-v for warning, -vv for info, -vvv for debug).

Prerequisites

  • Debian 12 - Bookworm
  • ZFS installed with a pre-existing pool
  • Python 3.11
  • sudo privileges

Installation

Install package:

sudo apt update
sudo apt install -y pipx samba avahi-daemon
sudo PIPX_HOME=/opt/pipx PIPX_BIN_DIR=/usr/local/bin pipx install smb-zfs
echo PIPX_HOME=/opt/pipx >> ~/.bashrc
echo PIPX_BIN_DIR=/usr/local/bin >> ~/.bashrc

Install bash completion:

wget "https://raw.githubusercontent.com/mietzen/smb-zfs/refs/tags/$(smb-zfs -v)/completion/smb-zfs-completion.sh" -O /etc/bash_completion.d/smb-zfs-completion.sh

This makes the smb-zfs command available system-wide.

Quick Start: Use the Wizard for Guided Setup

$ smb-zfs --help
usage: smb-zfs [-h] [--version] [-v] {wizard,setup,create,modify,delete,list,passwd,remove,get-state} ...

A tool to manage Samba on a ZFS-backed system.

positional arguments:
  {wizard,setup,create,modify,delete,list,passwd,remove,get-state}
                        Available commands
    wizard              Start an interactive wizard for common tasks.
    setup               Set up and configure Samba, ZFS, and Avahi.
    create              Create a new user, share, or group.
    modify              Modify an existing user, share, or group.
    delete              Delete a user, share, or group.
    list                List all managed users, shares, groups or pools.
    passwd              Change a user's Samba password.
    remove              Uninstall smb-zfs and remove all related configurations and data.
    get-state           Print the current state as JSON.

options:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  -v, --verbose         Increase verbosity level (-v for warning, -vv for info, -vvv for debug).

Example setup:

$ smb-zfs wizard setup

--- Initial System Setup Wizard ---
Available ZFS pools: data, rpool, tank
Enter the name of the ZFS pool to use: tank
Enter the server's NetBIOS name [nas]:
Enter the workgroup name [WORKGROUP]:
Enable macOS compatibility optimizations? [y/N]  [n]: y
Enter a default quota for user homes (e.g., 10G, optional): 20G

Summary of actions:
 - ZFS Pool: tank
 - Server Name: nas
 - Workgroup: WORKGROUP
 - macOS Optimized: True
 - Default Home Quota: 20G
Proceed with setup? [Y/n]  [y]:

Success: Setup completed successfully.
$ smb-zfs wizard create user

--- Create New User Wizard ---
Enter the new username: nils
Enter password for user 'nils':
Confirm password:
Allow shell access (/bin/bash)? [y/N]  [n]: y
Available groups: smb_users
Enter comma-separated groups to add user to (optional): smb_users

Success: User 'nils' created successfully.
$ smb-zfs wizard create share

--- Create New Share Wizard ---
Enter the name for the new share: media
Enter the ZFS dataset path within the pool (e.g., data/media): media
Enter a comment for the share (optional): Movies, Series, Music, etc.
Available users: nils
Enter the owner for the share's files (default: root):
Available groups: smb_users
Enter the group for the share's files (default: smb_users):
Enter file system permissions for the share root [0775]:
Enter valid users/groups (e.g., @smb_users) [@smb_users]:
Make the share read-only? [y/N]  [n]:
Make the share browseable? [Y/n]  [y]:
Enter a ZFS quota for this share (e.g., 100G, optional): 500G

Success: Share 'media' created successfully.

Advanced CLI usage

All commands must be run with root privileges.

Initial Setup:

sudo smb-zfs install --pool <your-zfs-pool> --default-home-quota 20G

Create a User:

sudo smb-zfs create user john --shell

Create a Share:

# Creates the dataset 'your-zfs-pool/data/media' with a 500G quota
sudo smb-zfs create share media --dataset data/media --quota 500G

Modify a Share's Quota:

sudo smb-zfs modify share media --quota 600G

Update smb-zfs

pipx upgrade smb-zfs

Uninstallation

sudo smb-zfs wizard remove
sudo pipx remove smb-zfs

# Remove apt pkgs
sudo apt remove pipx samba samba-common-bin avahi-daemon

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smb_zfs-0.7.2-py3-none-any.whl (32.3 kB view details)

Uploaded Python 3

File details

Details for the file smb_zfs-0.7.2-py3-none-any.whl.

File metadata

  • Download URL: smb_zfs-0.7.2-py3-none-any.whl
  • Upload date:
  • Size: 32.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for smb_zfs-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0907f878d59f9276f1624392912c94ddbcc3be4121c1b9ef43b2ad62571935cd
MD5 b215b97939c637d45d1676423a816f84
BLAKE2b-256 e7786a762c4968f2dd22344fac3643d89d18b6b31ac4b134955b7c744e73c7a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for smb_zfs-0.7.2-py3-none-any.whl:

Publisher: release.yml on mietzen/smb-zfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page