LVM-based 3-tier storage management for Doh with automatic PV discovery, guided tier assignment, and bcache acceleration.
The Storage Manager uses LVM Physical Volumes organized into 3 volume groups to create a flexible and powerful storage architecture.
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Tier 0 Cache │ │ Tier 1 Archive │ │ Tier 2 Backup │
│ (vg_cache) │ │ (vg_archive) │ │ (vg_backup) │
├─────────────────┤ ├─────────────────┤ ├─────────────────┤
│ • Fast SSDs │ ──>│ • Primary Data │ ──>│ • Large HDDs │
│ • bcache cache │ │ • LVM Pool │ │ • Backup Mirror │
│ • 50-500GB │ │ • Expandable │ │ • ≥ Archive Size│
└─────────────────┘ └─────────────────┘ └─────────────────┘
The Storage Manager uses an intelligent workflow system that:
.doh/static/storage.pod.yaml under storage_state.doh storage status displays complete workflow progress with timestamps.The system tracks these workflow states:
| State | Command | Description |
|---|---|---|
deps_installed |
doh storage deps |
System dependencies installed |
prepare_run |
doh storage prepare |
Drive analysis completed |
init_run |
doh storage init |
LVM PV assignment completed |
setup_run |
doh storage setup |
Storage system implemented |
The commands follow a strict dependency chain to ensure a successful setup:
deps → prepare → init → setup
The storage manager requires the following system tools. These can be installed easily with the doh storage deps command.
For the best results, use devices that match the role of each tier:
| Tier | Purpose | Devices | Size | Notes |
|---|---|---|---|---|
| 0 | Cache | NVMe, SATA SSD | 50GB-500GB | Fast access, bcache acceleration |
| 1 | Archive | SATA SSD, fast HDD | 500GB-8TB | Primary storage, expandable LVM pool |
| 2 | Backup | Large HDDs | ≥ Archive size | Backup mirror, high capacity |
Follow these steps to configure your storage system from start to finish.
First, install the required system tools. The command will detect your OS and use the appropriate package manager.
doh storage deps
Critical: You must create LVM Physical Volumes on your storage drives before they can be discovered and used by the storage manager.
Use parted or gparted to:
8e).sudo pvcreate /dev/deviceXpY on the partition.Example:
# Create an LVM PV on a new drive
sudo parted /dev/nvme0n1 mklabel gpt
sudo parted /dev/nvme0n1 mkpart primary 0% 100%
sudo parted /dev/nvme0n1 set 1 lvm on
sudo pvcreate /dev/nvme0n1p1
# Repeat for all other drives you intend to use
sudo pvcreate /dev/sda1 # Archive device
sudo pvcreate /dev/sdb1 # Another archive device
sudo pvcreate /dev/sdc1 # Backup device
For more detailed instructions, run doh storage prepare guide.
Once you have created your LVM PVs, run the guided assignment tool. This command will:
vg_cache, vg_archive, vg_backup).doh storage init
When to use: Anytime - before or after doh storage setup. This step is idempotent and can be run multiple times.
By default, storage mounts at /mnt/storage and /mnt/backup, which require sudo access. For user-friendly access, configure mount points in your home directory:
doh storage mount
Smart Behavior:
/media/ by desktop environmentsdoh storage setup next~/storage and ~/backup with proper user permissionsThis command intelligently handles auto-mounted storage issues and can migrate your storage to new mount points even while it's actively in use.
After assigning your PVs to tiers (and optionally configuring mount points), implement the storage system. This creates logical volumes, sets up bcache, formats filesystems, and mounts at the configured locations.
doh storage setup
After this step, your 3-tier storage system will be fully operational.
doh storage deps # Install system dependencies (lvm2, bcache-tools, etc)
doh storage deps --dry-run # Show what would be installed
doh storage prepare # Analyze drives, show tier recommendations, and guide PV creation
doh storage prepare list-all # Show all drives including system drives
doh storage prepare show-lvm # Show detailed LVM analysis and diagnostics
doh storage prepare guide # Detailed LVM PV creation instructions
doh storage init # Guided PV assignment to tiers
doh storage init list-only # Show PV categorization only, without configuration
doh storage init apply # Auto-assign PVs using recommendations
doh storage init --json # Output PV categorization in JSON format
doh storage mount # Configure user-friendly mount points (anytime, idempotent, smart remounting)
doh storage setup # Implement the full storage system
doh storage setup --dry-run # Preview setup operations without making changes
doh storage setup auto # Auto-setup without prompts using current configuration
doh storage setup deps-only # Only install system dependencies
doh storage status # Check system and workflow status
doh storage mount # Change mount points (works on live systems too)
doh storage extend tier1 /dev/sdd1 # Add a new PV to an existing tier
doh storage config show # Display current configuration with workflow status and pod analysis
doh storage config edit # Interactively edit the modernized tier-based configuration
doh storage config set --key <key> --value <value> # Set specific configuration values
doh storage config reset # Reset configuration to modernized defaults
doh storage repair check # Run diagnostics to check for issues
doh storage backup sync # Synchronize primary storage to the backup tier
doh storage backup status # Show backup status and last sync time
doh storage backup restore # Restore from backup (interactive)
doh storage backup verify # Verify backup integrity
doh storage backup perms # Fix backup directory permissions (requires sudo)
The Storage Manager includes a sophisticated server-managed backup system that runs automatically:
storage:
backup_schedule: '0 * * * *' # Cron format (default: hourly)
rsync_options: ['-a', '--delete'] # rsync options for synchronization
rsync_excludes: # Patterns to exclude from backups
- '/cache' # bcache artifacts
- '*.tmp' # Temporary files
- '/lost+found' # Filesystem recovery
backup_timer_state: # Managed automatically - do not edit
last_run: null
next_scheduled: null
missed_windows: 0
max_missed_windows: 2
error_state: false
The backup system initializes automatically when the storage manager loads and continues running in the background, ensuring your data is regularly synchronized to the backup tier.
The storage manager's configuration, including volume group names and device assignments, is stored in /.doh/static/storage.pod.yaml. This dedicated configuration file is automatically inherited by the main pod.yaml, providing centralized storage management. While you can view the configuration directly, it is strongly recommended to use the CLI tools to modify it.
Default volume groups:
storage:
tier0_volume_group: 'vg_cache' # Cache tier
tier1_volume_group: 'vg_archive' # Archive tier
tier2_volume_group: 'vg_backup' # Backup tier
To modify these or other settings, use doh storage config edit.
# 1. Install system dependencies
doh storage deps
# 2. Analyze drives and get PV creation guidance
doh storage prepare
# 3. Create LVM PVs on your drives (manual step)
sudo pvcreate /dev/nvme0n1p1 # Fast SSD for cache
sudo pvcreate /dev/sda1 # Primary storage
sudo pvcreate /dev/sdb1 # More primary storage
sudo pvcreate /dev/sdc1 # Large backup drive
# 4. Assign PVs to tiers
doh storage init
# 5. Configure user-friendly mount points (optional)
doh storage mount
# 6. Implement the storage system
doh storage setup
# Prepare a new drive as an LVM PV
sudo pvcreate /dev/sdd1
# Extend the archive tier with the new drive
doh storage extend tier1 /dev/sdd1
# Change mount points on a live system
doh storage mount
# The command will:
# 1. Detect current mounts and auto-mounted storage
# 2. Offer user-friendly defaults (~/storage, ~/backup)
# 3. Relocate auto-mounted storage from /media/ paths
# 4. Safely unmount, remount, and set permissions
# 5. Add fstab entries for persistence
# 6. Update storage state for web UI visibility
If your desktop environment auto-mounts storage to /media/username/, the mount command will automatically detect and relocate it:
# Detect and fix auto-mounted storage
doh storage mount
# Example output:
# 🔍 Auto-Mount Detection Results:
# Backup storage found: /dev/mapper/vg_backup-lv_backup
# Currently at: /media/username/backup_volume
# Will move to: ~/backup
# Archive storage found: /dev/mapper/vg_archive-lv_archive
# Currently at: /media/username/archive_volume
# Will move to: ~/storage
# Overall system and workflow status
doh storage status
# Detailed LVM information
sudo vgdisplay
sudo pvdisplay
If you encounter an error about a step not being complete, check the workflow status.
# Check workflow status
doh storage status
This will show which steps are complete and which need to be run.
If doh storage init finds no PVs, verify that they exist and are correctly configured.
# Check if PVs exist on the system
sudo pvdisplay
# Check for LVM signatures on a specific device
sudo blkid /dev/deviceXpY
# If missing, create the PV
sudo pvcreate /dev/deviceXpY
If you see permission errors, ensure LVM tools are installed and you have sudo access.
# Check sudo access works
sudo vgs
# Fix backup directory permissions if needed
doh storage backup perms
If your storage appears and disappears depending on access method, or if files seem missing:
# Check for auto-mounted storage
doh storage mount
# This will detect if your storage was auto-mounted to /media/ paths
# and relocate it to your configured mount points
If storage doesn't appear in the web interface:
# Check storage state
doh storage status
# Update storage state for web UI
doh storage mount # This updates state automatically
The storage manager includes advanced monitoring capabilities:
The system provides intelligent growth recommendations:
# Check tier growth capabilities
doh storage status
# Get detailed usage recommendations
doh storage extend tier1 --dry-run # Preview expansion
--dry-run) where available to preview changes./dev/sdX) carefully before running commands to avoid data loss.The Storage Manager has been refactored with a centralized architecture to eliminate code duplication and improve reliability:
User Management
getUserInfo(): Gets current user permissions and identitysetDirectoryPermissions(): Sets permissions without recursive operations that can hangcreateMountDirectory(): Creates directories with proper ownershipMount Operations
isMounted(): Checks if a path is currently mountedgetMountedDevice(): Gets the device mounted at a specific pathunmountPath(): Safely unmounts with lazy fallback for busy filesystemsmountDevice(): Mounts devices with automatic permission settingaddToFstab(): Adds persistent mount entriesAuto-Mount Management
detectAutoMounts(): Discovers storage auto-mounted by desktop environmentsrelocateAutoMounts(): Moves auto-mounted storage to proper configured pathsAll storage state is centrally managed and synchronized with the web UI through:
updateStorageState(): Updates storage visibility and status for web interfacegetStorageState(): Retrieves current workflow and mount state/.doh/static/storage.pod.yaml