Last modified: October 14, 2024

This article is written in: 🇺🇸

Partitioning Disks

Partitioning a disk involves dividing a physical storage device into separate, manageable sections called partitions. Each partition functions as an independent disk within the operating system, allowing for better organization, multi-boot setups, or separation of system files from user data. The two main partition table formats used to define how these partitions are structured on the disk are the Master Boot Record (MBR) and the GUID Partition Table (GPT).

Imagine your disk as a bookshelf divided into compartments:

+------------------+------------------+------------------+------------------+
|   Compartment 1  |   Compartment 2  |   Compartment 3  |   Free Space     |
|   (/dev/sda1)    |   (/dev/sda2)    |   (/dev/sda3)    |                  |
+------------------+------------------+------------------+------------------+
|    50 GB         |    100 GB        |     8 GB         |     42 GB        |
|    ext4          |    ext4          |     swap         |                  |
|    Mounted at /  |    Mounted at    |                  |                  |
|                  |      /home       |                  |                  |
+------------------+------------------+------------------+------------------+

In this illustration, the disk /dev/sda is divided into three partitions with varying sizes and purposes, and there's remaining free space available for future use.

Basic Partition Operations

Several operations can be performed on disk partitions:

Relationship Between Physical Disks and Partitions

A physical disk is the actual hardware component that stores data. Partitions are logical divisions within this disk, allowing the operating system to manage different areas separately. Each partition can be treated as an independent disk with its own filesystem and mount point.

Visual representation:

+-------------------+
|   Physical Disk   |
|     (/dev/sda)    |
|                   |
|  +-------------+  |
|  | Partition 1 |  |
|  | (/dev/sda1) |  |
|  +-------------+  |
|  | Partition 2 |  |
|  | (/dev/sda2) |  |
|  +-------------+  |
|  | Partition 3 |  |
|  | (/dev/sda3) |  |
|  +-------------+  |
+-------------------+

Each partition is a segment of the physical disk that can be managed independently, formatted with different filesystems, and mounted at different points in the directory tree.

Disk Naming Conventions

In Linux, disks and partitions are named using specific conventions to identify the device type, order, and partition number.

Device Type Indicators:

Partition Numbers:

Partitions are numbered starting from 1. For example, /dev/sda1 is the first partition on the first disk.

Examples:

Types of Partitions

Primary Partitions

Primary partitions are the main partitions on a disk. On an MBR-partitioned disk, you can have up to four primary partitions. These partitions are used to boot operating systems or store data.

Creating a Primary Partition:

Example using fdisk to create a primary partition:

sudo fdisk /dev/sda

Inside fdisk:

Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-1048575999, default 2048): [Press Enter]
Last sector, +sectors or +size{K,M,G,T,P}: +50G
Created a new partition 1 of type 'Linux' and of size 50 GiB.

Formatting the Partition:

sudo mkfs.ext4 /dev/sda1

This action prepares the partition for use by creating an ext4 filesystem structure on it.

Extended and Logical Partitions

Extended partitions are a workaround for the MBR limitation of four primary partitions. An extended partition acts as a container for logical partitions, allowing you to create more than four partitions on a disk.

Creating an Extended Partition:

Inside fdisk:

Command (m for help): n
Partition type:
   p   primary (3 primary, 1 extended, 0 free)
   e   extended
Select (default p): e
Partition number (1-4, default 4): 4
First sector (some value): [Press Enter]
Last sector, +sectors or +size{K,M,G,T,P}: [Press Enter to use remaining space]
Created a new extended partition 4.

Creating Logical Partitions Within the Extended Partition:

Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (some value): [Press Enter]
Last sector, +sectors or +size{K,M,G,T,P}: +20G
Created a new logical partition 5 of type 'Linux' and of size 20 GiB.

Repeat the process for additional logical partitions.

Comparison

Here's a comprehensive comparison of different partition types:

Feature Primary Partition Extended Partition Logical Partition
Definition A main partition that can host an operating system or data directly. A special type of partition that acts as a container for logical partitions. A partition within an extended partition used to store data.
Maximum Number Up to 4 primary partitions per disk under MBR. Only 1 extended partition per disk under MBR (counts as one of the 4 primary). Numerous logical partitions can exist within the extended partition (limited by OS).
Purpose Used to install operating systems or store data directly. Provides a way to bypass the limit of 4 primary partitions by containing logical partitions. Allows the creation of additional partitions beyond the primary limit for organizing data.
Bootability Can be marked as active to boot an operating system (on MBR systems). Cannot be used to boot directly; it's a container. Generally not bootable, but can be configured with bootloaders in some cases.
Storage Location Entries stored directly in the partition table within the MBR or GPT. Defined in the partition table but contains an extended boot record (EBR) for logical partitions. Defined within EBRs linked in a chain inside the extended partition.
Limitations Limited to 4 per disk under MBR (no limit under GPT). Only one extended partition allowed per disk under MBR. Number limited by available space and operating system constraints.
Use Cases Ideal for systems requiring multiple operating systems or separate data areas. Necessary when more than 4 partitions are needed on an MBR disk. Useful for organizing data into separate partitions beyond the primary partition limit.
Deletion Impact Deleting removes the partition and all its data. Deleting removes the extended partition and all contained logical partitions. Deleting removes only the specific logical partition and its data.

Partition Table Formats: MBR vs. GPT

Partition table formats are organize data on storage devices, enabling the system to locate, identify, and manage different partitions on a disk. Two of the most widely used partition table formats are the Master Boot Record (MBR) and the GUID Partition Table (GPT). Each format comes with its own structure, limitations, and features, which affect how storage devices can be utilized and managed. While MBR is an older format, widely compatible across various operating systems, GPT is a newer standard designed to address the limitations of MBR, offering greater flexibility and scalability for modern storage needs.

Master Boot Record (MBR)

The Master Boot Record is the original partition table format, introduced in the 1980s, which has been the standard for decades. Located in the first sector of a storage device, the MBR holds the boot loader and information about the disk's partitions. However, MBR has some notable limitations: it supports a maximum disk size of 2 TB and can only create up to four primary partitions. For users needing more partitions, an extended partition must be created to hold additional logical partitions. Despite these limitations, MBR's simplicity and broad compatibility with older systems make it a popular choice for users and devices that do not require large storage capacities or numerous partitions.

GUID Partition Table (GPT)

The GUID Partition Table was developed as a modern replacement for MBR, overcoming many of its restrictions. GPT is part of the Unified Extensible Firmware Interface (UEFI) standard and supports much larger disks, theoretically up to 9.4 zettabytes, with practically unlimited partition counts. Each partition in GPT is identified by a globally unique identifier (GUID), enhancing flexibility and reducing the likelihood of partition-related conflicts. Additionally, GPT maintains multiple copies of its partition table for improved data redundancy and recovery, making it more reliable than MBR. GPT has become the preferred choice for newer systems, particularly those requiring large storage capacities or more than four partitions, and is increasingly supported by most modern operating systems.

Comparison Table:

Feature MBR GPT
Max Disk Size 2 TB 9.4 ZB
Max Partitions 4 primary partitions 128 partitions (default)
Data Redundancy No Yes (multiple partition tables)
Error Checking None CRC32 checksums
Boot Mode BIOS UEFI
Compatibility Older systems Modern systems

Operations in gdisk and fdisk

Both gdisk and fdisk are powerful command-line tools used for disk partitioning, gdisk is designed for GPT disks, while fdisk traditionally works with MBR disks but now supports GPT as well. Below is a table summarizing the key operations available in each tool.

gdisk Operations

Command Description
p Display the current partition table.
n Create a new partition.
d Delete a partition.
t Change a partition's type code.
l List known partition types.
w Write changes to disk and exit.
q Quit without saving changes.
x Enter expert mode for advanced options.
? Display help information.
i Show detailed information about a partition.
o Create a new empty GUID partition table (GPT).
r Enter recovery and transformation mode.

fdisk Operations

Command Description
p Display the partition table.
n Add a new partition.
d Delete a partition.
t Change a partition's system ID (type).
l List known partition types.
w Write changes to disk and exit.
q Quit without saving changes.
m Display help menu.
a Toggle a bootable flag on a partition.
v Verify the partition table for errors.
x Enter expert mode for advanced options.
g Create a new empty GPT partition table.

Managing Disk Partitions

Viewing Partition Tables

To inspect the partition table of a disk, we use previously introduced tools fdisk, parted, or gdisk.

Using fdisk

sudo fdisk -l /dev/sda

Example output:

