
Examining disk space on Linux
$ alias bysize="ls -lhS"
Using the fdisk command
fdisk The command can provide useful statistics about your disk partitions. Here’s an example:
$ sudo fdisk
fdisk: bad usage
Try 'fdisk --help' for more information.
$ sudo fdisk -l
Disk /dev/sda: 14.91 GiB, 16013942784 bytes, 31277232 sectors
Disk model: KINGSTON SNS4151
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 818C0FC9-CBBA-49E5-953B-A511A4E40A3DDevice Start End Sectors Size Type
/dev/sda1 2048 1230847 1228800 600M EFI System
/dev/sda2 1230848 3327999 2097152 1G Linux filesystem
/dev/sda3 3328000 31277055 27949056 13.3G Linux filesystemDisk /dev/zram0: 3.7 GiB, 3967811584 bytes, 968704 sectors
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytesDisk /dev/loop0: 103.99 MiB, 109043712 bytes, 212976 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/loop1: 8.44 MiB, 8847360 bytes, 17280 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Using the lsblk command
lsblk The command provides very useful information about your disk partitions. The output shown below clearly shows that there were three partitions on the disk (sda), their sizes and mount points.
$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
loop0 7:0 0 104M 1 loop /var/lib/snapd/snap/core/16928
loop1 7:1 0 8.4M 1 loop /var/lib/snapd/snap/gping/13
sda 8:0 0 14.9G 0 disk
├─sda1 8:1 0 600M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 13.3G 0 part /home
/
zram0 252:0 0 3.7G 0 disk [SWAP]
Wrap
These commands described in this post can help you estimate disk space, diagnose disk usage problems, and manage disk space effectively.
2025-01-08 18:04:58