Author’s Note: This post has been updated with added info about NVMe SSDs, or PCIe SSD disks. You can read the updated post at What you need to know about disks and disk partitions in Linux.
A beginner’s guide to disks and disk partitions in Linux is an updated version of Guide to disks and disk partitions in Linux. It is intended to be an absolute beginner’s guide to understanding how Linux handles disks and partitions.
If you are migrating from Windows to Linux and are attempting to install any Linux distribution alongside Windows 7/8 on your computer, this article should come in handy. You’ll read about hard drive naming convention in Linux, how they are partitioned, partition tables, file systems and mount points.
By the time you are through reading this, you should have a pretty good idea of what you are doing when installing your next Linux distribution on your laptop or desktop computer. An understanding of all the aspects concerning how a disk is referenced and partitioned will put you in a better position to troubleshoot installation and disk-related problems. Most of the highly technical terms associated with this subject have been omitted, so this should be an easy read.
NFTs were hot in 2021. They will be even more so this year and beyond. NFT South is a conference where NFT enthusiasts will meet to explore and celebrate the different use cases of NFTs. It’s going to be a fun event. Get your ticket today!
1. Hard Drive Naming Convention: The first thing you need to know is this: There’s no C or D drive in Linux. There are equivalents, but when you come across a reference to a hard drive in Linux, you’ll typically see something like /dev/sda, /dev/sdb, /dev/sdc, … etc. The “dev” is short for device, and, in this case, a block storage device. The “sd” is short for SCSI mass-storage driver. (SCSI stands for Small Computer System Interface.) For the rest of this article, the “/dev/” part will be dropped, so all references to hard drives (and partitions) will start with the last part only.
Let’s begin by taking a look at how hard drives are represented in Windows. Figure 1 was taken from a Windows 8 installation on a computer with two hard drives attached – Disk 0 and Disk 1.
Figure 2 shows how those hard drives would be represented in Linux. Where Windows sees Disk 0 and Disk 1, Linux takes a different approach. The first hard drive detected by a Linux system carries the sda label. In numerical terms, it is hard drive 0 (zero; counting begins from 0, not 1). The second hard drive is sdb, the third drive, sdc, etc. In the screenshot below, there are two hard drives detected by the installer – sda and sdb.
Figure 3 comes from a Linux system with three hard drives attached. So that’s how hard drives are referenced in Linux – sda, sdb, sdc, sdd, sde, …, sdz…
2. Partition Tables: In simple terms, a partition table describes the layout of partitions of a hard drive. There are two partition table standards – MBR (Master Boot Record) and GPT (GUID Partition Table). MBR, also know as ms-dos, is what you might call the first standard. GPT came much later. If you’re interested in the historical and technical details about both standards, see these Wikipedia articles – GUID Partition Table and Master Boot Record.
The MBR partitioning scheme is what you’ll find on older computers. Newer computers support both schemes, so it’s still possible to use an MBR partitioning scheme on those computers. MBR’s major limitations led to the development of GPT. Those limitations are:
- It does not allow the configuration of more than four main partitions. Those partitions are called primary partitions.
- Disk partitions are limited to 2TB
Newer computers come with a replacement firmware for the old BIOS system called UEFI (Unified Extensible Firmware interface), and GPT is a part of the UEFI standard. If you bought a Windows 8 computer, it’s most certainly installed on a GPT partitioning scheme. If you’re already running a Linux distribution or attempting to install one on a recent Windows 7/8 computer, the easiest method of finding out what partitioning standard is used is to launch a shell terminal and type <strong>sudo fdisk -l</strong>
(leave out the sudo if the distribution does not use it).
Figure 4 shows the output of sudo fdisk -l from a Ubuntu Linux installation. The Disklabel type: gpt line confirms that GPT is in use.
Figure 5 was taken from a Fedora Linux installation. As in Figure 4, the Disklabel type: dos line confirms what partitioning scheme is in use. In this case, it is MBR.
You can also tell whether GPT or MBR is in use by accessing the UEFI setup utility. Under the Boot menu, look for PCI ROM Priority. You should see two options – EFI Compatible ROM and Legacy ROM. The latter indicates MBR.
3. Partitions and Partition Numbering: To install an operating system on a hard drive, it must first be subdivided into distinct storage units. Those storage units are called partitions. Under the MBR partitioning scheme, there are three different types of partitions – Primary, Extended, and Logical. Extended, and Logical partitions will be discussed further down.
With MBR, any partition that is not explicitly created as an extended or logical partition, is a primary partition. And, as stated earlier, there can be no more than four primary partitions. Figure 6 was taken from a Linux installation with four primary partitions. If you observe closely, you will see that the first primary partition is sda1 and the last sda4. Unlike hard drives, partition numbers start from 1, not 0 (zero). Any disk space that’s not allocated to the primary partitions is listed as Free or free space. But while it may be free, it is, however, unusable. And that is because as far as the system is concerned, that free space does not exist.
So if you attempt to create another partition using the free space, the installer will throw up the type of error message shown in Figure 7. The error message will always say, “not enough free space,” even when you know that there is space available. And it does not matter whether that free space is 1 MB or 1 GB. It will be unusable.
To get around the four primary partition limitation of MBR, the smart guys involved came up with the concept of an extended partition. By tagging a partition as an extended partition, it is then possible to create many more partitions under it. Those partitions are called logical partitions. Theoretically, there is no limit to the number of logical partitions that you can create. Note: Only one extended partition may be configured on a single hard drive.
Techno Tip: Linux professionals now can access their favorite Windows applications on their Linux system itself without a hassle with Windows desktop as a service with 24*7 excellent support from www.Apps4Rent.com.
What the concept of extended partition brings to the table is illustrated in Figure 8. You can see that there are three primary partitions – sda1, sda2 and sda3. The fourth partition is an extended partition, which makes it possible to create more (logical) partitions – sda5, sda6 and sda7. Under an extended partition, you can have free space, and that free space will still be usable. So you do not have to allocate all the available free space to the logical partitions of an extended partition.
i am confused. I am trying to make a partition to install Linux Mint 20.3 on an older Windows 10. I got through the installation and get to the partitions, all is fine. Then i look at the output. Linux installer correctly labels Windows7, windows10 and backup partitions and shows a new linux partition, BUT the output is a Single partition of the entire hard drive. I am afraid to say “COMPLETE INSTALLATION” because i don’t know if the first part showing partitions of EXISTING Files will remain if the output shown is a SINGLE partition? Can someone explain if i should just proceed, or if I am doing something wrong. I previously used and old UBUNTU and a MEPIS program. Seems the installation was more straightforward. Also, I am not a C language programmer. Thanks for any help.
It should not be a single partition. The entire hard drive should be labelled /dev/sda, but the partitions should have a number appended to that. For example, the boot partition should likely be /dev/sda1. Others will likely be /dev/sda5, /dev/sda6, etc. Check that the Windows and Linux partitions are different and you should be good to go. I’ll recommend that you read What you need to know about disks and disk partitions in Linux
Very useful. This has filled in several gaps in my knowledge.
can i dld this
article
Very informative for a newbie like me
Thanks
Very well written article, but it really didn’t help with a problem.
Just tried the new Linux Mint 18.3 on my desktop computer.
I used the live setting with swap partition (300mb). After deciding that yes I want the OS but on my laptop instead, I removed Mint BUT the swap partition is still there and refuses to delete.
Any ideas on how to do this?
Excellent tutorial. Thanks.
Very nicely written article – thank you for it!
Very well written – Thank you
what is the disk name after”sdz”?
Unlikely you’ll ever encounter it on your system, but the lettering starts all over from a. So it should be sdza, sdzb, sdzc, …, sdzz.
And on and on and on…
it should be mentioned that logical partitions cannot be used to boot the system; only one of those 4 primary partitions can do that
I think this is mainly for Microsoft Windows. Linux works well with logical partitions; my Ubuntu 18.04 boots from a logical partition without any problem.
AFAIK linux can booting up from logical or extended partition so is no problem where do you install / or /boot partition.
Thank you for an interesting and well written article! Could you please advice on how to install linux on a new computer with two drives, one SSD and one HDD. Is it possible f.ex to have boot, root and swap in three partitions on the SSD and have home in a partition on the HDD? Or would it be better to have the whole Linux installation on the SSD and use the HDD as an extra data storage volume?
Since any data generated on the system will be by you, you can have /home on the HDD, and the other partitions on the SSD. That would be the best configuration.
This helped me very much! Great read and very easy to understand
I installed Kali Linux(dual with windows) on a 200GB extended partition and I am regretting it, since I cannot access that drive unless Im on linux. Why can I not view the extended partition in windows? How to make it accessible? Any other suggestions for me?
Because Kali would probably install the file system as EXT3/4. Windows knows nothing of any of these file systems so to it, they do not exist. You would need to specify fat32 for the file system which would be a bad idea. I do not believe that any linux will install to an NTFS partition but could stand corrected on that.
On my version of ubuntu `fdisk -l` does not list the partition type. The man page specifies that it can not interpret gpt tables. GNU `parted` can.
`sudo parted -l`
It is not clear that how can we create extended partition ?
An extended partition is created automatically in the background when you create a logical partition. And that is, if you’re using the installer’s of Ubuntu and its derivatives and any distribution using the new Calamares installer.
That, of course, only applies if you’re creating the partitions under an MBR partitioning table.
See Guide to disks and disk partitions in Linux for more on this.