9 Tools to Monitor Linux Disk Partitions and Usage in Linux

In this article, we will review a number of Linux command line utilities that you can use to check disk partitions in Linux.

Monitoring storage device(s) space usage is one of the most important tasks of a SysAdmin, this helps to ensure adequate free space remains on the storage devices for efficient running of your Linux system.

Command Line Utilities To Print Linux Disk Partition Table

The following is a list of command line utilities for printing storage device partition table and space usage.

1. fdisk (fixed disk) Command

fdisk is a powerful and popular command line tool used for creating and manipulating disk partition tables.

It supports GPT, MBR, Sun, SGI and BSD partition tables. You can run fdisk commands through its user-friendly, text based and menu driven interface to display, create, resize, delete, modify, copy and move partitions on storage disks.

The fdisk command below will print the partition table of all mounted block devices:

$ sudo fdisk -l
fdisk – List Linux Disk Partition Table
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 82213CA8-50E4-4DDB-9337-85E46DA03430
Device          Start        End    Sectors   Size Type
/dev/sda1        2048    2050047    2048000  1000M Windows recovery environment
/dev/sda2     2050048    2582527     532480   260M EFI System
/dev/sda3     2582528    4630527    2048000  1000M Lenovo boot partition
/dev/sda4     4630528    4892671     262144   128M Microsoft reserved
/dev/sda5     4892672 1173295103 1168402432 557.1G Microsoft basic data
/dev/sda6  1870348288 1922777087   52428800    25G Microsoft basic data
/dev/sda7  1922777088 1953523711   30746624  14.7G Windows recovery environment
/dev/sda8  1173295104 1173297151       2048     1M BIOS boot
/dev/sda9  1173297152 1181110271    7813120   3.7G Linux swap
/dev/sda10 1181110272 1870348287  689238016 328.7G Linux filesystem
Partition table entries are not in disk order.

For more usage and examples about fdisk command read 10 ‘fdisk’ Command Examples to Manage Partitions

2. sfdisk (scriptable fdisk) Command

sfdisk works more like fdisk, it prints or manipulates a storage disk partition table. However, sfdisk offers extra features not available in fdisk. You can use it just as fdisk, it also supports GPT, MBR, Sun and SGI partition tables.

One difference between the two is that sfdisk does not create the standard system partitions for SGI and SUN disk labels like fdisk does.

$ sudo sfdisk -l
sfdisk – Check Linux Disk Partition Table
Disk /dev/sda: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 82213CA8-50E4-4DDB-9337-85E46DA03430
Device          Start        End    Sectors   Size Type
/dev/sda1        2048    2050047    2048000  1000M Windows recovery environment
/dev/sda2     2050048    2582527     532480   260M EFI System
/dev/sda3     2582528    4630527    2048000  1000M Lenovo boot partition
/dev/sda4     4630528    4892671     262144   128M Microsoft reserved
/dev/sda5     4892672 1173295103 1168402432 557.1G Microsoft basic data
/dev/sda6  1870348288 1922777087   52428800    25G Microsoft basic data
/dev/sda7  1922777088 1953523711   30746624  14.7G Windows recovery environment
/dev/sda8  1173295104 1173297151       2048     1M BIOS boot
/dev/sda9  1173297152 1181110271    7813120   3.7G Linux swap
/dev/sda10 1181110272 1870348287  689238016 328.7G Linux filesystem
Partition table entries are not in disk order.

For more usage, go through sfdisk man pages.

3. cfdisk (curses fdisk) Command

cfdisk is simple program used for printing and managing disk partitions. It offers basic partitioning functionality with a user-friendly interface. It operates similar to the more powerful commands: fdisk and sfdisk allowing users to view, add, delete, and modify hard-disk partitions.

Use the right and left arrow keys to move the highlighter over the menu tabs.

$ sudo cfdisk
cfdisk – Print Linux Disk Partition Table
                                 Disk: /dev/sda