Disk /dev/sda: 500 GiB, 536870912000 bytes, 1048576000 sectors
Disk model: ST500DM002-1BD14
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x12345678

Device     Boot   Start        End    Sectors   Size Id Type
/dev/sda1          2048  104857599 104855552    50G 83 Linux
/dev/sda2     104857600 209715199 104857600    50G 83 Linux

Using parted

parted is another tool that can be used to inspect the partition table, particularly helpful for both MBR and GPT partition tables.

To view the partition table with parted, use the following command:

sudo parted /dev/sda print

Example output:

Model: ATA ST500DM002-1BD14 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  50.0GB  50.0GB  primary  ext4
 2      50.0GB  100GB   50.0GB  primary  ext4

Using gdisk

gdisk is a tool similar to fdisk but designed specifically for GPT partition tables. It’s particularly useful for disks larger than 2 TB or when using UEFI-based systems.

To view the partition table with gdisk, use the following command:

sudo gdisk -l /dev/sda

Example output:

GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: not present
  BSD: not present
  APM: not present
  GPT: present

Disk /dev/sda: 1048576000 sectors, 500.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): D2AC4D27-567A-4E2B-8A6F-3BC66E42DAF7
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 1048575966
Partitions will be aligned on 2048-sector boundaries

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        104857599   50.0 GiB    8300  Linux filesystem
   2       104857600       209715199   50.0 GiB    8300  Linux filesystem

Checking Free Space

To check for unallocated space on a disk—space that hasn’t been assigned to any partition—you can use tools like fdisk, parted, and lsblk. These utilities show information about partitions and any remaining unallocated space on the disk.

Using fdisk

With fdisk, you can view both existing partitions and unallocated space. When you use fdisk -l, it lists the partitions on the disk, and at the end, any unallocated space will be noted.

sudo fdisk -l /dev/sda

Example output:

Disk /dev/sda: 500 GiB, 536870912000 bytes, 1048576000 sectors
Disk model: ST500DM002-1BD14
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x12345678

Device     Boot   Start        End    Sectors   Size Id Type
/dev/sda1          2048  104857599 104855552    50G 83 Linux
/dev/sda2     104857600 209715199 104857600    50G 83 Linux

Disk /dev/sda has 400 GiB of unallocated space.

Using parted

parted also displays unallocated space, making it a useful tool to confirm if your disk has unused space.

sudo parted /dev/sda print free

Example output:

Model: ATA ST500DM002-1BD14 (scsi)
Disk /dev/sda: 500GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
        0.00B  1049kB  1049kB            Free Space
 1      1049kB  50.0GB  50.0GB  primary  ext4
 2      50.0GB  100GB   50.0GB  primary  ext4
        100GB   500GB   400GB            Free Space

Using lsblk

lsblk doesn’t directly show unallocated space, but by listing only mounted filesystems and partitions, it indirectly indicates where unallocated space might be found on a disk.

lsblk

Example output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   500G  0 disk 
├─sda1   8:1    0    50G  0 part /
└─sda2   8:2    0    50G  0 part /home

Creating a New Partition

Here’s how to create a new partition on /dev/sda:

Using fdisk

I. Open fdisk:

sudo fdisk /dev/sda

II. List Current Partitions:

Once in fdisk, type p and press Enter to view the current partition table.

III. Create a New Partition:

IV. Write the Changes:

Type w to write the changes to the disk and exit fdisk.

V. Verify the New Partition:

Use lsblk or sudo fdisk -l to confirm that the new partition has been created.

Using parted

I. Open parted:

sudo parted /dev/sda

II. Set Disk Label (Optional):

mklabel gpt

III. Create the Partition:

mkpart primary ext4 100GB 150GB

This creates a primary partition formatted as ext4 starting at 100 GB and ending at 150 GB.

IV. Type quit to exit parted.

V. Format the Partition (Optional):

sudo mkfs.ext4 /dev/sda3

Using gdisk

I. Open gdisk:

sudo gdisk /dev/sda

II. Create a New Partition:

III. Write the Changes:

Type w to write the changes to the disk and exit gdisk.

After creating the partition, you may need to format it and add it to /etc/fstab for automatic mounting on boot. To format it, you can use a command such as:

sudo mkfs.ext4 /dev/sda3

To mount it immediately, create a mount point and mount the partition:

sudo mkdir /mnt/newpartition
sudo mount /dev/sda3 /mnt/newpartition

