In Linux, there are multiple commands and tools available to view disk partition information. Below is a comprehensive guide:
lsblk CommandPurpose: 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:
-f: Show filesystem types (ext4, ntfs, etc.)-o SIZE,NAME,FSTYPE,MOUNTPOINT: Customize output fieldsfdisk CommandPurpose: 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:
parted CommandPurpose: 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
df CommandPurpose: 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:
-h: Human-readable format (GB/MB)-T: Show filesystem typeblkid CommandPurpose: Display partition UUIDs and filesystem types.
sudo blkid
Example Output:
/dev/sda1: UUID="ABCD-EF12" TYPE="vfat" /dev/sda2: UUID="a1b2c3d4" TYPE="ext4"
mount CommandPurpose: 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)
/proc/partitionsPurpose: 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
sudo apt install gparted # Debian/Ubuntu sudo dnf install gparted # Fedora
| 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.