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

# Expand a Linux filesystem after a disk upgrade

> Use extra VPS storage on Linux: identify the disk layout, grow a supported partition or LVM volume, then extend ext4 or XFS and check the result.

A disk upgrade increases the virtual disk size. Linux may still show the old usable space until you expand the partition and filesystem.

> [!WARNING]
>
> Make a current off-server backup before changing partitions or filesystems. The examples cover ext4 and XFS on a single disk, with or without a simple LVM layout. They do not cover RAID, encrypted volumes or moving partitions.

## 1. Check the disk and filesystem

Follow the upgrade's [power-cycle instructions](https://docs.edbb.com/vps-management/power-cycle-or-reboot-a-vps.md) and keep the [VNC console](https://docs.edbb.com/vps-management/enable-vnc-server.md) open. Run:

```bash theme={"system"}
findmnt -no SOURCE,FSTYPE /
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
df -hT /
```

Check that the **whole disk** shows the upgraded capacity. Then identify the root filesystem:

| Layout | Next step |
| - | - |
| Root on a plain partition, such as `/dev/vda1` | Expand that partition if there is free space immediately after it, then expand the filesystem. |
| Root on an LVM logical volume | Inspect the physical volume and free space, then use the LVM steps below. |
| Swap, EFI or another partition sits after the partition you want to grow | Stop. The free space is not adjacent; do not delete the other partition. |
| Filesystem occupies the whole disk with no partition | Do not run `growpart`; use a procedure for that layout. |
| RAID, encryption, an unfamiliar filesystem or unclear device names | Get a layout-specific procedure before continuing. |

## 2. Expand a partition into adjacent free space

Install `growpart` if it is missing:

> [tab] Debian / Ubuntu
>
> ```bash theme={"system"}
> sudo apt update
> sudo apt install cloud-guest-utils
> ```

> [tab] Rocky / AlmaLinux
>
> ```bash theme={"system"}
> sudo dnf install cloud-utils-growpart
> ```

This example is for **partition 1 on `/dev/vda`**. Use the disk and partition number from your own layout. Preview the change first:

```bash theme={"system"}
sudo growpart -N /dev/vda 1
```

Proceed only if it keeps the partition start unchanged and extends the intended partition into adjacent free space:

```bash theme={"system"}
sudo growpart /dev/vda 1
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
```

If the partition already fills the disk, it does not need this step. If Linux cannot reread the partition table, arrange a clean reboot and inspect the result before continuing; do not force repeated writes.

## 3. Expand the filesystem

> [tab] Plain ext4
>
> For an ext4 root filesystem directly on `/dev/vda1`:
>
> ```bash theme={"system"}
> sudo resize2fs /dev/vda1
> ```
>
> Use the actual filesystem device. Do not run this command on XFS or on an LVM physical volume.

> [tab] Plain XFS
>
> XFS grows using its mounted directory. For the root filesystem:
>
> ```bash theme={"system"}
> sudo xfs_growfs /
> ```
>
> The underlying partition must already have the extra space. XFS cannot be shrunk with this command.

> [tab] LVM with ext4 or XFS
>
> Inspect the volume names and free space:
>
> ```bash theme={"system"}
> sudo pvs
> sudo vgs
> sudo lvs -o lv_path,lv_size,vg_name
> ```
>
> If the physical volume is inside a partition, grow that partition first using its **actual number**. For example, `/dev/vda3` requires `growpart -N /dev/vda 3`, followed by `growpart /dev/vda 3` after checking the preview.
>
> Let LVM recognise the larger physical volume:
>
> ```bash theme={"system"}
> sudo pvresize /dev/vda3
> sudo vgs
> ```
>
> Substitute your actual physical volume. If the volume group already has enough free space, a partition change and `pvresize` are unnecessary.
>
> Extend the root logical volume by an amount no greater than the group's free space. This example adds **10 GiB**; replace both the amount and logical-volume path:
>
> ```bash theme={"system"}
> sudo lvextend -L +10G /dev/VG/ROOT_LV
> ```
>
> Then grow the filesystem: for ext4, run `sudo resize2fs /dev/VG/ROOT_LV`; for XFS mounted at `/`, run `sudo xfs_growfs /`. Do not allocate space to a different logical volume by guessing its name.

## 4. Verify the result

```bash theme={"system"}
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS
df -hT /
```

`df` should show the larger usable filesystem. Check that your applications work and that the system logs contain no storage errors.

## If another partition is in the way

Do not delete swap, EFI or recovery partitions just to make `growpart` succeed. Moving partitions requires a separate maintenance and recovery plan. The [Linux rescue guide](https://docs.edbb.com/vps-management/linux-rescue.md) explains how to inspect the disk and recover files; booting rescue media alone does not make a partition move safe.

For a layout you cannot safely extend, consider moving your data to a freshly installed VPS with the required disk size, then verifying the new installation before cancelling the old one.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.