Resizing Partitions

Resizing partitions involves careful steps to avoid data loss.

Shrinking a Partition

sudo resize2fs /dev/sda1 40G

Following the filesystem shrink, use partition management tools such as fdisk or parted to modify the partition size.

sudo fdisk /dev/sda

Inside fdisk, you will need to delete the existing partition and recreate it, specifying the new, smaller size and ensuring it starts at the same sector as the original.

Expanding a Partition

sudo resize2fs /dev/sda1

General Tips for Partition Resizing:

sudo fsck /dev/sda1

Post-Resize Checks:

Deleting Partitions

Here’s how to delete a partition, for example, /dev/sda3:

Using fdisk to Delete a Partition

I. Open fdisk:

sudo fdisk /dev/sda

II. List Partitions:

Type p and press Enter to view the current partitions and identify the one you want to delete.

III. Delete the Partition:

IV. Write the Changes:

Type w to write the changes and exit fdisk. This action removes the partition from the partition table.

V. Verify the Deletion:

Use lsblk or sudo fdisk -l to confirm the partition has been deleted.

Using parted to Delete a Partition

I. Open parted:

sudo parted /dev/sda

II. List Partitions:

Type print to view the partition table and locate the partition you want to delete.

III. Delete the Partition:

rm 3

IV. Quit parted:

Using gdisk to Delete a Partition

I. Open gdisk:

sudo gdisk /dev/sda

II. Delete the Partition:

III. Write the Changes:

Type w to write the changes to the disk and exit gdisk. Confirm the changes when prompted.

IV. Verify the Deletion:

Use lsblk or sudo gdisk -l /dev/sda to confirm the partition has been removed.

Note: Deleting a partition will remove all data on that partition. Make sure to back up any important data before proceeding with the deletion process.

Practical Examples and Commands

Listing All Disks and Partitions

The lsblk command provides a detailed overview of all block devices, including disks and partitions, and their mount points.

lsblk -o NAME,MAJ:MIN,RM,SIZE,RO,TYPE,MOUNTPOINT

Example output:

NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0 465.8G  0 disk
├─sda1   8:1    0    50G  0 part /
├─sda2   8:2    0    50G  0 part /home
└─sda3   8:3    0   100G  0 part /data

Here, each disk and partition is displayed with its size, type, and mount point. sda is the primary disk, with sda1, sda2, and sda3 as its partitions.

Formatting and Mounting a New Partition

After creating a new partition, such as /dev/sda3, you need to format it and then mount it to make it accessible.

Formatting:

sudo mkfs.ext4 /dev/sda3

This command formats the partition /dev/sda3 with the ext4 filesystem. Ensure you’ve chosen the correct filesystem for your needs (e.g., ext4, xfs, etc.).

Creating a Mount Point:

sudo mkdir /mnt/data

This creates a directory (/mnt/data) where the partition will be mounted, allowing access to its contents from that location.

Mounting the Partition:

sudo mount /dev/sda3 /mnt/data

Mounting attaches the /dev/sda3 partition to the /mnt/data directory, making it accessible as part of the file system.

Verifying the Mount:

df -h | grep sda3

Example output:

/dev/sda3       99G   60M   94G   1% /mnt/data

The df -h command provides details about the mounted partition, showing the used and available space. The output confirms that /dev/sda3 is mounted on /mnt/data.

Adding the Partition to /etc/fstab

To ensure that the partition mounts automatically at boot, add an entry to the /etc/fstab file. This file defines how disk partitions, block devices, and remote filesystems are mounted.

Get the UUID:

sudo blkid /dev/sda3

Example output:

/dev/sda3: UUID="abcd-1234" TYPE="ext4" PARTUUID="12345678-03"

The blkid command displays the UUID for each partition. UUIDs are unique identifiers for partitions, making them more reliable than device names, as device names can change between boots.

Edit /etc/fstab:

sudo nano /etc/fstab

This opens the /etc/fstab file in a text editor (like nano). You can add an entry for the new partition to ensure it mounts automatically at boot.

Add the following line:

UUID=abcd-1234   /mnt/data   ext4   defaults   0   2

After saving and exiting, you can run sudo mount -a to apply changes immediately.

Changing MBR to GPT Using gdisk

