Storage management is a fundamental skill for Linux system administrators and DevOps engineers. This comprehensive guide covers disk partitioning, filesystem management, and storage administration techniques. From basic disk operations to advanced LVM configurations, master the art of storage management in Linux environments.
Linux Storage Tools Comparison
| Tool Category | Primary Tools | Purpose | Skill Level |
|---|---|---|---|
| Disk Information | lsblk, fdisk, parted | Disk and partition discovery | Beginner |
| Partitioning | fdisk, parted, gdisk | Partition creation and management | Intermediate |
| Filesystem Operations | mkfs, mount, fsck | Filesystem creation and maintenance | Intermediate |
| LVM Management | pvcreate, vgcreate, lvcreate | Logical Volume Management | Advanced |
| RAID Management | mdadm | Software RAID configuration | Advanced |
| Monitoring & Analysis | df, du, iostat, smartctl | Storage monitoring and health | Intermediate |
• List disks:
lsblk or fdisk -l• Check disk space:
df -h• Check directory size:
du -sh /path• Create partition:
fdisk /dev/sdX• Format partition:
mkfs.ext4 /dev/sdX1• Mount filesystem:
mount /dev/sdX1 /mnt• Check filesystem:
fsck /dev/sdX1• Always backup data before partitioning operations
• Document disk layouts for future reference
Storage Management Workflow
Storage Setup Process
Essential Storage Tools
| Tool | Command Examples | Purpose | Key Output |
|---|---|---|---|
| lsblk | lsblklsblk -f |
List block devices | Disk hierarchy, filesystems |
| fdisk | fdisk -lfdisk /dev/sda |
Partition management | Partition table, create partitions |
| parted | parted -lparted /dev/sda |
Advanced partitioning | GPT partitions, resize operations |
| df | df -hdf -i |
Disk space usage | Used/available space, inodes |
| du | du -sh /homedu -h --max-depth=1 |
Directory space usage | Directory sizes, file sizes |
| mount | mountmount /dev/sda1 /mnt |
Filesystem mounting | Mounted filesystems, mount options |
Disk Discovery & Information
Display information about block devices and their hierarchy.
Common Operations:
# List all block devices
lsblk
# Show filesystem information
lsblk -f
# Show detailed information
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE,UUID
# Show SCSI devices
lsscsi
# Show disk information with model
lsblk -d -o NAME,SIZE,MODEL,SERIAL
# Tree view with all details
lsblk -a
# Show only disks (exclude partitions)
lsblk -d
# JSON output for scripting
lsblk -J
Display and manage disk partition tables.
Partition Analysis:
# List partition tables for all disks
sudo fdisk -l
# List specific disk partitions
sudo fdisk -l /dev/sda
# Interactive partition editing
sudo fdisk /dev/sdb
# Show partition types
sudo fdisk -l /dev/sda | grep -E "^/dev/"
# Check if disk uses MBR or GPT
sudo fdisk -l /dev/sda | grep -i "disklabel"
# Show partition sizes in human readable
sudo fdisk -l /dev/sda | grep -E "^/dev/" | awk '{print $1,$5}'
# Backup partition table
sudo sfdisk -d /dev/sda > sda_partition_backup.txt
Monitor disk usage and available space.
Space Analysis:
# Show disk space usage
df -h
# Show inode usage
df -i
# Show specific filesystem
df -h /home
# Show directory sizes
du -sh /var/log/
du -h --max-depth=1 /home
# Interactive disk usage analysis
ncdu /
# Show largest files
find /var/log -type f -exec du -h {} + | sort -rh | head -20
# Monitor disk space in real-time
watch -n 5 'df -h'
# Show filesystem type
df -T
Partition Management
Create and manage MBR partition tables.
Partition Operations:
# Start fdisk for a disk
sudo fdisk /dev/sdb
# Common fdisk commands:
# n - Create new partition
# d - Delete partition
# p - Print partition table
# t - Change partition type
# w - Write changes and exit
# q - Quit without saving
# Create partition sequence:
# 1. sudo fdisk /dev/sdb
# 2. n (new partition)
# 3. p (primary partition)
# 4. 1 (partition number)
# 5. [Enter] (first sector)
# 6. +10G (size: 10GB)
# 7. w (write changes)
# Change partition type to Linux LVM
# t → 8e (for LVM)
# t → 83 (for Linux)
# t → 82 (for Linux swap)
# Delete all partitions
sudo sgdisk -Z /dev/sdb
Advanced partitioning with GPT support.
GPT Operations:
# List partitions
sudo parted -l
# Start parted for a disk
sudo parted /dev/sdb
# Common parted commands:
# print - Show partition table
# mklabel gpt - Create GPT partition table
# mkpart primary ext4 1MiB 10GiB - Create partition
# rm 1 - Delete partition 1
# resizepart 1 15GiB - Resize partition
# quit - Exit
# Create GPT partition table
sudo parted /dev/sdb mklabel gpt
# Create partition with parted
sudo parted /dev/sdb mkpart primary ext4 1MiB 10GiB
# Create partition with specific alignment
sudo parted -a optimal /dev/sdb mkpart primary ext4 1MiB 10GiB
# Resize partition
sudo parted /dev/sdb resizepart 1 15GiB
# Set partition flags
sudo parted /dev/sdb set 1 boot on
# Show all partition information
sudo parted /dev/sdb unit MB print free
GPT-specific partitioning tool.
GPT Operations:
# Start gdisk for GPT disk
sudo gdisk /dev/sdb
# Common gdisk commands:
# p - Print partition table
# n - Create new partition
# d - Delete partition
# t - Change partition type
# w - Write table to disk
# q - Quit without saving
# Create GPT partition
sudo gdisk /dev/sdb
# n → [Enter] → [Enter] → +10G → 8300 (Linux filesystem)
# Change partition type to LVM
# t → 1 → 8e00
# Show detailed partition information
sudo gdisk -l /dev/sdb
# Backup GPT partition table
sudo sgdisk -b /dev/sdb sdb_gpt_backup.bin
# Restore GPT partition table
sudo sgdisk -l sdb_gpt_backup.bin /dev/sdb
# Verify partition table
sudo gdisk -v /dev/sdb
Filesystem Operations
Create various filesystem types.
Filesystem Creation:
# Create ext4 filesystem
sudo mkfs.ext4 /dev/sdb1
# Create XFS filesystem
sudo mkfs.xfs /dev/sdb1
# Create Btrfs filesystem
sudo mkfs.btrfs /dev/sdb1
# Create filesystem with label
sudo mkfs.ext4 -L "data_disk" /dev/sdb1
# Create swap partition
sudo mkswap /dev/sdb2
sudo swapon /dev/sdb2
# Check filesystem
sudo fsck /dev/sdb1
sudo fsck.ext4 /dev/sdb1
# Show filesystem information
sudo blkid /dev/sdb1
sudo file -s /dev/sdb1
# Tune ext4 filesystem
sudo tune2fs -l /dev/sdb1
sudo tune2fs -L "new_label" /dev/sdb1
Mount and unmount filesystems.
Mount Operations:
# Mount filesystem
sudo mount /dev/sdb1 /mnt/data
# Mount with specific options
sudo mount -o rw,noatime /dev/sdb1 /mnt/data
# Mount all filesystems in fstab
sudo mount -a
# Unmount filesystem
sudo umount /mnt/data
# Force unmount (use with caution)
sudo umount -f /mnt/data
# Lazy unmount
sudo umount -l /mnt/data
# Show mounted filesystems
mount
findmnt
# Show specific mount information
findmnt /mnt/data
# Remount with different options
sudo mount -o remount,rw /mnt/data
# Mount by UUID
sudo mount UUID=1234-5678 /mnt/data
Configure persistent filesystem mounting.
fstab Examples:
# /etc/fstab examples:
# Mount by device
/dev/sdb1 /mnt/data ext4 defaults 0 2
# Mount by UUID
UUID=1234-5678 /mnt/data ext4 defaults,noatime 0 2
# Mount by label
LABEL=data_disk /mnt/data ext4 defaults 0 2
# NFS mount
nfs-server:/export/data /mnt/nfs nfs rw,hard,intr 0 0
# CIFS/SMB mount
//server/share /mnt/smb cifs credentials=/root/smb.cred,uid=1000 0 0
# tmpfs mount
tmpfs /mnt/tmpfs tmpfs size=1G,mode=1777 0 0
# Swap partition
/dev/sdb2 none swap sw 0 0
# Test fstab without mounting
sudo mount -a --fake
# Check fstab for errors
sudo findmnt --verify
Filesystem Comparison
| Filesystem | Max File Size | Max Volume Size | Journaling | Use Case |
|---|---|---|---|---|
| ext4 | 16 TiB | 1 EiB | Yes | General purpose, stable |
| XFS | 8 EiB | 8 EiB | Yes | High performance, large files |
| Btrfs | 16 EiB | 16 EiB | Yes | Advanced features, snapshots |
| ZFS | 16 EiB | 256 ZiB | Copy-on-write | Enterprise storage, data integrity |
| NTFS | 16 EiB | 8 PiB | Yes | Windows compatibility |
| FAT32 | 4 GiB | 2 TiB | No | USB drives, compatibility |
Advanced Storage Management
| Tool Category | Tools | Primary Use | Installation |
|---|---|---|---|
| LVM Management | pvcreate, vgcreate, lvcreate | Logical Volume Management | sudo apt install lvm2 |
| RAID Management | mdadm | Software RAID configuration | sudo apt install mdadm |
| Disk Health | smartctl, badblocks | Disk monitoring and testing | sudo apt install smartmontools |
| Performance Testing | hdparm, fio, iostat | Disk performance benchmarking | sudo apt install hdparm fio |
| Encryption | cryptsetup, LUKS | Disk encryption | sudo apt install cryptsetup |
LVM (Logical Volume Management)
Physical Volumes, Volume Groups, and Logical Volumes.
LVM Setup:
# Create Physical Volume
sudo pvcreate /dev/sdb1
sudo pvcreate /dev/sdc1
# Create Volume Group
sudo vgcreate myvg /dev/sdb1 /dev/sdc1
# Create Logical Volume
sudo lvcreate -L 20G -n mylv myvg
# Create filesystem on LV
sudo mkfs.ext4 /dev/myvg/mylv
# Mount the logical volume
sudo mount /dev/myvg/mylv /mnt/lvm
# Show LVM information
sudo pvs # Physical volumes
sudo vgs # Volume groups
sudo lvs # Logical volumes
# Show detailed information
sudo pvdisplay
sudo vgdisplay
sudo lvdisplay
Extend, reduce, and manage LVM volumes.
LVM Operations:
# Extend Volume Group
sudo vgextend myvg /dev/sdd1
# Extend Logical Volume
sudo lvextend -L +10G /dev/myvg/mylv
# Resize filesystem (ext4)
sudo resize2fs /dev/myvg/mylv
# Reduce Logical Volume (dangerous!)
# First reduce filesystem, then LV
sudo lvreduce -L -5G /dev/myvg/mylv
# Create snapshot
sudo lvcreate -L 5G -s -n mysnap /dev/myvg/mylv
# Remove snapshot
sudo lvremove /dev/myvg/mysnap
# Move Physical Volume
sudo pvmove /dev/sdb1 /dev/sdc1
# Remove Physical Volume
sudo vgreduce myvg /dev/sdb1
sudo pvremove /dev/sdb1
Advanced LVM features and monitoring.
Advanced LVM:
# Create striped logical volume
sudo lvcreate -L 20G -i 2 -I 64 -n striped_lv myvg
# Create mirrored logical volume
sudo lvcreate -L 10G -m 1 -n mirrored_lv myvg
# Convert to thin pool
sudo lvconvert --type thin-pool myvg/mylv
# Create thin volume
sudo lvcreate -V 10G -T myvg/mythinpool -n thin_vol
# Monitor LVM
sudo lvchange -an /dev/myvg/mylv # Deactivate
sudo lvchange -ay /dev/myvg/mylv # Activate
# Backup LVM metadata
sudo vgcfgbackup myvg
# Restore LVM metadata
sudo vgcfgrestore myvg
# Show LVM history
sudo lvdisplay -h /dev/myvg/mylv
RAID Management
Create and manage software RAID arrays.
RAID Setup:
# Create RAID 1 (mirror)
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1
# Create RAID 5
sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
# Create RAID 10
sudo mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
# Stop RAID array
sudo mdadm --stop /dev/md0
# Assemble existing RAID
sudo mdadm --assemble /dev/md0
# Show RAID status
cat /proc/mdstat
sudo mdadm --detail /dev/md0
# Save RAID configuration
sudo mdadm --detail --scan >> /etc/mdadm/mdadm.conf
# Add spare disk to RAID
sudo mdadm --add /dev/md0 /dev/sdf1
# Remove failed disk
sudo mdadm --remove /dev/md0 /dev/sdb1
# Mark disk as failed
sudo mdadm --fail /dev/md0 /dev/sdb1
Monitor RAID health and performance.
RAID Monitoring:
# Monitor RAID status
watch cat /proc/mdstat
# Detailed RAID information
sudo mdadm --detail /dev/md0
# Examine component disks
sudo mdadm --examine /dev/sdb1
# Check RAID recovery progress
cat /proc/mdstat | grep recovery
# Monitor disk health in RAID
sudo smartctl -a /dev/sdb1 | grep -E "Reallocated|Pending|Uncorrectable"
# Check RAID events
dmesg | grep md
# Test RAID array
sudo badblocks -sv /dev/md0
# Performance testing
sudo hdparm -Tt /dev/md0
# Check filesystem on RAID
sudo fsck /dev/md0
Recover and rebuild RAID arrays.
Recovery Operations:
# Rebuild RAID array
sudo mdadm --manage /dev/md0 --re-add /dev/sdb1
# Check rebuild progress
watch -n 1 'cat /proc/mdstat'
# Stop and reassemble array
sudo mdadm --stop /dev/md0
sudo mdadm --assemble /dev/md0 /dev/sdb1 /dev/sdc1
# Recreate array with missing disk
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 missing
# Add missing disk later
sudo mdadm --add /dev/md0 /dev/sdc1
# Recover from failed RAID
sudo mdadm --assemble --force /dev/md0 /dev/sdb1 /dev/sdc1
# Backup RAID metadata
sudo mdadm --detail --scan > /etc/mdadm/mdadm.conf
# Restore RAID configuration
sudo mdadm --assemble --scan
Practical Storage Scenarios
Real-World Storage Management Examples
# 1. Complete Storage Diagnostics Script
#!/bin/bash
echo "=== Storage Diagnostics ==="
echo "1. Block Devices:"
lsblk
echo -e "\n2. Disk Space:"
df -h
echo -e "\n3. Mount Points:"
findmnt
echo -e "\n4. LVM Status:"
sudo pvs 2>/dev/null && sudo vgs 2>/dev/null && sudo lvs 2>/dev/null
echo -e "\n5. RAID Status:"
cat /proc/mdstat 2>/dev/null
echo -e "\n6. Disk Health:"
for disk in /dev/sd?; do
echo "Checking $disk:"
sudo smartctl -H $disk 2>/dev/null | grep "SMART overall-health" || echo "SMART not available"
done
# 2. Disk Partitioning Script
#!/bin/bash
DISK="/dev/sdb"
echo "Partitioning $DISK..."
echo -e "o\nn\np\n1\n\n+10G\nn\np\n2\n\n+5G\nt\n2\n82\nw" | sudo fdisk $DISK
sudo partprobe $DISK
echo "Partitioning complete:"
sudo fdisk -l $DISK
# 3. LVM Setup Script
#!/bin/bash
VG_NAME="datavg"
LV_NAME="datalv"
MOUNT_POINT="/mnt/data"
echo "Setting up LVM..."
sudo pvcreate /dev/sdb1
sudo vgcreate $VG_NAME /dev/sdb1
sudo lvcreate -L 8G -n $LV_NAME $VG_NAME
sudo mkfs.ext4 /dev/$VG_NAME/$LV_NAME
sudo mkdir -p $MOUNT_POINT
sudo mount /dev/$VG_NAME/$LV_NAME $MOUNT_POINT
echo "LVM setup complete:"
sudo lvs
# 4. Filesystem Health Check
#!/bin/bash
echo "Filesystem Health Check:"
for fs in $(findmnt -r -n -o TARGET | grep -v "^/$"); do
echo "Checking $fs:"
sudo touch $fs/.fs_test 2>/dev/null && echo " Writable" || echo " Read-only"
sudo rm -f $fs/.fs_test 2>/dev/null
df -h $fs | tail -1
done
# 5. Disk Performance Test
#!/bin/bash
echo "Disk Performance Test:"
for disk in /dev/sd?; do
echo "Testing $disk:"
sudo hdparm -Tt $disk 2>/dev/null | grep -E "Timing|MB"
done
# 6. Storage Monitoring Script
#!/bin/bash
THRESHOLD=90
echo "Storage Monitoring:"
df -h | awk -v threshold=$THRESHOLD '
NR>1 {
usage = $5
sub(/%/, "", usage)
if (usage > threshold) {
print "ALERT: " $1 " (" $6 ") is " usage "% full!"
}
}'
# 7. LVM Snapshot Management
#!/bin/bash
VG_NAME="datavg"
LV_NAME="datalv"
SNAP_NAME="backup_snap"
SNAP_SIZE="2G"
echo "Creating LVM snapshot..."
sudo lvcreate -L $SNAP_SIZE -s -n $SNAP_NAME /dev/$VG_NAME/$LV_NAME
echo "Snapshot created:"
sudo lvs /dev/$VG_NAME/$SNAP_NAME
# Later: sudo lvremove /dev/$VG_NAME/$SNAP_NAME
# 8. RAID Health Check
#!/bin/bash
echo "RAID Health Check:"
if [ -f /proc/mdstat ]; then
cat /proc/mdstat
for array in /dev/md*; do
if [ -b $array ]; then
echo "Details for $array:"
sudo mdadm --detail $array | grep -E "State|Status|Failed"
fi
done
else
echo "No software RAID arrays found"
fi
# 9. Disk Encryption Setup
#!/bin/bash
CRYPT_NAME="secure_disk"
MOUNT_POINT="/mnt/secure"
echo "Setting up encrypted disk..."
sudo cryptsetup luksFormat /dev/sdb1
sudo cryptsetup luksOpen /dev/sdb1 $CRYPT_NAME
sudo mkfs.ext4 /dev/mapper/$CRYPT_NAME
sudo mkdir -p $MOUNT_POINT
sudo mount /dev/mapper/$CRYPT_NAME $MOUNT_POINT
echo "Encrypted disk ready at $MOUNT_POINT"
# 10. Storage Benchmark Suite
#!/bin/bash
echo "Storage Benchmark Suite:"
TEST_FILE="/tmp/testfile"
echo "1. Write test:"
dd if=/dev/zero of=$TEST_FILE bs=1M count=1024 oflag=direct status=progress
echo -e "\n2. Read test:"
dd if=$TEST_FILE of=/dev/null bs=1M count=1024 status=progress
echo -e "\n3. Random I/O:"
fio --name=random_test --ioengine=libaio --rw=randrw --bs=4k --numjobs=4 --size=1G --runtime=60 --group_reporting
rm -f $TEST_FILE
# 11. Filesystem Type Check
#!/bin/bash
echo "Filesystem Types:"
for device in $(lsblk -r -n -o NAME,TYPE | grep disk | cut -d' ' -f1); do
device_path="/dev/$device"
if [ -b $device_path ]; then
fstype=$(lsblk -r -n -o FSTYPE $device_path)
echo "$device_path: $fstype"
fi
done
# 12. Mount Point Verification
#!/bin/bash
echo "Verifying mount points..."
while read -r line; do
device=$(echo $line | awk '{print $1}')
mountpoint=$(echo $line | awk '{print $2}')
if mountpoint -q "$mountpoint"; then
echo "✓ $device mounted at $mountpoint"
else
echo "✗ $device NOT mounted at $mountpoint"
fi
done < <(findmnt -r -n -o SOURCE,TARGET)
# 13. Disk Temperature Monitoring
#!/bin/bash
echo "Disk Temperatures:"
for disk in /dev/sd?; do
temp=$(sudo smartctl -A $disk 2>/dev/null | grep -i temperature | head -1 | awk '{print $10}')
if [ -n "$temp" ]; then
echo "$disk: ${temp}°C"
else
echo "$disk: Temperature not available"
fi
done
# 14. Storage Configuration Backup
#!/bin/bash
BACKUP_DIR="/root/storage_backup_$(date +%Y%m%d)"
mkdir -p $BACKUP_DIR
sudo fdisk -l > $BACKUP_DIR/fdisk.txt
lsblk > $BACKUP_DIR/lsblk.txt
df -h > $BACKUP_DIR/df.txt
sudo pvs 2>/dev/null > $BACKUP_DIR/pvs.txt
sudo vgs 2>/dev/null > $BACKUP_DIR/vgs.txt
sudo lvs 2>/dev/null > $BACKUP_DIR/lvs.txt
cat /proc/mdstat 2>/dev/null > $BACKUP_DIR/mdstat.txt
cp /etc/fstab $BACKUP_DIR/fstab.backup
echo "Storage configuration backed up to $BACKUP_DIR"
# 15. Automated Cleanup Script
#!/bin/bash
echo "Cleaning up temporary files..."
# Clean log files older than 30 days
find /var/log -name "*.log" -type f -mtime +30 -delete
# Clean temporary files
find /tmp -type f -atime +7 -delete
find /var/tmp -type f -atime +7 -delete
# Clean package cache
sudo apt-get autoremove -y
sudo apt-get autoclean -y
echo "Cleanup complete"
Common Storage Issues & Solutions
Partitioning Problems
- Disk Not Recognized: Check kernel messages, rescan SCSI bus, verify connections
- Partition Table Corruption: Use testdisk, gdisk recovery, restore from backup
- MBR/GPT Conversion Issues: Backup data first, use gdisk for conversion
- Partition Alignment: Use parted with optimal alignment, check with fdisk
Filesystem Issues
- Filesystem Corruption: Run fsck, check disk health, restore from backup
- Mount Failures: Check fstab syntax, verify device existence, check filesystem type
- Read-only Filesystem: Check disk errors, remount as read-write, run fsck
- Inode Exhaustion: Check with df -i, clean up small files, recreate filesystem with more inodes
LVM Issues
- Volume Group Not Found: Scan for physical volumes, activate volume group
- Logical Volume Activation Failed: Check device mapper, verify LVM metadata
- Snapshot Issues: Monitor snapshot space, remove old snapshots
- LVM Metadata Corruption: Use vgcfgrestore, restore from backup
RAID Issues
- RAID Degraded: Replace failed disks, monitor rebuild progress
- RAID Not Assembling: Check component disks, force assembly if needed
- Slow RAID Performance: Check disk health, verify RAID configuration
- RAID Recovery: Use mdadm recovery options, restore from backup if needed
Advanced Storage Techniques
Disk Encryption
Full disk encryption with LUKS.
Encryption Operations:
# Create encrypted partition
sudo cryptsetup luksFormat /dev/sdb1
# Open encrypted partition
sudo cryptsetup luksOpen /dev/sdb1 secure_disk
# Create filesystem on encrypted device
sudo mkfs.ext4 /dev/mapper/secure_disk
# Mount encrypted filesystem
sudo mount /dev/mapper/secure_disk /mnt/secure
# Close encrypted partition
sudo umount /mnt/secure
sudo cryptsetup luksClose secure_disk
# Add additional passphrase
sudo cryptsetup luksAddKey /dev/sdb1
# Backup LUKS header
sudo cryptsetup luksHeaderBackup /dev/sdb1 --header-backup-file luks_header.backup
Performance Tuning
Storage performance optimization.
Performance Optimization:
# Tune ext4 filesystem
sudo tune2fs -o journal_data_writeback /dev/sdb1
sudo tune2fs -O ^has_journal /dev/sdb1 # Disable journal
# Mount with performance options
sudo mount -o noatime,nodiratime,data=writeback /dev/sdb1 /mnt/data
# Tune disk parameters
sudo hdparm -W 1 /dev/sdb # Enable write cache
sudo hdparm -a 1024 /dev/sdb # Set readahead
# I/O scheduler tuning
echo noop > /sys/block/sdb/queue/scheduler
echo deadline > /sys/block/sdb/queue/scheduler
# SSD optimization
sudo fstrim /mnt/ssd
Data Recovery
Data recovery techniques and tools.
Recovery Tools:
# Recover partition table
sudo testdisk /dev/sdb
# Recover deleted files
sudo photorec /dev/sdb1
# Clone failing disk
sudo ddrescue /dev/sdb /dev/sdc rescue.log
# File carving
foremost -t jpg,pdf,doc -i /dev/sdb1 -o recovered_files/
# Check filesystem for recovery
sudo fsck -y /dev/sdb1
# Mount corrupted filesystem read-only
sudo mount -o ro,loop,recovery /dev/sdb1 /mnt/recover
• Always backup data before partitioning or filesystem operations
• Test new storage configurations in non-production environments
• Monitor disk health regularly with SMART tools
• Keep LVM metadata backups for disaster recovery
• Understand RAID levels and their trade-offs for your use case
• Document storage configurations and changes
• Have recovery procedures tested and ready
• Consider performance implications of different filesystems
• Plan for storage growth and scalability
• Use
lsblk -f for quick filesystem overview• Prefer GPT over MBR for modern systems
• Use LVM for flexible storage management
• Monitor disk SMART attributes for early failure detection
• Use
ncdu for interactive disk usage analysis• Create storage documentation with disk layouts
• Use RAID for redundancy, not as a backup solution
• Test backup and recovery procedures regularly
• Consider using ZFS or Btrfs for advanced features
Key Takeaways
Effective storage management requires understanding disk partitioning, filesystem characteristics, and advanced storage technologies like LVM and RAID. By following systematic approaches, using appropriate tools for each task, and maintaining good documentation, you can efficiently manage storage in Linux environments. Remember that storage operations can be destructive, so always have backups and test procedures in safe environments first.
Next Step: Explore advanced storage topics like distributed filesystems (Ceph, GlusterFS), storage performance tuning, cloud storage integration, and automated storage management with tools like Ansible.