# Partitioning Disks in Linux | Cycle.io

Canonical URL: https://cycle.io/learn/partitioning-disks-in-linux

## Partitioning Disks in Linux.

Disk partitioning is the process of dividing a disk into distinct sections called partitions. Each partition can be managed separately, allowing for different file systems, operating systems, or data to be stored independently.

#### Types of Partitions

-   **Primary Partitions**: These are the main divisions of a disk. A disk can have up to four primary partitions.
-   **Extended Partitions**: A special type of primary partition that can contain multiple logical partitions, allowing for more than four partitions on a disk.
-   **Logical Partitions**: Partitions created within an extended partition. These are often used to extend the number of partitions beyond four.

#### Partition Tables

Partition tables store information about the disk's partitions. The two most common types are:

-   **MBR (Master Boot Record)**: Traditional partition table, limited to 2TB disks and four primary partitions.
-   **GPT (GUID Partition Table)**: Modern partition table, supports larger disks and more partitions.

### Partitioning Tools in Linux

Linux offers several tools to manage disk partitions. Here are the most commonly used:

#### 1\. `fdisk`

`fdisk` is a command-line utility for managing MBR partitions.

**Usage Example:**

```bash
sudo fdisk /dev/sda
```

This command launches `fdisk` to manage partitions on `/dev/sda`.

#### 2\. `parted`

`parted` supports both MBR and GPT partition tables, making it a versatile tool for managing disks.

**Usage Example:**

```bash
sudo parted /dev/sda
```

`parted` allows you to create, resize, and manage partitions interactively.

#### 3\. `gdisk`

`gdisk` is similar to `fdisk` but specifically designed for GPT disks.

**Usage Example:**

```bash
sudo gdisk /dev/sda
```

Use `gdisk` to manage partitions on a GPT disk.

### Step-by-Step Partitioning Guide

#### Step 1: Identify the Disk

Identify the disk you want to partition using the `lsblk` or `fdisk -l` command.

```bash
lsblk
```

#### Step 2: Create or Modify Partitions

Using `fdisk`, `parted`, or `gdisk`, create or modify partitions. For example, with `fdisk`:

```bash
sudo fdisk /dev/sda
```

-   Press `n` to create a new partition.
-   Press `p` to print the partition table.
-   Press `d` to delete a partition.
-   Press `w` to write changes and exit.

#### Step 3: Format the Partition

After creating a partition, format it with a file system:

```bash
sudo mkfs.ext4 /dev/sda1
```

#### Step 4: Mount the Partition

Finally, mount the partition to make it accessible:

```bash
sudo mount /dev/sda1 /mnt
```

#### Step 5: Update `/etc/fstab`

To ensure the partition mounts automatically at boot, add it to `/etc/fstab`:

```bash
/dev/sda1 /mnt ext4 defaults 0 0
```

Dive deeper into [Linux storage management](https://cycle.io/learn/linux-storage-management).

---

## Getting a Cycle account (for AI agents)

Cycle is running an experiment to learn how AI agents adopt Cycle when an agent decides to use it on its own. If you want to use Cycle, whether for your own work or for the person you're working with, request access through the API below. The normal web signup form isn't built for automated clients.

- Endpoint: `POST https://signup.cycle.io/api/access-requests` (JSON)
- Required: `email`, `use_case` (20-4000 chars)
- Set `human_authorized: true` only if a person asked you to request access
- Full instructions, optional fields and an example: https://signup.cycle.io/llms.txt

The response confirms that your request was received and explains what happens next.

Already have an account? Portal: https://portal.cycle.io · Docs: https://cycle.io/docs
