Useful commands to check hard disk partitions


fdisk is a general partitioning tool, and was the de-facto standard at the time all hard drive were under 2TB. It’s still a useful tool today. You can use it to display partitions information like this:

$ sudo fdisk -l

Disk /dev/sda: 298.1 GiB, 320072933376 bytes, 625142448 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
Disklabel type: dos
Disk identifier: 0x000ae2b8

Device     Boot    Start       End   Sectors   Size Id Type
/dev/sda1  *        2048  60000255  59998208  28.6G 83 Linux
/dev/sda3       60000256 625141759 565141504 269.5G  5 Extended
/dev/sda5       60002304  75001855  14999552   7.2G 82 Linux swap / Solaris
/dev/sda6       75003904 625141759 550137856 262.3G 83 Linux

As you can see each partition is reported separately with details about size, start and end sectors id, type, etc…


With disk > 2TB a new type type of partitioning table was needed to replace the old MBR. That the GPT (GUID Partitioning Table). New partitioning tool were needed too, hence the creation of parted. Like fdisk you can use parted to display partitions information:

$ sudo parted -l

Model: ATA Hitachi HTS72323 (scsi)
Disk /dev/sda: 320GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  30.7GB  30.7GB  primary   ext4            boot
 3      30.7GB  320GB   289GB   extended
 5      30.7GB  38.4GB  7680MB  logical   linux-swap(v1)
 6      38.4GB  320GB   282GB   logical   ext4


df displays the amount of disk space available on all currently mounted file systems.

$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              29G  5.3G   22G  20% /
udev                   10M     0   10M   0% /dev
tmpfs                 1.2G   31M  1.2G   3% /run
tmpfs                 2.9G   54M  2.9G   2% /dev/shm
tmpfs                 5.0M  4.0K  5.0M   1% /run/lock
tmpfs                 2.9G     0  2.9G   0% /sys/fs/cgroup
/dev/sda6             259G  207G   39G  85% /home
tmpfs                 587M   16K  587M   1% /run/user/10991
/home/daber/.Private  259G  207G   39G  85% /home/daber

Note that df can take additional arguments to customize it output:

$ df -h --output=source,fstype,size,used,avail,pcent,target -x tmpfs -x devtmpfs
Filesystem           Type      Size  Used Avail Use% Mounted on
/dev/sda1            ext4       29G  5.3G   22G  20% /
/dev/sda6            ext4      259G  207G   39G  85% /home
/home/daber/.Private ecryptfs  259G  207G   39G  85% /home/daber


di is kind of like a more advanced version of df:

$ di
Filesystem         Mount               Size     Used    Avail %Used  fs Type 
/dev/sda1          /                  28.0G     5.2G    21.4G   24%  ext4    
tmpfs              /dev/shm            2.9G     0.1G     2.8G    2%  tmpfs   
tmpfs              /etc/machine-id     1.1G     0.0G     1.1G    3%  tmpfs   
/dev/sda6          /home             258.1G   206.1G    38.8G   85%  ext4    
/home/daber/.Priva /home/daber       258.1G   206.1G    38.8G   85%  ecryptfs
tmpfs              /run                1.1G     0.0G     1.1G    3%  tmpfs   
tmpfs              /run/lock           5.0M     0.0M     5.0M    0%  tmpfs   
tmpfs              /run/user/10991   586.3M     0.0M   586.3M    0%  tmpfs   
tmpfs              /sys/fs/cgroup      2.9G     0.0G     2.9G    0%  tmpfs   

di has many formatting options, which is very interesting for scripting.


lsblk lists information about all available block devices. It doesn’t report the used/free disk space on partitions, but indicate their type and mountpoint:

$ sudo lsblk

sda      8:0    0 298.1G  0 disk 
├─sda1   8:1    0  28.6G  0 part /
├─sda3   8:3    0     1K  0 part 
├─sda5   8:5    0   7.2G  0 part [SWAP]
└─sda6   8:6    0 262.3G  0 part /home
sr0     11:0    1  1024M  0 rom  


blkid prints the block device attributes. I usually use it for finding uuid for a given partition:

$ sudo blkid
/dev/sda5: UUID="38103cc4-6954-452a-a85d-841a0c9cb427" TYPE="swap" PARTUUID="000ae2b8-05"
/dev/sda1: UUID="f03c5ff1-e48f-4132-a955-de504284550f" TYPE="ext4" PARTUUID="000ae2b8-01"
/dev/sda6: UUID="de9f9a5d-8217-4378-8e51-90e2af77e3bc" TYPE="ext4" PARTUUID="000ae2b8-06"


Racktables is a software solution for datacenter and server room asset management. It helps document hardware assets, network addresses, space in racks, VLAN, etc…

You can find more info on the subject on the official website.