Size: 931.5 GiB, 1000204886016 bytes, 1953525168 sectors
Label: gpt, identifier: 82213CA8-50E4-4DDB-9337-85E46DA03430
Device          Start        End    Sectors   Size Type
>>  Free space       2048       2048          0     0B
/dev/sda1        2048    2050047    2048000  1000M Windows recovery environm
/dev/sda2     2050048    2582527     532480   260M EFI System
/dev/sda3     2582528    4630527    2048000  1000M Lenovo boot partition
/dev/sda4     4630528    4892671     262144   128M Microsoft reserved
/dev/sda5     4892672 1173295103 1168402432 557.1G Microsoft basic data
/dev/sda6  1870348288 1922777087   52428800    25G Microsoft basic data
/dev/sda7  1922777088 1953523711   30746624  14.7G Windows recovery environm
/dev/sda8  1173295104 1173297151       2048     1M BIOS boot
/dev/sda9  1173297152 1181110271    7813120   3.7G Linux swap
/dev/sda10 1181110272 1870348287  689238016 328.7G Linux filesystem
┌────────────────────────────────────────────────────────────────────────────┐
│      Filesystem: ntfs                                                      │
│Filesystem label: WINRE_DRV                                                 │
└────────────────────────────────────────────────────────────────────────────┘
[   New  ]  [  Quit  ]  [  Help  ]  [  Sort  ]  [  Write ]  [  Dump  ]

4. Parted Command

parted is also a well-known command line tool for displaying and manipulating disk partitions. It understands multiple partition table formats, including MBR and GPT.

Parted can be used for creating space for new partitions, reorganizing disk usage, and copying data to new hard disks and beyond.