Converting a disk's partition table from the Master Boot Record (MBR) format to the GUID Partition Table (GPT) can unlock new capabilities, such as supporting disks larger than 2 terabytes and allowing more than four primary partitions. The gdisk utility is a powerful tool that facilitates this conversion while aiming to preserve your existing data. In this comprehensive guide, we'll walk through the process of changing an MBR partition table to GPT using gdisk, providing detailed explanations and interpretations at each step.

Preparing for the Conversion

Converting from MBR to GPT is a significant operation that can potentially lead to data loss if not done carefully. Proper preparation is crucial.

Step 1: Examine the Current Partition Table

Start by inspecting the existing partition table to understand the current disk layout.

sudo gdisk -l /dev/sda

Example Output:

GPT fdisk (gdisk) version 1.0.5

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present

Found valid MBR with protective or hybrid GPT; converting MBR to GPT format in memory.
This operation may not preserve existing partitions.

Disk /dev/sda: 20971520 sectors, 10.0 GiB
Sector size (logical/physical): 512 bytes / 512 bytes
Disk identifier (GUID): FFFFEEEE-DDDD-CCCC-BBBB-AAAA99998888
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 20971486
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        20971519   10.0 GiB    0700  Microsoft basic data

Step 2: Launch gdisk Interactive Mode

Run gdisk to interactively convert the partition table.

sudo gdisk /dev/sda

Example Output:

GPT fdisk (gdisk) version 1.0.5

Type 'help' or '?' to view a list of commands.

Command (? for help):

Step 3: Review the Existing Partition Table

Before making changes, it's wise to review the current partitions.

At the gdisk prompt, type:

p

Example Output:

Disk /dev/sda: 20971520 sectors, 10.0 GiB
Sector size (logical/physical): 512 bytes / 512 bytes
Disk identifier (GUID): A1B2C3D4-E5F6-7890-1234-56789ABCDEF0
Partition table holds up to 128 entries

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        20971519   10.0 GiB    0700  Microsoft basic data

Step 4: Write the New GPT Partition Table

To apply the GPT format, write the changes to the disk.

At the gdisk prompt, type:

w

Example Output:

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING PARTITIONS!!

Do you want to proceed? (Y/N): y

After confirmation, you should see:

OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

Step 5: Verify the Conversion

Confirm that the disk now uses the GPT partitioning scheme.

sudo gdisk -l /dev/sda

Example Output:

GPT fdisk (gdisk) version 1.0.5

Disk /dev/sda: 20971520 sectors, 10.0 GiB
Sector size (logical/physical): 512 bytes / 512 bytes
Disk identifier (GUID): B123C456-D789-0E12-3456-7890ABCDEF12
Partition table holds up to 128 entries

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        20971519   10.0 GiB    8300  Linux filesystem

Step 6: Adjust Partition Types (If Necessary)

Depending on your system, you may need to adjust the partition type codes.

At the gdisk prompt, type:

t

You'll be prompted to enter the partition number:

Partition number (1-1): 1

Then enter the new hex code:

Hex code or GUID (L to show codes, Enter = 8300): 8300

Step 7: Create a BIOS Boot Partition (For BIOS Systems)

If your system uses BIOS (not UEFI), you'll need a BIOS boot partition to boot from a GPT disk.

At the gdisk prompt, create a new partition:

n

Example Input:

Option Action
Partition Number Press Enter to accept the default.
First Sector Press Enter to accept the default.
Last Sector +1M (creates a 1 MB partition).
Hex Code ef02 (BIOS boot partition).

Example Output:

Command (? for help): n
Partition number (2-128, default 2): [Press Enter]
First sector (34-2047, default = 34) or {+-}size{KMGTP}: [Press Enter]
Last sector (2048-2047, default = 2047) or {+-}size{KMGTP}: +1M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): ef02
Changed type of partition to 'BIOS boot partition'

Step 8: Write Changes and Exit gdisk

Save the changes to the disk.

At the gdisk prompt, type:

w

Confirm when prompted:

Do you want to proceed? (Y/N): y

Example Output:

OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

Step 9: Reinstall the Bootloader

Since the partition table has changed, you need to reinstall the bootloader.

For GRUB on BIOS systems:

sudo grub-install /dev/sda

Example Output:

Installing for i386-pc platform.
Installation finished. No error reported.

Step 10: Update the Filesystem Table (fstab)

Ensure that the /etc/fstab file references the correct partitions.

