> ## Documentation Index
> Fetch the complete documentation index at: https://help.onetsolutions.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Extend a Partition

> Extend a disk partition after increasing disk size

After upgrading your VPS storage, you need to extend the partition to use the additional space.

<Info>
  **Prerequisites**

  * A VPS with OnetSolutions
  * Increased disk size (via upgrade)
  * Root or sudo access
</Info>

<Warning>
  Always backup your data before modifying disk partitions.
</Warning>

## Extension Steps

<Steps>
  <Step title="Identify disk and partition">
    List available disks and partitions:

    ```bash theme={null}
    lsblk
    ```

    Note the device name (e.g., `/dev/vda`) and partition number (e.g., `1` for `/dev/vda1`).
  </Step>

  <Step title="Extend the partition">
    Use `growpart` to extend the partition:

    ```bash theme={null}
    sudo growpart /dev/vda 1
    ```

    Replace `/dev/vda` and `1` with your actual device and partition number.
  </Step>

  <Step title="Verify partition extension">
    Run `lsblk` again to confirm the partition shows the increased size.
  </Step>

  <Step title="Resize the filesystem">
    Extend the filesystem to use the new space:

    ```bash theme={null}
    sudo resize2fs /dev/vda1
    ```

    Replace `/dev/vda1` with your actual partition.
  </Step>

  <Step title="Verify the changes">
    Check disk space usage:

    ```bash theme={null}
    df -h
    ```

    Your partition should now show the increased size.
  </Step>
</Steps>

## Installing Required Tools

<Info>
  The `growpart` tool extends the partition, while `resize2fs` or `xfs_growfs` extends the filesystem to use the new space.
</Info>

If `growpart` is not installed:

<Tabs>
  <Tab title="Debian/Ubuntu">
    ```bash theme={null}
    sudo apt install cloud-guest-utils
    ```
  </Tab>

  <Tab title="CentOS/Rocky/Alma">
    ```bash theme={null}
    sudo yum install cloud-utils-growpart
    ```
  </Tab>
</Tabs>

## Filesystem Commands

<AccordionGroup>
  <Accordion title="ext4 filesystem" icon="hard-drive">
    Most common Linux filesystem. Use `resize2fs`:

    ```bash theme={null}
    sudo resize2fs /dev/vda1
    ```
  </Accordion>

  <Accordion title="XFS filesystem" icon="hard-drive">
    Default on CentOS/Rocky/Alma. Use `xfs_growfs`:

    ```bash theme={null}
    sudo xfs_growfs /dev/vda1
    ```
  </Accordion>
</AccordionGroup>

<Tip>
  To check your filesystem type, run: `df -Th`
</Tip>
