Storage & Cache Guard
Monarch separates the operating system disk from bulk VM/media storage while letting you share fast SSDs across both roles.
Disk roles in the installer
On the Storage wizard page (shared/utils/plan.ts), each physical disk is assigned one of four roles:
- System: Holds the EFI system partition, boot partition, and ext4 root (
/). You can allocate the whole disk or a fixed size; the remaining space on an SSD can be carved into cache partitions. - Data volume: An LVM volume group (
vg_<name>) and logical volume (data) supporting:- Single disk
- Linear concatenation
- LVM RAID (
RAID 1,RAID 5,RAID 6, orRAID 10) Mounted at a path of your choice (commonly/home/QEMUfor VM images and ISOs, or a target root for ClyoCloud).
- Cache: An SSD partition placed in front of a data volume via LVM
dm-cache. One SSD can hold multiple independent cache partitions for different volume groups, and can sit alongside the system partition on the same SSD. - Unused: Never partitioned, formatted, or touched.
The layout preview displays the complete chain — disk → partition → VG → LV → cache → mount — along with usable capacity before anything is written.
Cache modes
- Writethrough (default): Writes hit both the cache SSD and the backing HDD array before completing. If the cache SSD dies completely, data on the backing array remains consistent.
- Writeback: Writes are acknowledged once stored on the cache SSD and flushed asynchronously to the backing array. Faster for random writes, but dirty blocks only exist on the SSD until flushed. Selecting writeback in the installer requires an explicit confirmation.
How monarch-cache-guard protects writeback caches
When any volume uses an SSD cache, the installer writes /etc/monarch/cache-guard.enabled and enables monarch-cache-guard.timer.
Every 10 minutes (starting 2 minutes after boot), monarch-cache-guard.sh runs:
- Queries
lvs --reportformat jsonfor every logical volume withsegtype == "cache". - Resolves the underlying physical SSD(s) for each cache volume (
[cache_cvol]or_cdatasub-LV) usinglsblk -no PKNAME. - Runs
smartctl -H -A -jagainst each parent SSD and flagsfailingif:smart_status.passed == false, orsmartctlexit code has bit 3 (disk failing) or bit 4 (prefail attribute <= threshold) set, or- NVMe
critical_warningis non-zero.
- If a failing SSD backs a writeback cache, the guard immediately runs:
lvchange -y --cachemode writethrough <vg/lv>
This forces LVM to flush all dirty blocks from the failing SSD down to the backing origin disks and switches the LV to safe writethrough mode.
5. Writes the current status JSON to /var/lib/monarch/cache-health.json, which monarch-daemon (Modules/Monarch.cs) reads and forwards to Monarch.panel.
Monitoring & notifications
- In
Monarch.panel, failing cache SSDs appear on the node's Storage tab and trigger thecache_degradedalert rule (Discord webhook and mobile notifications). - In
Monarch.android, failing cache SSDs are surfaced on the node detail screen and polled byAlertWorker. - Check guard logs directly on the host with:
journalctl -t monarch-cache-guard
cat /var/lib/monarch/cache-health.json