• Skip to main content
  • Skip to primary sidebar
  • Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / Linux sysadmin tutorials linux system administrator / linux disk management commands

linux disk management commands

Linux provides several commands for managing disks, partitions, and file systems. Here are some essential disk management commands along with their usage examples:


Table of Contents

Toggle
    • 🔥 Summary Table of Commands
  • 1. lsblk (List Block Devices)
    • Example:
  • 2. fdisk (Partition Management)
    • Example:
  • 3. parted (Advanced Partition Management)
    • Example:
  • 4. df (Check Disk Space Usage)
    • Example:
  • 5. du (Check Directory Size)
    • Example:
  • 6. mount (Mount a File System)
    • Example:
  • 7. umount (Unmount a File System)
    • Example:
  • 8. mkfs (Format a Partition)
    • Example:
  • 9. blkid (Get UUID of Partitions)
    • Example:
  • 10. tune2fs (Modify ext Filesystem Parameters)
    • Example:
  • 11. fsck (Check and Repair File System)
    • Example:
  • 12. resize2fs (Resize ext File System)
    • Example:
  • 13. lvdisplay (Show LVM Logical Volumes)
    • Example:
  • 14. pvcreate (Initialize a Disk for LVM)
    • Example:
  • 15. vgcreate (Create a Volume Group)
    • Example:
  • 16. lvcreate (Create a Logical Volume)
    • Example:
  • 17. mount -o loop (Mount an ISO File)
    • Example:
  • 18. swapon and swapoff (Manage Swap Space)
    • Example:
  • 19. iostat (Disk I/O Statistics)
    • Example:
  • 20. smartctl (Check Disk Health)
    • Example:

🔥 Summary Table of Commands

Command Description
lsblk List block devices
fdisk Partition a disk
parted Advanced partitioning
df -h Check disk usage
du -sh Check directory size
mount Mount a file system
umount Unmount a file system
mkfs.ext4 Format partition as ext4
blkid Get partition UUID
fsck Check and repair file system
resize2fs Resize ext4 file system
lvdisplay Display LVM logical volumes
pvcreate Initialize disk for LVM
vgcreate Create a volume group
lvcreate Create a logical volume
swapon -s Show active swap
iostat Show disk I/O stats
smartctl Check disk health

1. lsblk (List Block Devices)

Example:

lsblk

Output: Displays a tree-like structure of disks and partitions.

lsblk -f

Usage: Shows file system details of each partition.


2. fdisk (Partition Management)

Example:

sudo fdisk -l

Usage: Lists all partitions on available disks.

sudo fdisk /dev/sdb

Usage: Opens interactive mode to create, delete, or modify partitions on /dev/sdb.


3. parted (Advanced Partition Management)

Example:

sudo parted /dev/sdb

Usage: Starts parted to manage partitions on /dev/sdb.

sudo parted -l

Output: Lists all disk partitions with details.


4. df (Check Disk Space Usage)

Example:

df -h

Output: Shows disk space usage in a human-readable format.

df -T

Usage: Displays file system types along with disk usage.


5. du (Check Directory Size)

Example:

du -sh /home/user

Output: Displays the total size of the /home/user directory.

du -ah /home/user | sort -rh | head -10

Usage: Lists the top 10 largest files/folders.


6. mount (Mount a File System)

Example:

sudo mount /dev/sdb1 /mnt

Usage: Mounts /dev/sdb1 partition to /mnt.

mount | column -t

Output: Shows currently mounted file systems in a readable format.


7. umount (Unmount a File System)

Example:

sudo umount /mnt

Usage: Unmounts the /mnt directory.

sudo umount /dev/sdb1

Usage: Unmounts the specific partition /dev/sdb1.


8. mkfs (Format a Partition)

Example:

sudo mkfs.ext4 /dev/sdb1

Usage: Formats /dev/sdb1 as an ext4 file system.

sudo mkfs.xfs /dev/sdb1

Usage: Formats /dev/sdb1 as an XFS file system.


9. blkid (Get UUID of Partitions)

Example:

sudo blkid

Output: Lists UUIDs and file system types of all partitions.

sudo blkid /dev/sdb1

Usage: Shows UUID and file system type for /dev/sdb1.


10. tune2fs (Modify ext Filesystem Parameters)

Example:

sudo tune2fs -l /dev/sda1

Output: Displays file system settings of /dev/sda1.

sudo tune2fs -m 5 /dev/sda1

Usage: Reserves 5% of disk space for system use.


11. fsck (Check and Repair File System)

Example:

sudo fsck /dev/sda1

Usage: Checks and repairs file system errors on /dev/sda1.


12. resize2fs (Resize ext File System)

Example:

sudo resize2fs /dev/sda1 20G

Usage: Shrinks or expands /dev/sda1 to 20GB.

sudo resize2fs /dev/sda1

