blackhole is a Linux FUSE filesystem overlay that gives you immutable
reads and zero-persistence writes.
- Reads come from a configured source (or optional override source).
- Writes appear successful to callers but are discarded (blackholed), depending on mode.
- Can run in foreground or be registered as a systemd user service.
blackhole supports two mount modes:
-
Directory mode (
mount dir)- Mount a directory view backed by
--source-dir - Optional
--override-dirtakes precedence per relative path - Writes/truncates are discarded
- create/mkdir/unlink/rmdir are synthetic/ephemeral (in-memory only)
- Mount a directory view backed by
-
Single-file mode (
mount file)- Mount at the target file’s parent directory and blackhole only the target file path
- Optional
--override-filereplaces reads for the target file - Sibling files in the same directory are passthrough to the real filesystem
- Linux
- Python 3.13+
- FUSE userspace support (
fusepyis used by the package) - For service workflows:
systemd --userandfusermount3
uv sync
uv pip install -e .pip install .After installation, the CLI entrypoint is:
blackholeblackhole mount file --target <file> [--override-file <file>] [--persistent] [--service-name <name>]
blackhole mount dir --mount-point <dir> --source-dir <dir> [--override-dir <dir>] [--persistent] [--service-name <name>]
blackhole install-service
blackhole unmount <name>--service-namerequires--persistent.- Paths are resolved to absolute paths.
- Legacy mount flags are rejected by the parser.
blackhole mount dir \
--mount-point /tmp/mnt \
--source-dir /srv/dataBehavior:
- Reading
/tmp/mnt/file.txtreads from/srv/data/file.txt - Writing
/tmp/mnt/file.txtreports success but does not modify/srv/data/file.txt
blackhole mount dir \
--mount-point /tmp/mnt \
--source-dir /srv/data \
--override-dir /srv/overrideBehavior:
- If
/srv/override/path/to/xexists, reads use it - Otherwise reads fall back to
/srv/data/path/to/x
blackhole mount file --target /tmp/mnt/target.txtBehavior:
/tmp/mnt/target.txtis blackholed for writes- Other files in
/tmp/mntare passthrough and can be modified normally
blackhole mount file \
--target /tmp/mnt/target.txt \
--override-file /tmp/source.txtBehavior:
- Reads of
target.txtcome from/tmp/source.txt - Writes to
target.txtare discarded - Override file is not mutated by writes through mount
Persistent mode registers a blackhole@.service user unit instance and exits.
blackhole install-serviceInstalls to:
~/.config/systemd/user/blackhole@.service
blackhole mount dir \
--mount-point /tmp/mnt \
--source-dir /srv/data \
--persistent \
--service-name my-mountThis writes:
~/.config/blackhole/my-mount.env
Then runs:
systemctl --user enable blackhole@my-mount.servicesystemctl --user start blackhole@my-mount.service
blackhole unmount my-mountThis stops/disables the unit, removes its env file, and daemon-reloads the user manager.
- Directory mode blocks path traversal outside source/override roots.
- Writes/truncates in blackholed paths return success without persistence.
- Synthetic create/mkdir/unlink/rmdir state exists only in memory for the life of the process.
- Mount runs foreground with deterministic options:
foreground=Trueallow_other=Falsenonempty=Truein single-file mode
Structured logs are emitted with format:
%(asctime)s %(levelname)s %(name)s event=%(message)s
Key events include startup mode, service install/register/unmount, mount start/stop, and discarded writes/truncates.
For development setup, test commands, and commit message requirements, see
CONTRIBUTING.md.