5 Ways to Check disk space in Linux

Table of Contents

Understanding device naming and usage are essential if we want to competently install and use disks in Linux. Device naming has changed and evolved over the numerous versions of Linux that are constantly being put out and as the technology changes.

The following Linux commands can be used to check disk space in Linux.

  • du -h shows disk usage in human-readable format for all directories and subdirectories
  • du -a shows disk usage for all files
  • df -h shows disk space in human-readable format
  • lsblk -f
  • fdisk -l
  • parted -l


Understanding Disk Naming standard

  • /dev/hd* – IDE disks. /dev/hda will be the first IDE hard disk, /dev/hdb will be second IDE hard disk, and so on.
  • /dev/sd* – SCSI or SATA disks including SSDs. /dev/sda will be the first SATA/SCSI hard disk, /dev/sdb will be second SATA/SCSI hard disk, and so on.
  • /dev/nvme* – NVM Express (NVMe) pci SSD. /dev/nvme0n1 will be first NVMe SSD, /dev/nvme1n1 will be second NVMe SSD, and so on.

Check disk space in Linux with lsblk command

lsblk command in Linux can list information about all available or the specified block devices. It reads the sysfs filesystem and udev db to gather information.

To list all block devices, run:

  • man lsblk
  • # lsblk
  • # lsblk /dev/DEVICE
  • # lsblk /dev/sda
  • # lsblk -l
  • # lsblk -d | grep disk

We can also fine-tune information displayed by lsblk as follows to list only Linux partitions and other data:


Check disk space Using fdisk command in Linux

fdisk is a dialog-driven program for creation and manipulation of partition tables. It understands GPT, MBR, Sun, SGI and BSD partition tables.

The -l options shows the partition tables for the specified devices and then exit. If no devices are given, those mentioned in /proc/partitions (if that exists) are used. we can specify device name as follows (in this example list partitions for /dev/sda):

  • # fdisk -l /dev/sda
  • # fdisk -l

Check disk space with parted command in Linux

Parted is a famous command-line tool that allows us to easily manage hard disk partitions. It can help us add, delete, shrink and extend disk partitions along with the file systems located on them.

Partition Table (GPT) is a standard for the layout of the partition table on a physical hard disk. It is a part of the Extensible Firmware Interface (EFI) standard proposed by Intel as a replacement for the outdated PC BIOS, one of the few remaining relics of the original IBM PC. EFI uses GPT where BIOS uses a Master Boot Record (MBR).

In this example list partitions on /dev/sdb using the parted command:

Pass the -l OR –list option to the parted command to list partition layout on all block devices:

# parted -l

Check Disk size Using sfdisk command in Linux

sfdisk command is a partition table editor. It is similar to fdisk and cfdisk, but with additional features.

This is very similar to fdisk, however sfdisk allows us to see both physical and logical volumes and also gives us a “summary” of the actual physical volumes’ partitions with the cylinders (start and end), sectors, size and type.

sfdisk -l device will list the partitions on the specified device. If the device argument is omitted, the partitions on all hard disks are listed. The following example lists the partitions on device /dev/hdc:

  • sfdisk -l /dev/hdc


Check disks with blkid command in Linux

Prints the block device (partitions and storage media) attributes like uuid and file system type. Does not report the space on the partitions.

  • $ sudo blkid
  • /dev/sda1: UUID=”5E38BE8B38BE6227″ TYPE=”ntfs”
  • /dev/sda5: UUID=”4668484A68483B47″ TYPE=”ntfs”
  • /dev/sda6: UUID=”6fa5a72a-ba26-4588-a103-74bb6b33a763″ TYPE=”ext4″
  • /dev/sda7: UUID=”94443023-34a1-4428-8f65-2fb02e571dae” TYPE=”swap”
  • /dev/sda8: UUID=”13f35f59-f023-4d98-b06f-9dfaebefd6c1″ TYPE=”ext4″
  • /dev/sdb1: UUID=”08D1-8024″ TYPE=”vfat”

Linux command to check disk space

  • df command – Shows the amount of disk space used and available on Linux file systems.
  • du command – Display the amount of disk space used by the specified files and for each subdirectory.
Share on facebook
Share on twitter
Share on linkedin

If you meet any issues with Linux, record them with Loom and send the link to us here. We will reply ASAP.

Load WordPress Sites in as fast as 37ms!