howtouselinux

4 Ways to Check Disk Partition with Examples in Linux

Table of Contents

The first thing that we need to know is there is no C drive or E drive in Linux. We will see something like /dev/sda, /dev/sdb, /dev/sdc, … etc. instead. The dev is short for device. The sd was short for Small Computer System Interface (SCSI) mass-storage driver.

  • /dev/sda – The first SCSI disk SCSI ID address-wise.
  • /dev/sdb – The second SCSI disk address-wise and so on.
  • /dev/sda1 – The first partition of disk sda
  • /dev/sdb1- The first partition of disk sdb

 

Understanding Disk Partition Tables

A partition table shows the partitions of a Hard Drive or any other storage device. There are two standards for the partition table:

  • Master Boot Record (MBR) – MBR also know as MS-DOS, is what us might call the original standard. MBR is still the most widely used partition table, it comes with two major limitations.
  • GUID Partition Table (GPT) – GPT came later. While MBR is still in use, the limitations are what led to the development of GPT. GPT overcomes the two limitations of MBR. We can have multiple primary partitions, and the drive sizes can exceed 2 TB.

The limitation of MBR:

  1. It does not allow us to create more than four main partitions. Those partitions are called primary partitions.
  2. Disk partitions may not exceed 2 TB.

 

Understanding Disk Partitions and Partition Numbering

To install an operating system on a hard drive, we have to divide it into distinct storage units. We call those storage units partitions. Under MBR – which is the default on virtually all Linux distributions, there are three different types of partitions – Primary, Extended, and Logical.

  • Primary – Holds the operating system files. Only four primary partitions can be created.
  • Extended – Special type of partition in which more than the four primary partitions can be created.
  • Logical – Partition that has been created inside of an extended partition.

With MBR any partition that is not explicitly created as an extended or logical partition, is a primary partition.

Any unallocated space is shown as Free. While it may be free, we cannot use it in that state. As far as the system is concerned that free space does not exist until it is partitioned.

Names without a trailing digit refer to the whole disk, while names with a trailing digit refer to a partition of that whole disk. By convention, SCSI disks have a maximum of 16 minor numbers mapped to a single disk.

Thus, for each whole disk, there is a maximum of 15 partitions per disk because one minor number is used to describe the entire disk (for example /dev/sda), and the other 15 minor numbers are used to refer to partitions for that disk (for example /dev/sda1, /dev/sda2, etc).

Understanding Disk Extended Partition

By tagging a partition as an extended partition, it is possible to create many more partitions under the extended partition. Those partitions are called logical partitions, and there is effectively no limit to the number of logical partitions that us can create. This means us can have three primary partitions and one extended partition and then create numerous partitions from there.

Check disk Partition with fdisk command in Linux

The best way to check disk partition in Linux is using fdisk command. It is a text-based utility for viewing and manipulating disk partitions. Typing fdisk -l at the command prompt will list all of the partitions on your Linux system.

You can also use the fdisk command to create, delete, or resize partitions. For more information on using fdisk, consult the man page by typing: man fdisk at the command prompt.

parted -l and fdisk -l can both list disk partitions on Linux.

 

  • Model – Model of the storage device.
  • Disk – Name and size of the disk.
  • Sector size – Logical and physical size of the memory. Not to be confused with available disk space.
  • Partition Table – Partition table type (msdos, gpt, aix, amiga, bsd, dvh, mac, pc98, sun, and loop).
  • Disk Flags – Partitions with information on size, type, file system, and flags.

 

Check disk Partitions with ls command in Linux

Here we can see that there are 3 partitions on disk sda.

  • # ls -l /dev/sda*
  • brw-rw—- 1 root disk 8, 0 May 24 08:09 /dev/sda
  • brw-rw—- 1 root disk 8, 1 May 24 08:09 /dev/sda1
  • brw-rw—- 1 root disk 8, 10 May 24 08:09 /dev/sda2
  • brw-rw—- 1 root disk 8, 11 May 24 08:09 /dev/sda3

 

Check disk partitions with cat /proc/partitions in Linux

/proc/partitions file also has much important info about disk and disk Partitions.

# cat /proc/partitions

  • major minor # blocks name
  • 8 0 17774160 sda
  • 8 1 1052226 sda1
  • 8 10 208845 sda2
  • 8 11 10490445 sda3

 

What is the difference between a partition and a filesystem?

A partition is a section of a disk that is allocated for use by an operating system. A filesystem is a method for organizing and storing files on a partition.

What is the purpose of partitions?

Partitions are used to separate different types of data. For example, you might have a partition for your operating system and another partition for your personal files. Partitions can help to improve performance and stability by isolating different types of files. For example, you can use a separate partition for your operating system files and another partition for your personal data files. This way, if one partition becomes corrupted, the other partition will not be affected.

What is the difference between primary and extended partitions?

Primary partitions are the first four partitions on a disk. Extended partitions are any partitions after the fourth partition. You can create up to four primary partitions or three primary partitions and one extended partition.

How do I delete a partition in Linux?

You can use the fdisk command to delete partitions in Linux. First, you need to find the device name of your disk. You can do this by running the lsblk command. Next, you need to run the fdisk command with the device name as an argument. Then, you will need to enter d to delete a partition. Finally, you will need to enter w to write the changes to the disk.

 

5 Ways to Check disk space in Linux

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

If you meet any issues with Linux, record them with Loom and send the link to us here. We will reply ASAP.

Load WordPress Sites in as fast as 37ms!