How Overlay Works
An overlay filesystem combines two layers:- Check delta layer first
- If not found, read from base layer
- Copy file to delta layer (if from base)
- Write changes to delta layer
- Base layer is never modified
- Create a “whiteout” marker in delta layer
- File appears deleted in merged view
- Original file in base layer is untouched
Creating an Overlay Filesystem
With agentfs run
The simplest way - automatically creates an overlay over your current directory:
With agentfs init --base
Create an overlay explicitly:
Viewing Changes
See what’s different from the base:Practical Examples
Safe Refactoring
Let an agent refactor your code without risk:Testing Destructive Operations
Try something dangerous safely:Parallel Experiments
Run multiple experiments on the same codebase:Storage Efficiency
The overlay only stores:- Modified files - Full copy after first write
- New files - Stored entirely in delta
- Deleted files - Small whiteout marker
Technical Details
File Operations
| Operation | Behavior |
|---|---|
| Read existing file | Pass through to base |
| Write existing file | Copy to delta, then write |
| Create new file | Write directly to delta |
| Delete file | Create whiteout in delta |
| Rename file | Delete old + create new |