{"id":46,"date":"2023-12-19T07:49:00","date_gmt":"2023-12-19T07:49:00","guid":{"rendered":"https:\/\/chennaihosting.co.in\/kb\/?p=46"},"modified":"2023-12-18T12:05:02","modified_gmt":"2023-12-18T12:05:02","slug":"monitor-linux-disk-partitions-usage","status":"publish","type":"post","link":"https:\/\/chennaihosting.co.in\/kb\/monitor-linux-disk-partitions-usage\/","title":{"rendered":"10 Monitoring Linux Disk Partitions and Usage in Linux"},"content":{"rendered":"\n<p>In Linux, disk partitions refer to logically separated sections or slices of a physical hard disk drive or storage device. These partitions allow users to divide the available disk space into distinct units, each treated as an individual storage entity.<\/p>\n\n\n\n<p>Here are some essential aspects of Linux disk partitions:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Organization of Disk Space<\/strong>: Partitions enable the organization and management of disk space by creating distinct areas for specific purposes. For instance, separate partitions can be designated for the operating system files, user data, system logs, or swap space.<\/li>\n\n\n\n<li><strong>Partition Types<\/strong>:\n<ul class=\"wp-block-list\">\n<li><strong>Primary Partition<\/strong>: The primary partition is the main division on the disk that can contain a file system and bootable operating system.<\/li>\n\n\n\n<li><strong>Extended Partition<\/strong>: An extended partition is a special type used to create additional logical partitions within it.<\/li>\n\n\n\n<li><strong>Logical Partition<\/strong>: Logical partitions exist within an extended partition and provide further segmentation of disk space.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>File Systems<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Each partition typically holds its own file system, such as ext4, ext3, XFS, NTFS, FAT32, or others. The file system determines how data is organized, stored, and accessed on that partition.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Partitioning Tools<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Various command-line utilities like <code>fdisk<\/code>, <code>parted<\/code>, <code>gdisk<\/code>, and graphical tools like <code>gparted<\/code> are used to create, delete, resize, or modify partitions on a disk.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Mounting<\/strong>:\n<ul class=\"wp-block-list\">\n<li>After creating partitions, they need to be mounted onto the Linux file system to be accessible. This process involves attaching a partition to a specific directory (mount point) in the file system hierarchy.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Device Naming<\/strong>:\n<ul class=\"wp-block-list\">\n<li>In Linux, partitions are represented using device names such as <code>\/dev\/sda1<\/code>, <code>\/dev\/sdb2<\/code>, etc. The initial part (<code>\/dev\/sd<\/code>) refers to the device itself, while the letter and number signify the partition number.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Usage and Benefits<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Disk partitions allow better organization of data, facilitating backup, system maintenance, and data isolation.<\/li>\n\n\n\n<li>They also aid in securing critical system areas from accidental data corruption or user errors by isolating different types of data onto separate partitions.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Understanding disk partitions is crucial for managing disk space effectively, optimizing system performance, and ensuring data security and accessibility in Linux systems. Proper planning and caution are recommended when creating, modifying, or managing disk partitions to avoid data loss or system instability.<\/p>\n\n\n\n<p>A System Administrator (SysAdmin) in the context of <a href=\"https:\/\/www.squarebrothers.com\/\" data-type=\"link\" data-id=\"https:\/\/www.squarebrothers.com\/\" target=\"_blank\" rel=\"noopener\">hosting<\/a> plays a crucial role in managing and maintaining the infrastructure and services that provide <a href=\"https:\/\/chennaihosting.co.in\/\" data-type=\"link\" data-id=\"https:\/\/chennaihosting.co.in\/\">hosting<\/a> solutions.<\/p>\n\n\n\n<p>Monitoring the space usage of storage devices is one of the most important tasks for a\u00a0<strong>SysAdmin<\/strong>, which ensures that there is adequate free space available on the storage devices to maintain the efficient operation of your Linux system.<\/p>\n\n\n\n<div class=\"wp-block-rank-math-toc-block\" id=\"rank-math-toc\"><h2>Table of Contents<\/h2><nav><ul><li><a href=\"#1-fdisk-fixed-disk-command\">1. fdisk (fixed disk) Command<\/a><\/li><li><a href=\"#2-sfdisk-scriptable-fdisk-command\">2. sfdisk (scriptable fdisk) Command<\/a><\/li><li><a href=\"#3-cfdisk-curses-fdisk-command\">3. cfdisk (curses fdisk) Command<\/a><\/li><li><a href=\"#4-parted-command\">4. Parted Command<\/a><\/li><li><a href=\"#5-lsblk-list-block-command\">5. lsblk (list block) Command<\/a><\/li><li><a href=\"#6-blkid-block-id-command\">6. blkid (block id) Command<\/a><\/li><li><a href=\"#7-hwinfo-hardware-info-command\">7. hwinfo (hardware info) Command<\/a><\/li><li><a href=\"#8-df-disk-filesystem-command\">8. df (disk filesystem) Command<\/a><\/li><li><a href=\"#9-du-disk-usage-command\">9. du (disk usage) Command<\/a><\/li><li><a href=\"#10-pydf-python-df-command\">10. pydf (python df) Command<\/a><ul><li><a href=\"#what-to-do-when-your-linux-disk-partition-is-running-out-of-space\">What to Do When Your Linux Disk\/Partition Is Running Out of Space?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n\n\n\n<p><h2 style=\"box-sizing: inherit; margin: 0px 0px 20px; padding: 0px; border-width: 0px 0px 2px; border-top-style: initial; border-right-style: initial; border-bottom-style: dashed; border-left-style: initial; border-top-color: initial; border-right-color: initial; border-bottom-color: rgb(222, 240, 255); border-left-color: initial; border-image: initial; font-family: &quot;Be Vietnam&quot;, sans-serif; font-size: 22px; font-weight: 600; line-height: 1.4em; white-space-collapse: collapse;\">List of Command Line Tools to Check Linux Disk Partitions<\/h2>Following is a list of command line utilities for printing storage device partition tables and space usage.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-fdisk-fixed-disk-command\">1. fdisk (fixed disk) Command<\/h3>\n\n\n\n<p><strong>fdisk<\/strong>\u00a0is a powerful and popular command line tool used for\u00a0creating and manipulating disk partition tables. It supports various partition table formats, including GPT, MBR, Sun, SGI, and BSD.<\/p>\n\n\n\n<p>You can use&nbsp;<strong>fdisk<\/strong>\u2018s user-friendly, text-based, menu-driven interface to perform tasks such as displaying, creating, resizing, deleting, modifying, copying, and moving partitions on storage disks<\/p>\n\n\n\n<p>The\u00a0fdisk command\u00a0below will print the partition table of all mounted block devices:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fdisk -l<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"169\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/1-1-1024x169.png\" alt=\"\" class=\"wp-image-47\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/1-1-1024x169.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/1-1-300x50.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/1-1-768x127.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/1-1-1536x254.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/1-1.png 1899w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-sfdisk-scriptable-fdisk-command\">2. sfdisk (scriptable fdisk) Command<\/h3>\n\n\n\n<p><strong>sfdisk<\/strong>&nbsp;works similarly to&nbsp;<strong>fdisk<\/strong>&nbsp;as it can print or manipulate a storage disk partition table. However,&nbsp;<strong>sfdisk<\/strong>&nbsp;offers additional features that are not available in&nbsp;<strong>fdisk<\/strong>. You can use it just like&nbsp;<strong>fdisk<\/strong>, and it also supports GPT, MBR, Sun, and SGI partition tables.<\/p>\n\n\n\n<p>One difference between the two is that\u00a0<strong>sfdisk<\/strong>\u00a0does not create the standard system partitions for SGI and SUN disk labels like\u00a0<strong>fdisk<\/strong>\u00a0does.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sfdisk -l<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"198\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/2-1-1024x198.png\" alt=\"\" class=\"wp-image-48\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/2-1-1024x198.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/2-1-300x58.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/2-1-768x148.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/2-1-1536x297.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/2-1.png 1901w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-cfdisk-curses-fdisk-command\">3. cfdisk (curses fdisk) Command<\/h3>\n\n\n\n<p><strong>cfdisk<\/strong>&nbsp;is a simple program used for printing and managing disk partitions by providing basic partitioning functionality through a user-friendly interface that operates similarly to more powerful commands like&nbsp;<strong>fdisk<\/strong>&nbsp;and&nbsp;<strong>sfdisk<\/strong>, enabling users to view, add, delete, and modify hard disk partitions.<\/p>\n\n\n\n<p>Use the right and left arrow keys to move the highlighter over the menu tabs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cfdisk<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-parted-command\">4. Parted Command<\/h3>\n\n\n\n<p>The\u00a0parted command\u00a0is a versatile and powerful utility for managing disk partitions on Unix-like operating systems. With a wide array of features, it allows users to create, resize, delete, and manipulate partitions on hard drives, making it essential for system administrators and advanced users.<\/p>\n\n\n\n<p>The&nbsp;<strong>parted<\/strong>&nbsp;tool supports both&nbsp;<strong>MBR<\/strong>&nbsp;(<strong>Master Boot Record<\/strong>) and&nbsp;<strong>GPT<\/strong>&nbsp;(<strong>GUID Partition Table<\/strong>) partitioning schemes and provides options for various file systems.<\/p>\n\n\n\n<p>Additionally, parted provides a range of advanced features, such as alignment control and the ability to create, resize and\u00a0copy disk partitions\u00a0(add a progress bar while copying), making it an indispensable tool for disk management tasks.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>parted -l<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"155\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/3-1-1024x155.png\" alt=\"\" class=\"wp-image-49\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/3-1-1024x155.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/3-1-300x45.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/3-1-768x116.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/3-1-1536x233.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/3-1.png 1902w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-lsblk-list-block-command\">5. lsblk (list block) Command<\/h3>\n\n\n\n<p>The\u00a0lsblk command\u00a0provides a detailed overview of storage devices, including hard drives, solid-state drives, and removable media, along with their associated information like size, partitions, and mount points.<\/p>\n\n\n\n<p><strong>lsblk<\/strong>&nbsp;aids in system administration tasks, making it easier to identify available storage resources, understand disk configurations, and manage storage devices efficiently.<\/p>\n\n\n\n<p>Its straightforward output and customization options make it a valuable tool for system administrators, helping ensure effective storage management and troubleshooting.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>lsblk<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"75\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/4-1-1024x75.png\" alt=\"\" class=\"wp-image-50\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/4-1-1024x75.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/4-1-300x22.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/4-1-768x57.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/4-1-1536x113.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/4-1.png 1900w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6-blkid-block-id-command\">6. blkid (block id) Command<\/h3>\n\n\n\n<p>The&nbsp;<strong>blkid<\/strong>&nbsp;command is used to identify block devices such as hard drives and partitions by their Universally Unique Identifier (<strong>UUID<\/strong>) or other attributes. It provides crucial information about storage devices, making it easier to mount and manage them.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>blkid<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"7-hwinfo-hardware-info-command\">7. hwinfo (hardware info) Command<\/h3>\n\n\n\n<p>The&nbsp;<strong>hwinfo<\/strong>&nbsp;command is used to provide comprehensive data about the system\u2019s components, including CPU, RAM, storage devices, graphics cards, network interfaces, and more.<\/p>\n\n\n\n<p>The system administrators and users employ \u2018<strong>hwinfo<\/strong>\u2018 to diagnose hardware issues, identify compatible drivers, and enhance system performance.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>hwinfo<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"list-of-command-line-tools-to-monitor-linux-disk-space-usage\">List of Command Line Tools to Monitor Linux Disk Space Usage<\/h2>\n\n\n\n<p>The following list includes command-line utilities for monitoring Linux disk space usage.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"8-df-disk-filesystem-command\">8. df (disk filesystem) Command<\/h3>\n\n\n\n<p>The\u00a0df command\u00a0is used to retrieve essential information about disk usage and available storage space on Linux file system usage.<\/p>\n\n\n\n<p>The \u201c<strong>df<\/strong>\u201d command assists users in monitoring disk space allocation, identifying potential storage issues, and making informed decisions regarding data management and cleanup.<\/p>\n\n\n\n<p>The&nbsp;<code>'-hT'<\/code>&nbsp;switch in the command below enables human-readable reporting of disk size, used space, available space, and used space percentages.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>df -hT<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"117\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/5-1-1024x117.png\" alt=\"\" class=\"wp-image-51\" style=\"width:840px;height:auto\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/5-1-1024x117.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/5-1-300x34.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/5-1-768x88.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/5-1-1536x175.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/5-1.png 1900w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"9-du-disk-usage-command\">9. du (disk usage) Command<\/h3>\n\n\n\n<p>The\u00a0du command\u00a0is used to allow users to assess the space occupied by files and directories on their storage device in a human-readable format.<\/p>\n\n\n\n<p>The\u00a0<strong>du command<\/strong>\u00a0helps users identify which files or directories consume the most space, aiding in disk management, cleanup, and optimization tasks. This command is invaluable for system administrators and users seeking to maintain efficient disk usage.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>du -sh \/home\/<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"35\" src=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/6-1-1024x35.png\" alt=\"\" class=\"wp-image-52\" srcset=\"https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/6-1-1024x35.png 1024w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/6-1-300x10.png 300w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/6-1-768x26.png 768w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/6-1-1536x52.png 1536w, https:\/\/chennaihosting.co.in\/kb\/wp-content\/uploads\/2023\/12\/6-1.png 1904w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"10-pydf-python-df-command\">10. pydf (python df) Command<\/h3>\n\n\n\n<p>The\u00a0pydf command\u00a0is an exceptional Python command line utility and a great replacement for the\u00a0<strong>df<\/strong>\u00a0command in Linux. It uses distinct colors to highlight disk partitions with specific attributes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pydf<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"what-to-do-when-your-linux-disk-partition-is-running-out-of-space\">What to Do When Your Linux Disk\/Partition Is Running Out of Space?<\/h4>\n\n\n\n<p>Once you realize that any of your storage disk(s) is running out of space or is full, you should:<\/p>\n\n\n\n<p>First, make a backup of all your important files on the system using any of the\u00a0Linux system backup tools.Next, check which files or directories are occupying the biggest amount of space on the disk(s) using the\u00a0du command.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 the\u00a0rm command\u00a0or you can\u00a0CCleaner tools\u00a0to find and delete unwanted files in Linux.If your root partition is getting full, you can\u00a0resize root partition using LVM, it should be pretty straight.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>We hope you&#8217;ve found this useful<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Linux, disk partitions refer to logically separated sections or [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":60,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[3,4],"class_list":["post-46","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-disk","tag-partitions"],"_links":{"self":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/46","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":5,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":59,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/posts\/46\/revisions\/59"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/media\/60"}],"wp:attachment":[{"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chennaihosting.co.in\/kb\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}