La interfaz está localizada; las descripciones y documentos de las Skills se traducen automáticamente con IA a su idioma. El código, los comandos, rutas y términos técnicos se mantienen en el original, y prevalece el documento del autor.
name: storage-architecture
description: Designs and implements Linux storage architectures for cloud block storage
and on-prem SAN/NAS with performance and durability guarantees.
license: MIT
compatibility: opencode
metadata:
version: "1.0.0"
domain: linux
role: implementation
scope: implementation
output-format: code
content-types:
Storage engineer designing and implementing Linux storage architectures for cloud block storage and on-prem SAN/NAS, selecting appropriate filesystems, configuring LVM, optimizing mount options, and monitoring storage health for performance and durability.
TL;DR Checklist
Select filesystem based on workload requirements (XFS for large files, ext4 for compatibility, btrfs for snapshots)
Configure LVM volumes with appropriate PE size, striping, and mirroring
Apply mount options optimized for the workload type (noatime, nodiratime, barrier settings)
Enable TRIM/discard for SSD/NVMe storage and configure periodic fstrim
Set up storage monitoring for IOPS, throughput, latency, and capacity
Configure cloud block storage with appropriate IOPS and throughput profiles
Implement backup strategy with filesystem-appropriate tools (xfsdump, e2backup, btrfs send/receive)
Validate storage performance with fio benchmarks before production deployment
When to Use
Use this skill when:
Designing storage layout — You're planning the storage architecture for a new system and need to select filesystems, LVM layout, and mount options
Optimizing storage performance — Existing storage is a bottleneck and needs tuning (mount options, I/O scheduler, filesystem parameters)
Migrating storage — You're migrating data between filesystems, storage types, or cloud providers and need the right tools
Use hardware-provisioning when selecting the underlying storage hardware (SSD, NVMe, HDD) before filesystem configuration. Use kernel-tuning for I/O scheduler and kernel storage parameters.
Core Workflow
1. Select Filesystem Based on Workload
Match filesystem characteristics to workload requirements.
Filesystem Max File Max FS Journaling Snapshots Compression Best For
─────────────────────────────────────────────────────────────────────────────────────
ext4 50 TB 1 EB Yes No No General purpose, compatibility
XFS 8 EB 8 EB Yes No* No Large files, high throughput
btrfs 16 EB 16 EB Yes (cow) Yes Yes (flex) Snapshots, compression, RAID
ZFS 16 EB 256 ZB Yes (cow) Yes Yes Data integrity, pools
tmpfs RAM RAM No No No In-memory cache
*XFS supports subvolume-like features with project quotas but not true snapshots.
# Check current filesystem types
findmnt -T / -o SOURCE,FSTYPE,SIZE,USE%
# Create filesystem with workload-appropriate options
# XFS for high-throughput workloads
sudo mkfs.xfs -f -L datapool /dev/vdb
# ext4 for general purpose
sudo mkfs.ext4 -L datapool /dev/vdb
# btrfs for snapshot-enabled storage
sudo mkfs.btrfs -L datapool /dev/vdb
Checkpoint: Filesystem type matches workload requirements. Labels are set for easy identification.
2. Configure LVM Layout
Set up LVM for flexible volume management.
# Create physical volume on block device
sudo pvcreate /dev/vdb
# Create volume group with appropriate PE (Physical Extent) size
# Default PE=4MB; use larger PE (16MB-64MB) for large volumes to reduce metadata overhead
sudo vgcreate vg-data /dev/vdb
sudo vgdisplay vg-data | grep "PE Size"
# Create logical volumes
# Database volume: 100GB, thin-provisioned
sudo lvcreate -L 100G -n db-data vg-data
sudo lvcreate --name db-meta --size 2G --type raid1 -m 1 vg-data
# Application volume: thin-pooled with overcommit
sudo lvcreate -L 20G -n db-pool vg-data
sudo lvcreate -V 500G --thinpool db-thinpool vg-data
sudo lvcreate -V 50G --thinpool db-thinpool --name app1 vg-data
# Create filesystems on LVs
sudo mkfs.xfs /dev/vg-data/db-data
sudo mkfs.ext4 /dev/vg-data/db-meta
# Add to fstab
echo '/dev/vg-data/db-data /data/db xfs defaults,noatime,nodiratime 0 2' | sudo tee -a /etc/fstab
echo '/dev/vg-data/db-meta /data/meta ext4 defaults,noatime 0 2' | sudo tee -a /etc/fstab
# Mount and verify
sudo mkdir -p /data/{db,meta}
sudo mount -a
df -h /data/{db,meta}
Checkpoint: LVM hierarchy is created (PV → VG → LV), filesystems are formatted and mounted, and fstab entries are correct.
3. Configure Mount Options
Apply workload-optimized mount options.
# Mount options by workload type:
#
# General purpose:
# defaults,noatime,nodiratime,relatime
#
# Database (XFS):
# defaults,noatime,nodiratime,logbsize=256k,allocsize=256k,inode64
#
# Database (ext4):
# defaults,noatime,nodiratime,data=ordered,journal_data_writeback
#
# Web server (XFS):
# defaults,noatime,nodiratime,inode64,allocsize=64k
#
# NVMe storage:
# defaults,noatime,nodiratime,discard=once,nobarrier
#
# SSD optimization:
# defaults,noatime,nodiratime,discard=async
# Example: Database mount with optimized options
sudo mkdir -p /data/db
sudo mount -o defaults,noatime,nodiratime,logbsize=256k,inode64 /dev/vg-data/db-data /data/db
# Verify mount options
findmnt /data/db
mount | grep /data/db
# Make persistent in /etc/fstab
echo '/dev/vg-data/db-data /data/db xfs defaults,noatime,nodiratime,logbsize=256k,inode64 0 2' | sudo tee -a /etc/fstab
Checkpoint: Mount options are applied and verified. /etc/fstab entries persist across reboots.
4. Configure SSD/NVMe Optimization
Enable TRIM and optimize for solid-state storage.
# Check if device is SSD (rotational=0 = SSD)
cat /sys/block/vdb/queue/rotational # 0 = SSD, 1 = HDD
# Enable TRIM (discard) on mount
# once: discard at mount time only (faster)
# async: background discard (best for performance)
sudo mount -o remount,discard=async /data/db
# Verify fstrim support
sudo fstrim -v /data/db
# Configure periodic fstrim via systemd timer
sudo systemctl enable --now fstrim.timer
# Verify timer is active
sudo systemctl list-timers fstrim.timer
# For NVMe, additional optimizations
echo "none" | sudo tee /sys/block/nvme0n1/queue/scheduler
echo 1024 | sudo tee /sys/block/nvme0n1/queue/nr_requests
blockdev --setra 4096 /dev/nvme0n1 # 2MB read-ahead
# Persistent NVMe udev rules
cat > /etc/udev/rules.d/60-nvme-tuning.rules << 'UDEV'
# Set I/O scheduler for NVMe devices
ACTION=="add|change", KERNEL=="nvme[0-9]*n[0-9]*", ATTR{queue/scheduler}="none"
# Set read-ahead for NVMe
ACTION=="add|change", KERNEL=="nvme[0-9]*n[0-9]*", ATTR{queue/read_ahead_kb}="2048"
# Set queue depth
ACTION=="add|change", KERNEL=="nvme[0-9]*n[0-9]*", ATTR{queue/nr_requests}="1024"
UDEV
Checkpoint: TRIM is enabled, periodic fstrim is running, NVMe scheduler is set to none/mq-deadline, and read-ahead is optimized.
5. Configure Cloud Block Storage
Set up cloud block storage with appropriate performance profiles.
# AWS EBS optimization
# Set I/O scheduler to none/mq-deadline for EBS (already optimized by hypervisor)
echo "mq-deadline" | sudo tee /sys/block/nvme1n1/queue/scheduler
# Enable write caching if EBS has battery-backed cache
sudo hdparm -W1 /dev/nvme1n1 # Enable write cache (only if backed by UPS/BBU)
# Configure EBS-optimized instance (AWS specific)
# This is done at instance launch, but verify:
aws ec2 describe-instance-attribute \
--instance-id i-0abc123 \
--attribute ebsOptimized
# GCP Persistent Disk optimization
# Set I/O scheduler for pd-ssd
echo "none" | sudo tee /sys/block/sdb/queue/scheduler
# Set multi-queue for NVMe
echo "16" | sudo tee /sys/block/nvme1n1/queue/nr_requests
# Azure Managed Disk optimization
# Azure disks are already NVMe-backed; use mq-deadline
echo "mq-deadline" | sudo tee /sys/block/sdc/queue/scheduler
Checkpoint: Backup procedures are configured and tested. Retention policy is documented. Restores are verified periodically.
Implementation Patterns
Pattern 1: Filesystem Selection (BAD vs. GOOD)
BAD — Default filesystem without workload analysis
# ❌ BAD: Using mkfs.ext4 on everything
sudo mkfs.ext4 /dev/vdb
sudo mkfs.ext4 /dev/vdc
sudo mkfs.ext4 /dev/vdd
# Problems:
# - ext4 has overhead for large files (>50GB files have performance issues)
# - No built-in compression to save storage costs
# - No snapshot capability for backup
# - Default journaling mode can cause write amplification on databases
# - 50TB max file size limit
# ❌ BAD: Using btrfs for write-heavy databases
sudo mkfs.btrfs /dev/vdb
# Problems:
# - Copy-on-write adds write overhead for sequential writes
# - Database engines do their own caching and I/O optimization
# - COW conflicts with database write patterns
GOOD — Filesystem matched to workload
# ✅ GOOD: XFS for database (large files, high throughput)
sudo mkfs.xfs -f -L db-data -d agcount=32 /dev/vdb
# agcount=32: 32 allocation groups for parallel I/O on large volumes
# -L db-data: label for easy identification
# ✅ GOOD: ext4 for general application data
sudo mkfs.ext4 -L app-data -E lazy_itable_init=0,lazy_journal_init=0 /dev/vdb
# lazy_itable_init=0: Initialize inode table at format time (faster first mount)
# lazy_journal_init=0: Initialize journal at format time (faster first mount)
# ✅ GOOD: btrfs for shared storage with snapshots
sudo mkfs.btrfs -L shared-data /dev/vdb
# Supports snapshots, compression, and subvolumes natively
# Ideal for VM storage, shared data, and backup targets
# ✅ GOOD: tmpfs for application cache
sudo mkdir -p /var/cache/app
echo 'tmpfs /var/cache/app tmpfs size=4G,noatime,mode=1777 0 0' | sudo tee -a /etc/fstab
sudo mount /var/cache/app
Pattern 2: LVM Configuration for Database
# LVM layout for database workload
#
# Physical Volumes: x 4 NVMe SSDs
# Volume Group: vg-db
# Logical Volumes:
# db-data: 200GB (RAID1 mirror) — data files
# db-wal: 50GB (RAID1 mirror) — write-ahead log
# db-index: 100GB (RAID1 mirror) — index files
# db-backup: 500GB (thin pool) — backup snapshots
# Create PVs
sudo pvcreate /dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1
# Create VG with large PE for big volumes
sudo vgcreate -s 64M vg-db /dev/nvme0n1 /dev/nvme1n1 /dev/nvme2n1 /dev/nvme3n1
# Create mirrored data volume (RAID1 for durability)
sudo lvcreate -L 200G -m 1 -n db-data vg-db
# Create mirrored WAL volume (RAID1 for fast writes)
sudo lvcreate -L 50G -m 1 -n db-wal vg-db
# Create mirrored index volume
sudo lvcreate -L 100G -m 1 -n db-index vg-db
# Format with XFS (optimized for databases)
sudo mkfs.xfs -f -L db-data -d agcount=16 /dev/vg-db/db-data
sudo mkfs.xfs -f -L db-wal -d agcount=4 /dev/vg-db/db-wal
sudo mkfs.xfs -f -L db-index /dev/vg-db/db-index
# Mount with database-optimized options
sudo mount -o defaults,noatime,nodiratime,logbsize=256k,allocsize=256k \
/dev/vg-db/db-data /var/lib/postgresql/data
sudo mount -o defaults,noatime,nodiratime,logbsize=256k,allocsize=256k \
/dev/vg-db/db-wal /var/lib/postgresql/wal
sudo mount -o defaults,noatime,nodiratime,logbsize=256k,allocsize=256k \
/dev/vg-db/db-index /var/lib/postgresql/index
Pattern 3: Storage Performance Benchmarking with fio
Bash — Run fio benchmark profiles for storage validation
MUST select filesystem based on workload requirements — XFS for large files/high throughput, ext4 for compatibility, btrfs for snapshots/compression
MUST set appropriate PE size for LVM volume groups — 4MB default is wasteful for large volumes; use 16-64MB for TB-scale storage
MUST use noatime and nodiratime mount options for all performance-sensitive mounts — eliminates unnecessary metadata writes
MUST enable TRIM/discard on all SSD/NVMe mounts — either discard=async on mount or fstrim.timer for periodic TRIM
MUST monitor disk usage and inode usage with alerting — capacity exhaustion is a leading cause of production incidents
MUST verify SMART health on all storage devices and set up alerting for predictive failure
MUST test restores from backups periodically — an untested backup is not a backup
MUST set I/O scheduler to mq-deadline for SSD/NVMe or none for NVMe — BFQ is appropriate only for HDDs with mixed workloads
MUST NOT DO
MUST NOT use ext4 for databases with files larger than 50GB — ext4 has known performance degradation with large files; use XFS instead
MUST NOT use btrfs for write-heavy database workloads — copy-on-write adds significant write amplification for sequential writes
MUST NOT use the same filesystem for all storage without analysis — different workloads have different filesystem requirements
MUST NOT format all partitions to the same filesystem type without workload analysis — this is a common but suboptimal pattern
MUST NOT rely on hardware RAID without filesystem-level monitoring — RAID controllers can fail silently; SMART and filesystem checks provide independent verification
MUST NOT enable discard on cloud block storage without provider support — some cloud providers don't support TRIM on EBS/Managed Disks and may have performance penalties
MUST NOT use LVM thin provisioning for databases without monitoring — thin pool exhaustion causes data loss; always monitor thin pool usage
Related Skills
Skill
Purpose
hardware-provisioning
Select appropriate storage hardware (SSD, NVMe, HDD) for the workload
resource-management
Set I/O limits on LVM volumes with cgroups to prevent resource starvation
kernel-tuning
Tune I/O scheduler and kernel storage parameters for optimal performance
linux-security
Secure storage with encryption (LUKS) and access controls
observability
Monitor storage I/O, latency, and capacity for proactive management
Live References
Authoritative documentation links for this skill's domain. The model follows markdown links at load time to resolve external references and inline content.