Linux bcache SSD Caching Setup Prompt
Design a bcache SSD-in-front-of-HDD caching tier with the right cache mode, write policy, and sequential-bypass tuning, and plan the attach/detach and failure behavior so a cache device loss never means data loss.
- Target user
- Linux sysadmins building hybrid SSD/HDD storage tiers
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a senior Linux storage engineer who builds bcache hybrid tiers (fast SSD caching a slow backing device) for production workloads. I will provide: - The backing device(s) and cache device (model, size, endurance) and their current contents - The workload: random-read-heavy DB, write-heavy log store, mixed VM images, etc. - Redundancy context (is the backing device on RAID, is the SSD single or mirrored) - Distro/kernel and whether bcache is already in use Your job: 1. **Confirm bcache fits.** bcache accelerates random I/O to a slow backing device; it does little for already-fast or purely-sequential workloads. If the workload is sequential ETL or the backing store is already NVMe, say so and recommend against it. 2. **Choose the cache mode with eyes open.** `writethrough` (safe: writes hit backing before ack, cache loss is harmless) vs `writeback` (fast writes, but a cache-device failure can lose un-flushed data unless the SSD is itself redundant) vs `writearound`/`none`. Recommend based on the redundancy of the cache device and the workload's write pattern, and make the durability trade-off explicit. 3. **Plan the device setup.** Give the `make-bcache` sequence to format backing + cache and attach them, the fact that formatting is DESTRUCTIVE and (for an existing filesystem) requires migration since bcache changes the on-disk superblock, and how to bring it up on boot (udev, bcache-tools). 4. **Tune for the workload.** Set `sequential_cutoff` (bypass large sequential I/O so it doesn't evict hot random data), `writeback_percent`, and congestion thresholds; explain `cache_mode`, and how to warm the cache. Note that defaults deliberately bypass sequential I/O. 5. **Protect endurance and health.** For writeback on a consumer SSD, project write amplification against the SSD's TBW; recommend monitoring `/sys/block/bcache0/bcache/` stats (cache hit ratio, dirty data) and SSD wear. 6. **Design failure and teardown.** Explain what happens if the cache device dies in each mode, how to safely detach (`echo 1 > .../detach` and flush dirty data first in writeback), and how to cleanly remove bcache and return to the bare backing device. Output as: a fit assessment, a recommended cache mode with the durability trade-off stated, the exact setup commands labeled DESTRUCTIVE where they are, tuning values for the workload, and a failure/detach runbook. Default to caution: recommend writethrough unless the cache SSD is redundant AND the workload clearly needs writeback, because writeback cache loss can mean data loss.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
bcache can turn a slow HDD array into something usable, but the writeback mode that makes it fast is also the one that can lose data if the cache SSD dies. This prompt ties the mode choice to the cache device’s redundancy, states the durability trade-off plainly, and includes the detach/failure runbook people skip.
How to use it
- Be honest about the workload — bcache does little for sequential or already-fast storage.
- State whether the cache SSD is redundant; it decides writethrough vs writeback.
- Keep the failure/detach runbook attached to the host’s docs.
Useful commands
# Format backing + cache and register (DESTRUCTIVE to both devices)
sudo make-bcache -B /dev/sdb # slow backing device
sudo make-bcache -C /dev/nvme0n1 # fast cache device
sudo bcache-super-show /dev/nvme0n1 # grab the cache set UUID
# Attach cache to the backing bcache device
echo <cset-uuid> | sudo tee /sys/block/bcache0/bcache/attach
# Choose a safe default mode and tune sequential bypass
echo writethrough | sudo tee /sys/block/bcache0/bcache/cache_mode
cat /sys/block/bcache0/bcache/sequential_cutoff
# Watch effectiveness and dirty data
cat /sys/block/bcache0/bcache/stats_total/cache_hit_ratio
cat /sys/block/bcache0/bcache/dirty_data Related prompts
-
Linux nvme-cli SSD Health Management Prompt
Interpret nvme-cli smart-log, error-log, and self-test output to decide whether an NVMe drive is healthy, wearing out, thermally throttling, or in pre-failure, and plan namespace, firmware, and format actions safely.
-
Linux fstrim & SSD Discard Maintenance Prompt
Set up correct TRIM/discard for SSDs and thin-provisioned storage on Linux — periodic fstrim vs continuous discard — across LVM, LUKS, and dm-crypt stacks without hurting performance.
-
Linux fio Storage Benchmark Design Prompt
Design fio job files that model your real workload (block size, queue depth, read/write mix, fsync policy) and interpret IOPS, throughput, and latency percentiles without fooling yourself with cache or preconditioning artifacts.
-
rsync Large-Dataset Migration & Verification Prompt
Plan, tune, and verify a large rsync data migration (terabytes / millions of files) — pick the right flags, avoid resync churn, throttle load, and prove the copy is byte-correct before cutover.
More Linux Admins prompts & error guides
Browse every Linux Admins prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.