block-storage – skill DevOps & Hạ tầng cho agent AI
Quản lý volume block storage và LVM. Cấu hình block storage trên cloud và ổ đĩa cục bộ. Dùng khi quản lý lưu trữ đĩa.
Cài skill block-storage bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/block-storage-addd5.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /block-storage – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/block-storage-addd5.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $block-storage – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/block-storage-addd5.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /block-storage – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/block-storage-addd5.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /block-storage – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Block Storage
Manage block storage volumes including LVM, cloud-based EBS, filesystem creation, snapshots, and RAID configurations. Covers the full lifecycle from provisioning raw disks to extending volumes in production.
When to Use
- Adding, partitioning, or formatting new disks on Linux servers
- Managing LVM logical volumes for flexible storage allocation
- Provisioning and attaching cloud block storage (AWS EBS)
- Creating and restoring snapshots for backup or migration
- Configuring software RAID for redundancy or performance
- Extending existing volumes without downtime
Prerequisites
- Root or sudo access on the target system
lvm2package installed for LVM operationsmdadmpackage installed for software RAID- AWS CLI configured for EBS operations
- Understanding of the workload's I/O characteristics (IOPS, throughput)
Destructive operation contract
Examples are alternatives, not one sequential script. Identify devices by stable serial/WWN and current filesystem/mounts, map cloud volume IDs to actual NVMe devices and confirm the exact target before mklabel/wipefs/mkfs/pvcreate/mdadm creation or shrink/remove. Verify an independent tested backup; RAID and snapshots alone are not backups. Quiesce databases/filesystems for application-consistent snapshots and monitor snapshot COW capacity. Read-only mount can still replay a journal; use filesystem-specific no-recovery options when forensic immutability matters. Start filesystem repair with assessment/image capture rather than unattended -y. Validate fstab without overwriting existing entries and test boot recovery. Extend the partition/container before its filesystem; ext4 shrink requires correct units/space and offline checks, XFS cannot shrink. Wait for EBS modification/snapshot completion and verify encryption/AZ/costs before attach/detach; never format restored data or force-detach mounted workloads.
Disk Discovery and Partitioning
# List all block devices
lsblk
lsblk -f # Show filesystem types and mount points
# Show detailed disk information
fdisk -l /dev/sdb
# Identify disk model and health (requires smartmontools)
smartctl -a /dev/sda
smartctl -H /dev/sda # Quick health check
# Create a GPT partition table and a single partition
parted /dev/sdb mklabel gpt
parted /dev/sdb mkpart primary ext4 0% 100%
# Alternative: use fdisk for MBR partitioning
fdisk /dev/sdb
# n -> new partition, p -> primary, Enter defaults, w -> write
# Inform the kernel of partition table changes
partprobe /dev/sdb
# Wipe filesystem signatures (prepare for LVM or RAID)
wipefs -a /dev/sdb1Filesystem Creation and Management
# Create an ext4 filesystem
mkfs.ext4 /dev/sdb1
# Create an ext4 filesystem with label and reserved block tuning
mkfs.ext4 -L appdata -m 1 /dev/sdb1 # 1% reserved blocks (default is 5%)
# Create an XFS filesystem (recommended for large volumes)
mkfs.xfs /dev/sdb1
# Create an XFS filesystem with label
mkfs.xfs -L appdata /dev/sdb1
# Mount the filesystem
mkdir -p /data
mount /dev/sdb1 /data
# Add persistent mount to fstab (use UUID for reliability)
blkid /dev/sdb1 # Get the UUID
echo 'UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /data ext4 defaults,noatime 0 2' >> /etc/fstab
# Mount all entries in fstab
mount -a
# Check and repair a filesystem (unmount first)
umount /data
fsck.ext4 -y /dev/sdb1
xfs_repair /dev/sdb1 # For XFS
# Resize ext4 (can grow online while mounted)
resize2fs /dev/sdb1
# Resize XFS (must be mounted to grow)
xfs_growfs /data
# Check filesystem usage
df -hTLVM Management
Creating an LVM Stack
# Step 1: Create physical volumes
pvcreate /dev/sdb /dev/sdc
# View physical volumes
pvs
pvdisplay /dev/sdb
# Step 2: Create a volume group from physical volumes
vgcreate data_vg /dev/sdb /dev/sdc
# View volume groups
vgs
vgdisplay data_vg
# Step 3: Create logical volumes
# Fixed size
lvcreate -L 100G -n app_lv data_vg
# Use percentage of free space
lvcreate -l 50%FREE -n logs_lv data_vg
# Use all remaining space
lvcreate -l 100%FREE -n backup_lv data_vg
# View logical volumes
lvs
lvdisplay /dev/data_vg/app_lv
# Step 4: Create filesystem and mount
mkfs.ext4 /dev/data_vg/app_lv
mkdir -p /data/app
mount /dev/data_vg/app_lv /data/app
# Add to fstab
echo '/dev/data_vg/app_lv /data/app ext4 defaults,noatime 0 2' >> /etc/fstabExtending Volumes (Online)
# Extend a logical volume by 20 GB
lvextend -L +20G /dev/data_vg/app_lv
# Extend to fill all free space in the VG
lvextend -l +100%FREE /dev/data_vg/app_lv
# Grow the ext4 filesystem (online, no unmount needed)
resize2fs /dev/data_vg/app_lv
# Grow XFS filesystem (online)
xfs_growfs /data/app
# Combined: extend LV and resize filesystem in one command
lvextend -L +20G --resizefs /dev/data_vg/app_lvAdding a New Disk to an Existing VG
# Add a new physical volume
pvcreate /dev/sdd
# Extend the volume group
vgextend data_vg /dev/sdd
# Now extend any logical volume using the new space
lvextend -l +100%FREE --resizefs /dev/data_vg/app_lvLVM Snapshots
# Create a snapshot (requires free space in VG)
lvcreate -L 10G -s -n app_snap /dev/data_vg/app_lv
# Mount the snapshot read-only for backup
mkdir -p /mnt/snapshot
mount -o ro /dev/data_vg/app_snap /mnt/snapshot
# Perform backup from the snapshot
tar czf /backup/app-$(date +%Y%m%d).tar.gz -C /mnt/snapshot .
# Backup completion path: unmount and remove the snapshot when no rollback is needed
umount /mnt/snapshot
lvremove -f /dev/data_vg/app_snap
# Alternative restore path: retain the snapshot above; do not run lvremove first.
# Reverts LV to snapshot point -- destructive
lvconvert --merge /dev/data_vg/app_snap
# Note: if the LV is mounted, merge happens at next activation (reboot)Reducing and Removing LVM Components
# Shrink a logical volume (ext4 only -- XFS cannot shrink)
# MUST unmount first
umount /data/app
e2fsck -f /dev/data_vg/app_lv
resize2fs /dev/data_vg/app_lv 80G
lvreduce -L 80G /dev/data_vg/app_lv
mount /data/app
# Remove a logical volume
umount /data/app
lvremove /dev/data_vg/app_lv
# Remove a disk from a volume group (migrate data off first)
pvmove /dev/sdc # Migrate extents to other PVs
vgreduce data_vg /dev/sdc # Remove PV from VG
pvremove /dev/sdc # Clean PV metadataAWS EBS Management
# Create a gp3 volume (general purpose SSD)
aws ec2 create-volume \
--availability-zone us-east-1a \
--size 100 \
--volume-type gp3 \
--iops 3000 \
--throughput 125 \
--tag-specifications 'ResourceType=volume,Tags=[{Key=Name,Value=app-data},{Key=Environment,Value=production}]'
# Create an io2 volume (provisioned IOPS SSD for databases)
aws ec2 create-volume \
--availability-zone us-east-1a \
--size 500 \
--volume-type io2 \
--iops 10000
# List volumes with filters
aws ec2 describe-volumes \
--filters "Name=tag:Environment,Values=production" \
--query 'Volumes[*].{ID:VolumeId,Size:Size,Type:VolumeType,State:State,AZ:AvailabilityZone}' \
--output table
# Attach a volume to an instance
aws ec2 attach-volume \
--volume-id vol-0abc123def456789 \
--instance-id i-0abc123def456789 \
--device /dev/xvdf
# After attaching, format and mount on the instance
lsblk # Identify the new device (e.g., /dev/nvme1n1)
mkfs.ext4 /dev/nvme1n1
mkdir -p /data
mount /dev/nvme1n1 /data
# Modify a volume (resize without detaching -- gp3/io2)
aws ec2 modify-volume \
--volume-id vol-0abc123def456789 \
--size 200
# After resize, grow the filesystem on the instance
growpart /dev/nvme1n1 1 # If partitioned
resize2fs /dev/nvme1n1p1 # ext4 when partitioned; use whole device only if filesystem is directly on it
# xfs_growfs /data # XFS
# Create a snapshot
aws ec2 create-snapshot \
--volume-id vol-0abc123def456789 \
--description "Pre-upgrade snapshot $(date +%Y-%m-%d)" \
--tag-specifications 'ResourceType=snapshot,Tags=[{Key=Name,Value=pre-upgrade}]'
# List snapshots
aws ec2 describe-snapshots \
--owner-ids self \
--query 'Snapshots[*].{ID:SnapshotId,Vol:VolumeId,Size:VolumeSize,Date:StartTime,Desc:Description}' \
--output table
# Create a volume from a snapshot (for restore or migration)
aws ec2 create-volume \
--snapshot-id snap-0abc123def456789 \
--availability-zone us-east-1a \
--volume-type gp3
# Detach a volume
aws ec2 detach-volume --volume-id vol-0abc123def456789
# Delete a volume (ensure it is detached first)
aws ec2 delete-volume --volume-id vol-0abc123def456789Software RAID (mdadm)
# Install mdadm
apt install -y mdadm # Debian/Ubuntu
dnf install -y mdadm # RHEL/CentOS
# Create RAID 1 (mirror) with 2 disks
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc
# Create RAID 5 (striped with parity) with 3 disks + 1 spare
mdadm --create /dev/md0 --level=5 --raid-devices=3 --spare-devices=1 /dev/sdb /de… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- blue-green-deploy – Cấu hình chiến lược triển khai không gián đoạn, gồm blue-green, canary và rolling…
- prometheus-configuration – Thiết lập Prometheus để thu thập, lưu trữ và giám sát toàn diện các chỉ số của hạ tầng…
- gcp-cloud-architect – Thiết kế kiến trúc GCP cho startup và doanh nghiệp lớn. Dùng khi cần thiết kế hạ tầng…
- bumblebee – Chạy quét kiểm kê và mức độ phơi nhiễm chuỗi cung ứng Bumblebee trên macOS/Linux để phát…
- cdk-patterns – Các mẫu và construct AWS CDK phổ biến để xây dựng hạ tầng đám mây bằng TypeScript…
- offensive-osint – Bộ công cụ vận hành cho trinh sát red-team bên ngoài và bug bounty có ủy quyền. Các…
- circleci – Cấu hình workflow và orb của CircleCI cho tích hợp liên tục và triển khai liên tục.
- claude-monitor – Giám sát hiệu năng Claude Code và hệ thống cục bộ. Chẩn đoán tình trạng chậm, đo…