Commands to check hard disk partitions and disk space on Linux
The following command’s output will provide information regarding the total size, disk space, memory consumed and file system.
Fdisk
In order to display all the partitions on a disk. File system details also can be seen from this command. But the only thing is that it won’t show the disk partition size.
$ fdisk -l
Disk /dev/vda: 53.0 GB, 52953088000 bytes, 103424000 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
Disk label type: dos
Disk identifier: 0x0008d0b6
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 1026047 512000 83 Linux
/dev/vda2 1026048 5220351 2097152 82 Linux swap / Solaris
/dev/vda3 5220352 103423999 49101824 83 Linux
Sfdisk
As we can see that the output of sfdisk is almost the same as the fdisk, with only difference being is that it shows size of each partition in MB
$ sfdisk -l -uM
Disk /dev/vda: 102603 cylinders, 16 heads, 63 sectors/track
Units: 1MiB = 1024*1024 bytes, blocks of 1024 bytes, counting from 0
Device Boot Start End MiB #blocks Id System
/dev/vda1 * 1 500 500 512000 83 Linux
sfdisk: start: (c, h, s) expected (2, 0, 33) found (0, 32, 33)
sfdisk: end: (c, h, s) expected (1017, 14, 30) found (63, 221, 30)
/dev/vda2 501 2548 2048 2097152 82 Linux swap / Solaris
sfdisk: start: (c, h, s) expected (1017, 14, 31) found (63, 221, 31)
sfdisk: end: (c, h, s) expected (1023, 15, 63) found (324,242, 46)
/dev/vda3 2549 50499 47951 49101824 83 Linux
sfdisk: start: (c, h, s) expected (1023, 15, 63) found (324, 242, 47)
sfdisk: end: (c, h, s) expected (1023, 15, 63) found (1023, 254, 63)
/dev/vda4 0 – 0 0 0 Empty
Parted
This command allows you to view the disk partitions details as well as it can modify the partitions too.
$ parted -l
Model: Virtio Block Device (virtblk)
Disk /dev/vda: 53.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 525MB 524MB primary ext4 boot
2 525MB 2673MB 2147MB primary linux-swap (v1)
3 2673MB 53.0GB 50.3GB primary ext4
lsblk
This command will give a list of all the storage blocks including the disk partitions and optical drives. Not only has it given details on the mount points, but also the size of the partitions.
$ lsblk
NAME MAJ: MIN RM SIZE RO TYPE MOUNTPOINT
vda 253:0 0 49.3G 0 disk
├─vda1 253:1 0 500M 0 part /boot
├─vda2 253:2 0 2G 0 part [SWAP]
└─vda3 253:3 0 46.8G 0 part /
blkid
The file system type and attributes like universally unique identifiers (UUID) of block devices can be viewed by this command. Block device means the partitions and the storage media are available.
$ blkid
/dev/vda1: UUID=”b9a72937-9472-4a68-b962-23587ff8c6e8″ TYPE=”ext4″
/dev/vda2: UUID=”c3edc4d5-67c3-4b11-aa7f-fb37de3a4221″ TYPE=”swap”
/dev/vda3: UUID=”99d0ee67-b781-4654-82fb-3eb193613caf” TYPE=”ext4″
If you need any further assistance please contact our support department.