Featured

Partitioning Basics for New Linux Users

Before you downsize the Windows partition or decide in the installation program on the optimal size of the new partitions for Linux, you should know what a partition is and how it is used.

 

Partitions are sections on the SSD or hard disk. Partitions with Windows file systems get their own letters (C:, D:, etc.) and seem to behave like independent hard disks.

 

Usually, there are already a few partitions on the data medium of a Windows notebook: the already mentioned ESP, plus possibly other small partitions with the boot system, drivers, and a recovery system, as well as a large partition that fills almost the entire SSD. This partition contains a file system with Windows and your personal data.

 

You will need additional partitions as soon as you want to install several operating systems on your computer at the same time. There are two reasons for this: On the one hand, different operating systems often use different file systems—that is, different methods of storing files within the partition. On the other hand, separate partitions avoid duplications and conflicts in directory and file names.

 

Linux usually provides for several partitions itself—for example, one partition for the operating system, another for your own data, and a third as a so-called swap partition. This is the counterpart to the Windows swap file.

 

For a Linux installation, it doesn’t matter how much space is left on your SSD or hard disk on Windows. You cannot use this space—inside a Windows partition—for Linux. You need space outside the existing Windows partition(s) for the Linux installation to create new Linux partitions there.

 

To change the partitioning of the hard disk, each operating system provides its own tools:

  • On Windows, there is the Disk Management program for this purpose. To run the program, search for “Create and format hard disk partitions” in the Start To downsize the Windows partition, select it and execute the Shrink Volume context menu command.
  • Distribution-specific partitioning aids are available during the Linux installation.
  • If you need to make changes to the partitioning after installing Linux, it is best to use the parted command or its graphical user interface, gparted.

Increased Flexibility with LVM: Changing the partitioning at a later date requires a great deal of effort. In many cases, the contents of a partition are lost when its size is changed. Moving partitions is also not provided for. For this reason, it is recommended to plan the partitioning well from the beginning. Linux professionals can work around many limitations by using the LVM system. This is an intermediate layer between partitions

and file systems.

 

There are two methods for managing partitioning information on an SSD or hard disk:

  • GPT: The modern GUID partition tables (GPT) have been used in internal SSDs and hard disks in all computers since 2012.
  • MBR: Storing partition data in the master boot record (MBR) is outdated and has many limitations. Unfortunately, MBR is still used today, mainly in virtual machines with disks smaller than 2 TiB and with external disks (e.g., USB flash drives and SD cards).

MBR Basics

MBR is intended for disks up to a maximum of 2 TiB. There are three types of partitions: primary, extended, and logical. A maximum of four primary partitions can exist on the hard disk. It is also possible to define an extended partition instead of one of these four primary partitions. Inside the extended partition, you can then create multiple logical partitions.

 

The point of extended and logical partitions is to get around the historically imposed limit of only four primary partitions. Note that some partitioning tools do not differentiate between different partition types in the user interface and take care of how the partitions are created internally.

 

An extended partition serves only as a container for logical partitions. Only primary and logical partitions are suitable for the actual storage of data.

 

GPT Basics

With GPT, each partition is identified by a globally unique identifier (GUID). All partitions are equal; that is, there is no distinction between primary, extended, and logical partitions. Each partition can be up to 8 zettabytes (ZiB) in size: that's 2 bytes, or about a billion TiB!

 

Note that the partition numbers do not have to match the actual order of the partitions. Suppose you create three partitions of 200 GiB each, then shrink the second partition to 50 GiB. This creates a gap between partitions 2 and 3 in which you can set up the fourth partition.

 

Comprehensive information about the structure of the GPT partition table and compatibility with various operating system versions can be found on the following Wikipedia page: https://en.wikipedia.org/wiki/GUID_Partition_Table.

 

Partition Names

On Windows, partitions that the operating system can use are designated with drive letters. A: and B: are reserved for floppy disks for historical reasons. The other letters denote the partitions with Windows file systems.

 

On Linux, internal access to hard disks or their partitions takes place via socalled device files (see table below). Hard disks and SATA SSDs are given the designation /dev/sda, /dev/sdb, /dev/sdc, and so on, in sequence. For SSDs for the NVMe interface, however, the device names start with /dev/nvme.

 

Some Sample Device Names of Partitions

 

To address a single partition and not the entire hard disk, the partition number is added to the device name. With GPT partitioning, all partitions are simply numbered in sequence. In MBR partitioning, on the other hand, the numbers from 1 to 4 are reserved for primary and extended partitions. Logical partitions always start with the number 5.

 

File Systems

Partitioning only reserves space on the SSD or hard disk. Before you can store files in a partition, you must create a so-called file system. It contains administrative information in addition to the actual data. Creating a file system in a partition is also called formatting. Windows and Linux use different file system types:

  • NTFS is commonly used on Windows. On small USB flash drives and SD cards, the rather old VFAT system is often used instead, and on larger SD cards, the exFAT file system is often used.
  • On Linux, ext4 is the most popular file system type. Alternatives are xfs (ideal for huge file systems) and btrfs.

Editor’s note: This post has been adapted from a section of the book Linux: The Comprehensive Guide by Michael Kofler.

Recommendation

Linux
Linux

Beginner or expert, professional or hobbyist, this is the Linux guide you need! Install Linux and walk through the basics: working in the terminal, handling files and directories, using Bash, and more. Then get into the nitty-gritty details of configuring your system and server, from compiling kernel modules to using tools like Apache, Postfix, and Samba. With information on backups, firewalls, virtualization, and more, you’ll learn everything there is to know about Linux!

Learn More
Rheinwerk Computing
by Rheinwerk Computing

Rheinwerk Computing is an imprint of Rheinwerk Publishing and publishes books by leading experts in the fields of programming, administration, security, analytics, and more.

Comments