This guide shows how to run Garage as a systemd service on Linux, providing automatic startup, process management, and system integration.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/deuxfleurs-org/garage/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
Before configuring systemd:- Garage binary installed at
/usr/local/bin/garage - Configuration file at
/etc/garage.toml - Understanding of systemd service management
Configuration Requirements
For systemd’s security features to work correctly, your/etc/garage.toml must use specific paths:
On the host filesystem, Garage data will actually be stored in
/var/lib/private/garage due to systemd’s dynamic user mapping.Creating the Service File
Service Hardening Features
The systemd service file includes several security hardening features:DynamicUser=true
DynamicUser=true
- Garage runs as a dynamically-allocated non-privileged user
- User ID is allocated at service start
- Provides isolation between services
ProtectHome=true
ProtectHome=true
- Blocks access to
/home,/root, and/run/userdirectories - Prevents accidental or malicious access to user data
NoNewPrivileges=true
NoNewPrivileges=true
- Prevents the process from gaining new privileges
- Blocks privilege escalation attempts
StateDirectory=garage
StateDirectory=garage
- Automatically creates
/var/lib/garagedirectory - Sets correct permissions for the dynamic user
- Maps to
/var/lib/private/garageon the host
LimitNOFILE=42000
LimitNOFILE=42000
- Increases the file descriptor limit
- Necessary for handling many simultaneous connections
Starting the Service
Managing the Service
Basic Commands
Viewing Logs
Usejournalctl to view Garage logs:
Customizing the Service
Changing Log Level
Edit the service file to adjust theRUST_LOG environment variable:
error: Only errorswarn: Warnings and errorsinfo: Normal operations (default)debug: Detailed debugging informationtrace: Very verbose debugging
Custom Binary Location
If your Garage binary is in a different location:Custom Configuration File
To use a non-default configuration file:Resource Limits
Add additional resource limits:Using with Multiple Nodes
For multi-node deployments, install and configure the systemd service on each node:Configure Each Node
Ensure each node’s
/etc/garage.toml has:- Unique
rpc_public_addr - Same
rpc_secretacross all nodes - Appropriate
metadata_diranddata_dir
Troubleshooting
Service Fails to Start
Check the service status and logs:- Configuration file syntax errors
- Permission issues with data directories
- Port already in use
- Invalid paths in configuration
Permission Denied Errors
If you see permission errors:- Verify paths in
/etc/garage.tomluse/var/lib/garage/ - Remove any existing
/var/lib/garagedirectory: - Restart the service:
Configuration Changes Not Applied
After modifying the service file:Port Conflicts
If ports are already in use, check what’s using them:Alternative: Using with Socket Activation
For advanced use cases, you can configure socket activation:Next Steps
- Configure multi-node cluster with systemd services
- Set up monitoring with systemd integration
- Configure reverse proxy for external access
- Learn about backup strategies for systemd deployments