How To Check Unallocated Disk Space In Ubuntu Linux

Here are the terminal commands to find unallocated disk space in Linux Ubuntu. Users can easily find the free space in external hard drive or find unused disks in Linux which can be further used to increase disk space on the system.

Unallocated space is the physical space on the hard drive which hasn’t been assigned (allocated) to a particular partition.

Don’t confuse free space and unallocated space. Free space means that the hard disk partitioned space which is not used on a particular drive or the respective partition.

In simple words, hard disk space that hasn’t been allocated to any partition or file system is known as unallocated space. This means the space doesn’t exist to the operating system and it cannot be used for any purpose.

Let us learn about different methods for checking unallocated free space in Linux Ubuntu.

Using Parted Command

The parted is a command line tool for manipulating disk partitions. This command is used to create space for new operating systems, to reorganize disk usage, to copy data to new hard disks, destroy, resize or move different partition formats.

The parted command is compatible with numerous partition table formats including FAT, FAT32, MS-DOS, and GPT.

Let’s check for unallocated space using the parted command.

$ sudo parted /dev/sda print free

In the command above, /dev/sda represents the name of the hard disk. The command “parted /dev/sda” is used with print free command option to show information about the partitions and unallocated space. Note:

The space/entries under the “Free Space” which is listed under the “File system” column displayes the unallocated space of the disk partition.

Using fdisk to Display disk cylinders

Before we begin, we must note that the parted command is very different from fdisk -l command. The fdisk -l command is used to lists all available disks and partitions in each disk.

Calcualting disk cylinders on the disk partition is another method to calculate unallocated disk space. Using the fdisk -l command you can see how many cylinders the disk has and how many bytes a cylinder represents.

The cylinder’s values (end value of one cylinder and start value of the other cylinder) follow each other when all disk space is allocated. If there are some values that are missing, it means that we have unallocated disk space.

Let us understand this by the example below:

sudo fdisk -l /dev/sda

Device Start End Sectors:

/dev/sda1 2048 15671295 15669248
/dev/sda2 18032550 25165823 3566637

You can see that /dev/sda1 ends on sector ‘15671295’ but /dev/sda2 doesn’t start directly on the next value but on sector ‘18032550’. It means that the range ‘15671295-18032549’ is missing so there is unallocated space on the disk.

To calculate the unallocated space, you can do as below:

missing sectors: 18032549 – 15671295 = 2361254
calculate the size in bytes: 2361254 * 512 = 4232006144 bytes ~ 4.23 GB

From the above example we find about almost 4.23 GB of unallocated space.

If you wish to display disk partition table in terminal, you can execute the cfdisk command:

# cfdisk /dev/sda

In the screenshot given below, you can easily see the “Free Space”.

If you do not wish to use terminal commands to check unallocated space, you can use GParted Linux tool. It is the GUI partition editor to managing disk partitions.

Author: Team Linux Ledger

The team of Linux experts and open source enthusiasts who are passionate about sharing their expertise with you through in-depth tutorials, news, and updates on various aspects of open source in general and Linux in particular A team that helps you become a better Linux user.

Leave a Comment