Skip to content

Storage Cheat Sheet

Storage Types in DevOps

  • Block Storage – Used for databases, VMs, containers (e.g., EBS, Cinder)
  • File Storage – Used for shared access & persistence (e.g., NFS, EFS)
  • Object Storage – Used for backups, logs, and media (e.g., S3, MinIO)

Disk Management (Linux)

List disks and partitions
lsblk
List disk partitions
fdisk -l
Show disk usage
df -h
Check disk space usage
du -sh /path/to/directory
Mount a disk
mount /dev/sdb1 /mnt
Unmount a disk
umount /mnt
Format a disk
mkfs.ext4 /dev/sdb1
Check filesystem usage
df -Th
Check disk health
smartctl -a /dev/sdb

AWS S3

List all S3 buckets
aws s3 ls
Upload a file to S3
aws s3 cp file.txt s3://mybucket/
Download a file from S3
aws s3 cp s3://mybucket/file.txt .
Sync local directory to S3
aws s3 sync /local/path s3://mybucket/

Azure Blob Storage

List all storage accounts
az storage account list
Upload a file to Azure Blob
az storage blob upload --container-name mycontainer --file file.txt --name file.txt
Download a file from Azure Blob
az storage blob download --container-name mycontainer --name file.txt --file file.txt

Google Cloud Storage (GCS)

List GCS buckets
gsutil ls
Upload a file to GCS
gsutil cp file.txt gs://mybucket/
Download a file from GCS
gsutil cp gs://mybucket/file.txt .

Linux Storage Monitoring

Monitor disk usage in real-time
iotop
Check disk performance
iostat -x 1

Linux Backup

Backup using rsync
rsync -av --delete /source/ /backup/

AWS Backup

Backup data to AWS S3
aws s3 sync /data s3://backup-bucket/

Azure Backup

Backup data to Azure Blob
az storage blob upload-batch --destination mycontainer --source /data

YAML Configurations:

Persistent Volume (PV)

apiVersion: v1
kind: PersistentVolume
metadata:
  name: my-pv
spec:
  capacity:
    storage: 10Gi
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/mnt/data"

Persistent Volume Claim (PVC)

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi

Pod with Persistent Volume

apiVersion: v1
kind: Pod
metadata:
  name: storage-pod
spec:
  containers:
  - name: app
    image: nginx
    volumeMounts:
    - mountPath: "/usr/share/nginx/html"
      name: storage-volume
  volumes:
  - name: storage-volume
    persistentVolumeClaim:
    claimName: my-pvc

Terraform Configurations:

  • AWS S3 Bucket
provider "aws" { 
  region = "us-east-1"
}
resource "aws_s3_bucket" "devops_bucket" { 
  bucket = "devops-backup-bucket"
  acl = "private"
}
output "bucket_name" {
  value = aws_s3_bucket.devops_bucket.id
}
  • Azure Storage Account
provider "azurerm" {
  features {}
}

resource "azurerm_storage_account" "example" { 
  name = "devopsstorageacc" 
  resource_group_name = "devops-rg"
  location = "East US"
  account_tier = "Standard" 
  account_replication_type = "LRS"
}