Linux disk management commands for system administrators

A practical reference for Linux disk management: inspecting devices, partitioning, creating filesystems, mounting persistently, and managing LVM - with the safety notes each command deserves.

Aug 10, 2026 - 11:06
Updated: 1 month ago
101.8k
Linux disk management commands for system administrators

Quick answer: The core Linux disk commands are lsblk and df to inspect, fdisk or parted to partition, mkfs to format, mount and /etc/fstab to attach, and pvcreate, vgcreate and lvcreate for LVM. Inspection commands are safe. Partitioning and mkfs destroy data, so confirm the device name with lsblk first.

Key takeaways

  • Always run lsblk first and confirm the device name. Most disk disasters are a wrong device name.
  • fdisk and mkfs change data on disk. lsblk, df and du only read.
  • Mount by UUID in /etc/fstab, and test with mount -a before you reboot.
  • A disk that shows full after deleting files usually has a process holding the deleted file open.
  • LVM lets you grow a filesystem without repartitioning.

What do the inspection commands show?

Start every disk task by looking. These commands change nothing.

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
 ├─rhel-root 253:0 0 17G 0 lvm /
 └─rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 10G 0 disk

Here sdb has no partitions and no mount point. That is your new, empty disk. The example is illustrative. Your device names and sizes will differ.

  • lsblk -f adds filesystem type, label and UUID.
  • df -h shows used and free space on mounted filesystems.
  • du -sh /var/log/* shows which directories take the space.
  • blkid prints UUIDs, which you need for fstab.

df and du can disagree. df asks the filesystem how much it has allocated. du adds up the files it can see. The gap is explained in the troubleshooting section below.

How do you partition a disk with fdisk?

Use fdisk for MBR or GPT disks of ordinary size, and parted when you need scripting or very large disks. Both do the same job here.

# fdisk /dev/sdb
Command (m for help): g # new GPT partition table
Command (m for help): n # new partition, accept defaults
Command (m for help): w # write changes and exit

Nothing is written until you press w. Until then you can quit with q and nothing has changed. After writing, run lsblk and you should see sdb1.

How do you create a filesystem?

mkfs formats a partition. On RHEL, XFS is the default filesystem, and ext4 is also supported.

# mkfs.xfs /dev/sdb1
# mkfs.ext4 /dev/sdb1 # alternative

mkfs erases whatever filesystem was there. Check the device name twice. A common slip is formatting sda1 when you meant sdb1.

How do you mount it, and make it permanent?

Mount the filesystem on a directory, then add a line to /etc/fstab so it returns after reboot.

# mkdir /data
# mount /dev/sdb1 /data
# blkid /dev/sdb1
/dev/sdb1: UUID="3f5a1c2e-8d7b-4c1a-9e55-0b6f1d2a7c11" TYPE="xfs"

Add this line to /etc/fstab, using your own UUID:

UUID=3f5a1c2e-8d7b-4c1a-9e55-0b6f1d2a7c11 /data xfs defaults 0 0

Use the UUID, not /dev/sdb1. Device names can change between boots when you add disks, but UUIDs do not.

Then test before rebooting:

# umount /data
# mount -a
# df -h /data

If mount -a prints an error, fix fstab now. A bad fstab line can drop a server into emergency mode at boot. On systemd systems you may also need systemctl daemon-reload after editing fstab.

What is LVM and when should you use it?

Use LVM when you expect the volume to grow. It puts a flexible layer between disks and filesystems, so you can add space later without repartitioning.

# pvcreate /dev/sdb
# vgcreate datavg /dev/sdb
# lvcreate -n datalv -L 5G datavg
# mkfs.xfs /dev/datavg/datalv

To grow it later, add free space to the volume group (a new disk with vgextend) and extend the logical volume and filesystem together:

# lvextend -r -L +2G /dev/datavg/datalv

The -r flag resizes the filesystem in the same step. XFS can be grown but not shrunk. For a fuller walk-through read what LVM is and why it is useful.

Why is my disk full when I deleted the files?

If df shows a full disk but du cannot find the files, a running process is probably holding a deleted file open. Space is released only when the process closes it.

# lsof +L1

This lists open files with a link count of zero. Restart the process that holds the file, and the space returns. Also check for inode exhaustion with df -i, which can fill a disk with millions of tiny files while free space looks fine.

Common mistakes

  • Editing fstab and rebooting without running mount -a.
  • Using /dev/sdX names in fstab instead of UUIDs.
  • Running mkfs on a device that already holds data you need.
  • Trying to shrink an XFS filesystem. It is not supported.

The Red Hat Enterprise Linux documentation covers storage management for each RHEL release in detail.

Next steps

Disk management is a core part of the RHCSA exam. Practise these steps in a throwaway VM with our RHCSA EX200 course. For daily commands, see the Linux commands cheat sheet.

Related reading

Frequently Asked Questions

Both create partitions. fdisk is simpler and interactive, and writes changes only when you press w. parted can script partitioning and handles very large disks and GPT easily, but writes changes immediately, so it needs more care.

Add a line to /etc/fstab with the filesystem UUID, mount point, type and options. Run mount -a to test it before rebooting. Use blkid to find the UUID.

df reports space used and free on a whole filesystem. du adds up the size of the files and directories it can reach. They can differ when a deleted file is still held open by a process.

Yes. mkfs creates a new filesystem and the old one is effectively erased. Always confirm the device name with lsblk before running it, and back up anything you need first.

Growing is usually safe with LVM, using lvextend -r. XFS cannot be shrunk. Ext4 can be shrunk when unmounted. Take a backup before any resize, because a mistake can destroy data.

A process may still hold the deleted file open, so the space is not freed. Run lsof +L1 to find it and restart that process. Also check df -i in case inodes ran out.

What's Your Reaction?

Like Like 0
Dislike Dislike 0
Love Love 0
Funny Funny 0
Wow Wow 0
Sad Sad 0
Angry Angry 0
Aayushi Sinha

With a passion for staying on the cutting edge of technology trends, I am dedicated to delivering content that not only informs but also inspires. Whether you need in-depth analysis pieces, informative guides, or thought-provoking opinion pieces, I craft content that resonates with tech enthusiasts and professionals alike.