![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Great tools to check linux disk partitions and usage in linux
Are you working as a system admin, then you should know these tools to manage disk space. This article explains about how to check Linux Disk Partitions and Usage in Linux.
Fdisk
Fdisk is a text based utility. By utilizing fdisk, you can create a brand new partition, delete the present partition, or exchange existing partition.
To get the more information about fdisk, use the following command –
$ fdisk
The sample out should be like this –
Usage: fdisk [options] change partition table fdisk [options] -l [] list partition table(s) Display or manipulate a disk partition table. Options: -b, --sector-size physical and logical sector size -B, --protect-boot don't erase bootbits when create a new label -c, --compatibility[=] mode is 'dos' or 'nondos' (default) -L, --color[=] colorize output (auto, always or colors are enabled by default -l, --list display partitions end exit -o, --output output columns -t, --type recognize specified partition table type only -u, --units[=] display units: 'cylinders' or 'sectors' (default) -s, --getsz display device size in 512-byte sectors [DEPRECATED] --bytes print SIZE in bytes rather than in human readable format -C, --cylinders specify the number of cylinders -H, --heads specify the number of heads -S, --sectors specify the number of sectors per track -h, --help display this help and exit -V, --version output version information and exit Available columns (for -o): gpt: Device Start End Sectors Size Type Type-UUID Attrs Name UUID dos: Device Start End Sectors Cylinders Size Type Id Attrs Boot End-C/H/S Start-C/H/S bsd: Slice Start End Sectors Cylinders Size Type Bsize Cpg Fsize sgi: Device Start End Sectors Cylinders Size Type Id Attrs sun: Device Start End Sectors Cylinders Size Type Id Flags ..........................................................................................
To get the list of devices, use the following command –
$ sudo fdisk -l
The sample output should be like this –
Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 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 Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 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 Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 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
sfdisk
sfdisk is a script-based tool to display or manipulate a disk partition table.
To get more information about sfdisk, use the following command –
$ man sfdisk
The sample output should be like this –
SFDISK(8) System Administration SFDISK(8) NAME sfdisk - display or manipulate a disk partition table SYNOPSIS sfdisk [options] device [-N partition-number] sfdisk [options] command DESCRIPTION sfdisk is a script-oriented tool for partitioning any block device. Since version 2.26 sfdisk supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any tionality for CHS (Cylinder-Head-Sector) addressing. CHS has never been important for Linux, and this addressing concept does not make any sense for new devices. sfdisk (since version 2.26) aligns the start and end of partitions to block-device I/O limits when relative sizes are specified, or when the default values are used. sfdisk does not create the standard system partitions for SGI and SUN disk labels like fdisk(8) does. It necessary to explicitly create all partitions including whole-disk system partitions. ........................................................................................
To get the list of devices, use the following command –
$ sfdisk -l
The sample output should be like this –
Disk /dev/ram0: 64 MiB, 67108864 bytes, 131072 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 Disk /dev/ram1: 64 MiB, 67108864 bytes, 131072 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 Disk /dev/ram2: 64 MiB, 67108864 bytes, 131072 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
lsblk
lsblk gives information about all or particular block devices. To get the more information about lsblk, use the following command –
$ man lsblk
The sample output should be like this –
LSBLK(8) System Administration LSBLK(8) NAME lsblk - list block devices SYNOPSIS lsblk [options] [device...] DESCRIPTION lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information. The command prints all block devices (except RAM disks) in a tree-like format by default. Use lsblk --help to get a list of all available columns. The default output, as well as the default output from options like --fs and --topology, is subject to change. So whenever pos‐sible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using --output col‐umns-list in environments where a stable output is required. Note that lsblk might be executed in time when udev does not have all information about recently added or modified devices yet. In this case it is recommended to use udevadm settle before lsblk to synchronize with udev. .................................................................................................
To get the list of devices, use the following command –
$ lsblk
The sample output should be like this –
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465.8G 0 disk ├─sda1 8:1 0 462.3G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 3.4G 0 part [SWAP] sr0 11:0 1 1024M 0 rom
lsscsi
It provides information about a list of SCSI devices (or hosts) currently attached to the system.To get the more information about lsscsi, use the following command –
$ man lsscsi
The sample output should be like this –
NAME lsscsi - list SCSI devices (or hosts) and their attributes SYNOPSIS lsscsi [--classic] [--device] [--generic] [--help] [--hosts] [--kname] [--list] [--lunhex] [--long] [-- protection] [--protmode] [--scsi_id] [--size] [--sysfsroot=PATH] [--transport] [--verbose] [--version] [--wwn] [H:C:T:L] DESCRIPTION Uses information in sysfs (Linux kernel series 2.6 and later) to list SCSI devices (or hosts) currently attached to the system.Options can be used to control the amount and form of information provided for each device. If a H:C:T:L argument is given then it acts as a filter and only devices that match it are listed. The colons don't have to be present, and '-', '*', '?' or missing arguments at the end are interpreted as wildcards. The default is '*:*:*:*' which means to match everything. Any filter string using '*' of '?' should be surrounded by single or double quotes to stop shell expansions. If '-' is used as a wildcard then the whole filter argument should be prefixed by '-- ' to tell this utility there are no more options on the command line to be interpreted. A leading '[' and trailing ']' are permitted (e.g. '[1:0:0]' matches all LUNs on 1:0:0). May also be used to filter --hosts in which case only the H is active and may be either a number or in the form "host" where is a host number. ............................................................................................
To get the list of SCSI devices (or hosts) currently attached, use the following command –
$ lsscsi
The sample output should be like this –
[0:0:0:0] disk ATA WDC WD5000LPVX-7 1A01 /dev/sda [1:0:0:0] cd/dvd TSSTcorp DVD+-RW SU-208FB D200 /dev/sr0
In this post, we have learned some very useful tools – “To check Linux Disk Partitions and Usage in Linux”. In our next articles, we will come up with more Linux based tricks and tips. Keep reading!