🧠 PVE Disk Cache Cheat Sheet
| VM Type / Workload | Recommended Cache Mode | Why | Notes |
|---|---|---|---|
| Windows VM (general desktop, small random I/O) | writeback |
Better write performance; Windows often has less efficient disk caching | Slightly higher risk of data loss if host crashes; good with UPS; add iothread=1 and discard=on for SSDs |
| Linux VM (server workloads, ext4/XFS/ZFS) | none |
Bypasses host cache, Linux handles caching itself efficiently | Slightly lower write performance than writeback, safer for integrity; add discard=on for SSDs |
| Linux VM (high-performance DB, heavy writes, sync important) | writeback or directsync |
Improves throughput while maintaining some safety | directsync safer for transactional DBs; writeback for analytical workloads; always use UPS |
| VM with mostly read workloads | none or directsync |
Avoids double caching; minimal performance impact for reads | Almost same performance as writeback for reads; much safer; add discard=on for SSDs |
| Mixed workloads on SSD/NVMe | writeback with iothread |
Maximizes performance on fast storage | iothread helps NVMe most, but also useful for fast SSDs; always use discard=on |
| Critical Data VM (business essential, cannot lose data) | none or writethrough |
Maximum data integrity and safety | writethrough provides read caching with write safety; performance secondary to reliability |
| Development/Test VM (disposable or frequently backed up) | writeback or unsafe |
Maximum performance for testing | unsafe only for truly disposable data; regular backups recommended for writeback |
⚙️ Essential Parameters for All Configurations
- SSD/NVMe: Always add
discard=on(enables TRIM) - Performance: Always add
iothread=1for virtio-scsi disks - Safety: Use UPS, especially with
writebackorunsafemodes
🧩 Quick Cache Mode Reference
| Cache Mode | Description | Safety | Performance |
|---|---|---|---|
none |
Direct disk access, bypasses host cache | 🔒 Highest | ⚙️ Moderate |
writethrough |
Safe writes + read caching | 🔒 High | ⚙️ Moderate |
directsync |
Sync writes direct to disk | 🔒 High | ⚙️ Moderate |
writeback |
Host page cache, delayed flush | ⚠️ Medium | 🚀 High |
unsafe |
No sync flush, full cache | ❌ Very low | ⚡ Maximum |
💡 Notes for ZFS/Btrfs Users
If your Proxmox storage backend uses ZFS or Btrfs, the cache parameter has minimal effect since these filesystems manage caching internally.
However, cache=none is still the safest and most compatible choice.
✅ Summary
- Use
writebackfor performance-sensitive Windows or test workloads. - Use
noneorwritethroughfor critical data and Linux servers. - Always enable
discard=onfor SSD/NVMe. - Always use
iothread=1on high-speed storage. - Protect with UPS if using
writebackorunsafe.
examples
- Windows VM
qm set 101 -scsi1 /dev/nvme0n1p2,cache=writeback,discard=on,iothread=1
- Linux VM
qm set 102 -scsi1 /dev/nvme0n1p3,cache=none,discard=on,iothread=1
评论区