20 Essential Linux Disk Management Techniques Every Sysadmin Must Master
This guide presents twenty practical Linux disk‑management techniques—from basic inspection commands like lsblk and blkid to advanced LVM, RAID, and performance‑monitoring tools—providing step‑by‑step examples, command syntax, and best‑practice recommendations for reliable storage administration.
1. Basic Inspection and Information Retrieval
Use lsblk -o NAME,SIZE,FSTYPE,MOUNTPOINT to display a tree view of disks, partitions, and mount points, enabling quick identification of storage layout.
Identify device UUIDs and filesystem types with blkid /dev/sda1, which helps avoid mount errors caused by changing device names and is essential for reliable /etc/fstab configuration.
Monitor disk health via SMART by running smartctl -a /dev/sda, which reports temperature, bad‑sector count, and other critical metrics for early fault prediction.
2. Partitioning and Formatting
Choose fdisk for traditional MBR partitions (≤2 TB) and parted for GPT partitions (>2 TB). Example GPT creation:
parted /dev/sdb mklabel gpt mkpart primary xfs 0% 100%Use mkfs.xfs -f /dev/sdb1 for forced XFS creation or mkfs.ext4 -i 8192 /dev/sdb2 to adjust inode density based on expected file count.
3. Mounting and Automatic Mount
Mount by UUID to ensure stability across device name changes:
# Get UUID
blkid /dev/sdb1
# /etc/fstab entry
UUID=1234-5678 /data xfs defaults 0 0Temporary mounts with performance options: mount -o noatime,nodev /dev/sdc1 /mnt/tmp Advanced /etc/fstab parameters, e.g., network storage: nas:/share /mnt/nfs nfs rw,hard,intr 0 0 and disk‑error protection:
/dev/sdb1 /data ext4 defaults,nofail 0 24. Space Analysis and Cleanup
Quick directory size overview: du -h --max-depth=1 /var | sort -hr Log management:
journalctl --vacuum-size=200M # limit journal size
logrotate -f /etc/logrotate.conf # force rotationFind large files efficiently:
find / -type f -size +500M -exec ls -lh {} \;5. LVM Advanced Management
Create physical volume, volume group, and logical volume:
pvcreate /dev/sdb # physical volume
vgcreate data_vg /dev/sdb # volume group
lvcreate -L 10T -n data_lv data_vg # logical volumeOnline expansion (four steps):
lvextend -L +5G /dev/data_vg/data_lv # extend LV
resize2fs /dev/data_vg/data_lv # EXT4 resize
xfs_growfs /data # XFS resize
vgextend data_vg /dev/sdc # extend VGCreate a consistent snapshot for backup:
lvcreate -L 1G -s -n db_snap /dev/data_vg/db_lv6. Filesystem Deep Techniques
Understand inode (metadata storage) and block (actual data). Monitor inode usage with df -i, especially in small‑file scenarios.
Repair a filesystem safely:
umount /dev/sdb1 # must unmount first
fsck -y /dev/sdb1 # run consistency checkNever run fsck on a mounted filesystem to avoid metadata corruption.
7. RAID Configuration
Create a software RAID‑1 array:
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdd /dev/sdeCommon RAID levels:
RAID 0 : striping, high performance, no redundancy.
RAID 1 : mirroring, strong redundancy, half capacity.
RAID 5 : distributed parity, balanced performance and redundancy.
8. Performance Monitoring and Optimization
Gather device‑level I/O statistics: iostat -dx 1 Identify top I/O‑consuming processes: iotop A utilization percentage (>80 %) indicates a saturated disk.
9. Best‑Practice Summary
Partition strategy : separate /home to isolate user data.
Filesystem selection : XFS for large files, EXT4 for general use.
LVM adoption : mandatory in production to avoid fixed partition sizes.
Space‑alert mechanisms : combine df, du, and find for proactive monitoring.
Backup first : always verify backup availability before any disk operation.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
