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- Tthe 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:
- It does not allow us to create more than four main partitions. Those partitions are called primary partitions.
- 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.
List disk Partition with parted and fdisk command
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.
List disk Partitions with ls command
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
/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