Usage: Expands the file system to fill available space.


13. lvdisplay (Show LVM Logical Volumes)

Example:

sudo lvdisplay

Output: Displays details of logical volumes.


14. pvcreate (Initialize a Disk for LVM)

Example:

sudo pvcreate /dev/sdb

Usage: Prepares /dev/sdb as a physical volume for LVM.


15. vgcreate (Create a Volume Group)

Example:

sudo vgcreate my_vg /dev/sdb

Usage: Creates a volume group named my_vg using /dev/sdb.


16. lvcreate (Create a Logical Volume)

Example:

sudo lvcreate -L 10G -n my_lv my_vg

Usage: Creates a 10GB logical volume my_lv inside my_vg.


17. mount -o loop (Mount an ISO File)

Example:

sudo mount -o loop file.iso /mnt

Usage: Mounts an ISO file to /mnt.


18. swapon and swapoff (Manage Swap Space)

Example:

sudo swapon -s

Output: Shows active swap partitions.

sudo swapon /dev/sdb1

Usage: Enables swap space on /dev/sdb1.

sudo swapoff /dev/sdb1

Usage: Disables swap space.


19. iostat (Disk I/O Statistics)

Example:

iostat -dx 1

Output: Shows real-time disk read/write stats.


20. smartctl (Check Disk Health)

Example:

sudo smartctl -a /dev/sda

Output: Displays SMART health information of /dev/sda.

sudo smartctl -t short /dev/sda

Usage: Runs a short disk self-test.


 

Primary Sidebar

Linux sysadmin tutorials linux system administrator

  • top 10 apt & apt-get commands (most used) apt vs apt-get
  • If-Else Statements in Shell Scripting
  • linux commands pdf (files & Directories, zip & unzip process, search etc)
  • Find Files with Specific Text on Linux grep find command
  • linux performance tuning inode limit file descriptors tco, kernel etc
  • Variables and Data Types in Shell Scripting
  • Top 10 most used Cat commands with examples (create, view, append files)
  • Ip tables / ufw / firewall d commands for block port ip rate limiting
  • Top 10 zip / tar commands to compress & extract files in linux
  • TOP 10 mv & cp commands in linux to move & copy files in Linux
  • Top 10 GREP Commands in linux to search files directory words strings
  • lsof netstat commands to know listening ports in linux 3 ways
  • Upgrade Ubuntu from 18.04 (19.10) to 20.04 LTS command line or gui server | desktop
  • 3 Ways (SCP, rsync, Sftp) linux server migration between two remote server apache nginx
  • linux system specs commands (CPU, Memory, Disk )speed, type. manufacture
  • linux sysctl command tweaks & hardening
  • linux security limits.conf deciding user limits process limits for nginx server
  • ulimit linux unlimited command unlimto set & know user limits open files file descriptor max user process etc.
  • red hat linux certification cost jobs salary syllabus courses fees
  • ufw firewall commads allow port enable disable ubuntu 20.04
  • ddos attack prevention
  • change ssh port in linux - avoid sshd ddos attacks
  • ping command
  • memcached install ubuntu wordpress
  • check linux version (lsb_release -a) ubuntu debian 32 or 64 bit
  • rsync command linux with examples comparison to scp
  • how to uninstall package in linux ubuntu rpm, yum apt-get
  • increase open file limit linux File descriptor ft nginx , mysql, lemp
  • remove repository ubuntu
  • htop commad memory details virtual vs shard vs resident
  • chown command in Linux with Examples
  • Kill PHP process
  • VIrtual Memory vs RSS Memory vs Shared memory in Linux
  • oom killer fixing it by configuration linux ubuntu
  • Install Lemp nginx mysql php fpm Stack on Debian 11 with repository
  • connect two remote servers linux command line
  • auto start after oom killer Mysql & php fpm nginx etc ubuntu wth systemd or cron job
  • load average Linux 1, 5, 15 min 2,4,8 cores explained
  • Control Structures in Shell Scripting
  • Shell Scripting Roadmap for Beginners to Advanced
  • awk commands with practical examples
  • Shell Scripting Tutorial for Beginners 🚀
  • find Command in Linux with Examples
  • sed Command in Linux with Examples (Beginner to Advanced)
  • Linux Text processing commands in with Examples
  • linux disk management commands
  • fdisk command in linux with examples
  • how to add a new disk in linux
  • Linux mount Command with Examples
  • fstab options with examples
  • Top 50 Shell Scripting Interview Questions and Answers
  • Linux Networking Interview Questions and Answers
  • Linux Networking Commands Cheat Sheet with Examples pdf
  • Netstat & SS Commands cheat sheet with examples Interview Questions
  • Nmap Cheat Sheet – Network Scanning & Security
  • Bash Brackets ([], (), {}, $( ), $(( ))) – Types, Uses & Examples

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy