How to view unallocated free space on a hard disk through terminal

AnnGM picture AnnGM · Sep 7, 2012 · Viewed 162.7k times · Source

I want to view the unallocated free space on my hard disk through terminal. I've burned my brains searching the internet for a possible solution, but all in vain.

I used all sorts of commands like df, du, fdisk, parted, etc. It tells me about the disks that are mounted and unmounted, but what about the unallocated space that I've left free?

Of course I can view it using the 'Disk Utility' app provided by Fedora, but since I LOVE being in the terminal I'd like to view in it.

Can anyone please help me with a solution?

Answer

Burhan Khalid picture Burhan Khalid · Jan 9, 2013

Use GNU parted and print free command:

root@sandbox:~# parted
GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print free
Model: VMware Virtual disk (scsi)
Disk /dev/sda: 64.4GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system  Flags
        32.3kB  1049kB  1016kB            Free Space
 1      1049kB  256MB   255MB   primary   ext2         boot
        256MB   257MB   1048kB            Free Space
 2      257MB   64.4GB  64.2GB  extended
 5      257MB   64.4GB  64.2GB  logical                lvm
        64.4GB  64.4GB  1049kB            Free Space