Use blkid to find the new UUIDs:

sudo blkid

Update /etc/fstab accordingly.

Step 11: Reboot and Test

Reboot the system to verify that everything works correctly.

sudo reboot

Visual Representation of the Conversion

To better understand the process, here's a simplified visual:

Before Conversion (MBR):

+-----------------------+
|       MBR Disk        |
|-----------------------|
| MBR Partition Table   |
|                       |
| +-------------------+ |
| |   /dev/sda1       | |
| |   Primary         | |
| |   Linux           | |
| +-------------------+ |
|                       |
+-----------------------+

After Conversion (GPT):

+-----------------------+
|       GPT Disk        |
|-----------------------|
| GPT Partition Table   |
|                       |
| +-------------------+ |
| |   /dev/sda1       | |
| |   Linux Filesystem| |
| +-------------------+ |
| +-------------------+ |
| |   /dev/sda2       | |
| |   BIOS Boot Part. | |
| +-------------------+ |
|                       |
+-----------------------+

Safety Precautions

Common Errors and Troubleshooting

Error: "Partition in Use"

sudo umount /dev/sda1

It’s also advisable to close any applications or services currently using the partition, as they can prevent the partition from unmounting properly.

Error: "No Free Sectors Available"

This error generally occurs when there is no unallocated space left on the disk. To address this, you can either shrink existing partitions to create free space or, if needed, upgrade to a larger disk or use additional storage to accommodate the expansion.

Error: "Filesystem Check Required"

sudo fsck -f /dev/sda1

This command performs a comprehensive scan and repair of the filesystem, helping to restore it to a consistent state after any partition resizing activities.

Challenges

  1. What are the key differences in terms of capacity, partition limits, and compatibility between MBR (Master Boot Record) and GPT (GUID Partition Table) partition tables?
  2. How can you list all the disk partitions on a Linux system?
  3. What are the steps to create a new partition on a disk using the fdisk command?
  4. What distinguishes primary partitions from extended partitions?
  5. How can you delete an existing partition using the fdisk command?
  6. Why is it necessary to create a filesystem on a disk partition?
  7. Is it possible to convert a disk from an MBR partition table to a GPT partition table and vice versa? If yes, how can this be achieved?
  8. What do the first two or three letters in common disk names (like /dev/sda, /dev/hda) signify?
  9. What information is conveyed by the last letter and the numbers in common disk names (e.g., /dev/sda1, /dev/sdc2)?
  10. What is the largest capacity of a disk that can be effectively partitioned using MBR and GPT partition tables, respectively?

Table of Contents

    Partitioning Disks
    1. Basic Partition Operations
    2. Relationship Between Physical Disks and Partitions
    3. Disk Naming Conventions
    4. Types of Partitions
      1. Primary Partitions
      2. Extended and Logical Partitions
      3. Comparison
    5. Partition Table Formats: MBR vs. GPT
      1. Master Boot Record (MBR)
      2. GUID Partition Table (GPT)
    6. Operations in gdisk and fdisk
      1. gdisk Operations
      2. fdisk Operations
    7. Managing Disk Partitions
      1. Viewing Partition Tables
      2. Checking Free Space
      3. Creating a New Partition
      4. Resizing Partitions
      5. Deleting Partitions
    8. Practical Examples and Commands
      1. Listing All Disks and Partitions
      2. Formatting and Mounting a New Partition
      3. Adding the Partition to /etc/fstab
    9. Changing MBR to GPT Using gdisk
      1. Preparing for the Conversion
      2. Step 1: Examine the Current Partition Table
      3. Step 2: Launch gdisk Interactive Mode
      4. Step 3: Review the Existing Partition Table
      5. Step 4: Write the New GPT Partition Table
      6. Step 5: Verify the Conversion
      7. Step 6: Adjust Partition Types (If Necessary)
      8. Step 7: Create a BIOS Boot Partition (For BIOS Systems)
      9. Step 8: Write Changes and Exit gdisk
      10. Step 9: Reinstall the Bootloader
      11. Step 10: Update the Filesystem Table (fstab)
      12. Step 11: Reboot and Test
      13. Visual Representation of the Conversion
    10. Safety Precautions
    11. Common Errors and Troubleshooting
      1. Error: "Partition in Use"
      2. Error: "No Free Sectors Available"
      3. Error: "Filesystem Check Required"
    12. Challenges