$ sudo parted -l
parted – A Partition Manipulation Tool
Model: ATA ST1000LM024 HN-M (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number  Start   End     Size    File system     Name                          Flags
1      1049kB  1050MB  1049MB  ntfs            Basic data partition          hidden, diag
2      1050MB  1322MB  273MB   fat32           EFI system partition          boot, hidden, esp
3      1322MB  2371MB  1049MB  fat32           Basic data partition          hidden
4      2371MB  2505MB  134MB                   Microsoft reserved partition  msftres
5      2505MB  601GB   598GB   ntfs            Basic data partition          msftdata
8      601GB   601GB   1049kB                                                bios_grub
9      601GB   605GB   4000MB  linux-swap(v1)
10      605GB   958GB   353GB   ext4
6      958GB   984GB   26.8GB  ntfs            Basic data partition          msftdata
7      984GB   1000GB  15.7GB  ntfs            Basic data partition          hidden, diag

5. lsblk (list block) Command

lsblk prints information including name, type, mountpoint concerning all available or particular mounted block device(s) excluding RAM disks.

$ lsblk
lsblk – List Linux Block Devices
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda       8:0    0 931.5G  0 disk
├─sda1    8:1    0  1000M  0 part
├─sda2    8:2    0   260M  0 part
├─sda3    8:3    0  1000M  0 part
├─sda4    8:4    0   128M  0 part
├─sda5    8:5    0 557.1G  0 part
├─sda6    8:6    0    25G  0 part
├─sda7    8:7    0  14.7G  0 part
├─sda8    8:8    0     1M  0 part
├─sda9    8:9    0   3.7G  0 part [SWAP]
└─sda10   8:10   0 328.7G  0 part /
sr0      11:0    1  1024M  0 rom

6. blkid (block id) Command

blkid a utility that locates or displays block device attributes (NAME=value pair) such as device or partition name, label, its filesystem type among others.

$ blkid
blkid – Print Block Device Attributes
/dev/sda1: LABEL="WINRE_DRV" UUID="D4A45AAAA45A8EBC" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="dcc4de2d-8fc4-490f-85e0-50c2e18cc33d"
/dev/sda2: LABEL="SYSTEM_DRV" UUID="185C-DA5B" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="b13c479a-d63b-4fec-9aee-f926fe7b0b16"
/dev/sda3: LABEL="LRS_ESP" UUID="0E60-2E0E" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="d464feab-0791-4866-a36b-90dbe6d6a437"
/dev/sda5: LABEL="Windows8_OS" UUID="18D0632AD0630CF6" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="8a66bd5b-8624-4fdb-9ad8-18d8cd356160"
/dev/sda6: LABEL="LENOVO" UUID="9286FFD986FFBC33" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="92fbbea9-6bcd-4ae5-a322-c96a07a81013"
/dev/sda7: LABEL="PBR_DRV" UUID="ECD06683D066543C" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="0e2878a2-377c-4b35-9454-f1f2c6398405"
/dev/sda9: UUID="e040de62-c837-453e-88ee-bd9000387083" TYPE="swap" PARTUUID="f5eef371-a152-4208-a62f-0fb287f9acdd"
/dev/sda10: UUID="bb29dda3-bdaa-4b39-86cf-4a6dc9634a1b" TYPE="ext4" PARTUUID="26b60905-1c39-4fd4-bdce-95c517c781fa"

7. hwinfo (hardware info) Command

hwinfo generally prints detailed information about system hardware. But you can run the hwinfo command below, where you employ the -- <HARDWARE_ITEM> option to list all hardware items of the specified type (in this case block devices such as disks and their partitions).

 

To restrict the information to a summary, use --short option as in the command below:

$ hwinfo --short --block
hwinfo – Print Linux Hardware Information
disk:
/dev/sda             ST1000LM024 HN-M
/dev/ram0            Disk
/dev/ram1            Disk
/dev/ram2            Disk
/dev/ram3            Disk
/dev/ram4            Disk
/dev/ram5            Disk
/dev/ram6            Disk
/dev/ram7            Disk
/dev/ram8            Disk
/dev/ram9            Disk
/dev/ram10           Disk
/dev/ram11           Disk
/dev/ram12           Disk
/dev/ram13           Disk
/dev/ram14           Disk
/dev/ram15           Disk
partition:
/dev/sda1            Partition
/dev/sda2            Partition
/dev/sda3            Partition
/dev/sda4            Partition
/dev/sda5            Partition
/dev/sda6            Partition
/dev/sda7            Partition
/dev/sda8            Partition
/dev/sda9            Partition
/dev/sda10           Partition
cdrom:
/dev/sr0             PLDS DVD-RW DA8A5SH

Make sure hwinfo tool installed on your system to get the above results..

Command Line Utilities To Monitor Disk Space Usage in Linux

The following is a list of command line utilities for monitoring Linux disk space usage.

8. df (disk filesystem) Command

df prints a summary of file system disk space usage on the terminal. In the command below, -hT switch enables reporting of the disk size, used space, available space and used space percentages in human-readable format.

$ df -hT
df – Show Linux Disk Space Usage
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs          tmpfs     788M  9.6M  779M   2% /run
/dev/sda10     ext4      324G  132G  176G  43% /
tmpfs          tmpfs     3.9G   86M  3.8G   3% /dev/shm
tmpfs          tmpfs     5.0M  4.0K  5.0M   1% /run/lock
tmpfs          tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
cgmfs          tmpfs     100K     0  100K   0% /run/cgmanager/fs
tmpfs          tmpfs     788M   32K  788M   1% /run/user/1000

9. pydf (python df) Command

pydf is an exceptional Python command line utility and a great replacement of df in Linux. It uses distinct colors to highlight disk partitions with specific attributes.

$ pydf
pydf – Show Colourised Linux Disk Space Usage
Filesystem Size Used Avail Use%                                                          Mounted on
/dev/sda10 323G 132G  175G 40.7 [######################................................] /

Make sure pydf utility installed on the system, if not install it using Install Pydf Tool to Monitor Linux Disk Usage.

What if a disk/partition is running out of space in Linux?

Once you realize that any of your storage disk(s) is running out of space or is full, you should:

  1. First, make a backup of all your important files on the system using any of the Linux system backup tools.
  2. Next, check which files or directories are occupying the biggest amount of space on the disk(s) using the du command.
  3. Then delete from the storage disk(s), any files that are no longer important or that you will not use in the future with the help of rm command or you can fslint tool to find and delete unwanted files in Linux.
  4. If your root partition is getting full, you can resize root partition using LVM, it should be pretty straight.

Note: In case you delete any important file, you can recover the deleted file in Linux.

In this article, we have talked about a number of useful command line utilities for displaying storage disk partition table and monitoring space usage.

If there is any important command line utility for the same purpose, that we have left out? Let us know via the comment section below. You can possibly ask a question or provide us feedback as well.

admin

leave a comment

one × 2 =

Create Account



Log In Your Account



%d bloggers like this: