How to Check Disk Partitions in Linux

In Linux, there are multiple commands and tools available to view disk partition information. Below is a comprehensive guide:

1. Using lsblk Command

Purpose: Lists all block devices (disks and partitions) in a tree format, showing names, sizes, and mount points.

lsblk

Example Output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 238.5G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0   732M  0 part /boot
└─sda3   8:3    0 237.3G  0 part /

Common Options:

2. Using fdisk Command

Purpose: View and manage disk partition tables (requires root privileges).

sudo fdisk -l

Example Output:

Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Device     Boot   Start       End   Sectors   Size Id Type
/dev/sda1  *       2048   1050623   1048576   512M  b W95 FAT32
/dev/sda2       1050624   2549759   1499136   732M 83 Linux
/dev/sda3       2549760 500117503 497567744 237.3G 83 Linux

Notes:

3. Using parted Command

Purpose: Advanced partition management tool supporting both GPT and MBR.

sudo parted -l

Example Output:

Model: ATA Samsung SSD 860 (scsi)
Disk /dev/sda: 256GB
Partition Table: gpt
Number  Start   End    Size    File system  Name  Flags
 1      1049kB  538MB  537MB   fat32              boot, esp
 2      538MB   1285MB 747MB   ext4
 3      1285MB  256GB  255GB   ext4

4. Using df Command

Purpose: View disk space usage of mounted partitions.

df -h

Example Output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda3       234G   56G  167G  25% /
/dev/sda1       511M  6.1M  505M   2% /boot/efi

Common Options:

5. Using blkid Command

Purpose: Display partition UUIDs and filesystem types.

sudo blkid

Example Output:

/dev/sda1: UUID="ABCD-EF12" TYPE="vfat"
/dev/sda2: UUID="a1b2c3d4" TYPE="ext4"

6. Using mount Command

Purpose: View currently mounted partitions.

mount | grep "^/dev"

Example Output:

/dev/sda3 on / type ext4 (rw,relatime)
/dev/sda1 on /boot/efi type vfat (rw,umask=0077)

7. Checking /proc/partitions

Purpose: Read kernel's partition information directly.

cat /proc/partitions

Example Output:

major minor  #blocks  name
   8        0  250059096 sda
   8        1     524288 sda1
   8        2    1499136 sda2

8. Graphical Tools

Summary: Choosing the Right Tool

Use Case Recommended Command
Quick partition structure overview lsblk
Detailed partition table information fdisk -l or parted -l
Mounted partition usage df -h
UUID and filesystem information blkid
Advanced partition management parted or GParted

These tools provide comprehensive information about disk partitions in Linux systems, suitable for both beginners and advanced users.